Table of Contents

Class CairoFont

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Represent a font with sizing and styling for use in rendering text

public class CairoFont : FontConfig, IDisposable
Inheritance
CairoFont
Implements
Inherited Members
Extension Methods

Constructors

CairoFont()

Creates an empty CairoFont instance.

public CairoFont()

CairoFont(double, string)

Creates a CairoFont object.

public CairoFont(double unscaledFontSize, string fontName)

Parameters

unscaledFontSize double

The size of the font before scaling is applied.

fontName string

The name of the font.

CairoFont(double, string, double[], double[])

Creates a CairoFont object

public CairoFont(double unscaledFontSize, string fontName, double[] color, double[] strokeColor = null)

Parameters

unscaledFontSize double

The size of the font before scaling is applied.

fontName string

The name of the font.

color double[]

The color of the font.

strokeColor double[]

The color for the stroke of the font. (Default: Null)

CairoFont(FontConfig)

Creates a pre-populated CairoFont instance.

public CairoFont(FontConfig config)

Parameters

config FontConfig

The configuration for the CairoFont

Fields

FontMeasuringContext

The static Context for all Cairo Fonts.

public static Context FontMeasuringContext

Field Value

Context

LineHeightMultiplier

public double LineHeightMultiplier

Field Value

double

Orientation

public EnumTextOrientation Orientation

Field Value

EnumTextOrientation

RenderTwice

Whether or not the font is rendered twice.

public bool RenderTwice

Field Value

bool

Slant

public FontSlant Slant

Field Value

FontSlant

Methods

AutoBoxSize(string, ElementBounds, bool)

Adjust the bounds so that it fits given text in one line

public void AutoBoxSize(string text, ElementBounds bounds, bool onlyGrow = false)

Parameters

text string

The text to adjust

bounds ElementBounds

The bounds to adjust the text to.

onlyGrow bool

If true, the box will not be made smaller

AutoFontSize(string, ElementBounds, bool)

Adjust font size so that it fits given bounds

public void AutoFontSize(string text, ElementBounds bounds, bool onlyShrink = true)

Parameters

text string

The text of the object.

bounds ElementBounds

The bounds of the element where the font is displayed.

onlyShrink bool

ButtonPressedText()

Creates a text preset for when the button is pressed.

public static CairoFont ButtonPressedText()

Returns

CairoFont

The text preset for a pressed button.

ButtonText()

Creates a Button Text preset.

public static CairoFont ButtonText()

Returns

CairoFont

The button text preset.

Clone()

Clone function. Creates a duplicate of this Cairofont.

public CairoFont Clone()

Returns

CairoFont

The duplicate font.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetFontExtents()

Gets the font's extents.

public FontExtents GetFontExtents()

Returns

FontExtents

The FontExtents for this particular font.

GetTextExtents(string)

Gets the extents of the text.

public TextExtents GetTextExtents(string text)

Parameters

text string

The text to extend.

Returns

TextExtents

The Text extends for this font with this text.

SetupContext(Context)

Sets up the context. Must be executed in the main thread, as it is not thread safe.

public void SetupContext(Context ctx)

Parameters

ctx Context

The context to set up the CairoFont with.

SmallButtonText(EnumButtonStyle)

public static CairoFont SmallButtonText(EnumButtonStyle style = EnumButtonStyle.Normal)

Parameters

style EnumButtonStyle

Returns

CairoFont

SmallTextInput()

Creates a text oreset for smaller text input fields.

public static CairoFont SmallTextInput()

Returns

CairoFont

The smaller text input preset.

TextInput()

Creates a text preset for text input fields.

public static CairoFont TextInput()

Returns

CairoFont

The text field input preset.

WhiteDetailText()

Creates a white text for details.

public static CairoFont WhiteDetailText()

Returns

CairoFont

A white text for details.

WhiteMediumText()

Creates a white text for medium dialog.

public static CairoFont WhiteMediumText()

Returns

CairoFont

The white text for medium dialog.

WhiteSmallText()

Creates a white text for small dialogs.

public static CairoFont WhiteSmallText()

Returns

CairoFont

The white text for small dialogs

WhiteSmallishText()

Creates a white text for smallish dialogs.

public static CairoFont WhiteSmallishText()

Returns

CairoFont

The white text for small dialogs.

WhiteSmallishText(string)

Creates a white text for smallish dialogs, using the specified base font

public static CairoFont WhiteSmallishText(string baseFont)

Parameters

baseFont string

Returns

CairoFont

WithColor(double[])

Sets the color of the CairoFont.

public CairoFont WithColor(double[] color)

Parameters

color double[]

The color to set.

Returns

CairoFont

WithFont(string)

public CairoFont WithFont(string fontname)

Parameters

fontname string

Returns

CairoFont

WithFontSize(float)

Sets the base size of the CairoFont.

public CairoFont WithFontSize(float fontSize)

Parameters

fontSize float

The new font size

Returns

CairoFont

WithLineHeightMultiplier(double)

public CairoFont WithLineHeightMultiplier(double lineHeightMul)

Parameters

lineHeightMul double

Returns

CairoFont

WithOrientation(EnumTextOrientation)

public CairoFont WithOrientation(EnumTextOrientation orientation)

Parameters

orientation EnumTextOrientation

Returns

CairoFont

WithRenderTwice()

Sets the font to render twice.

public CairoFont WithRenderTwice()

Returns

CairoFont

WithSlant(FontSlant)

public CairoFont WithSlant(FontSlant slant)

Parameters

slant FontSlant

Returns

CairoFont

WithStroke(double[], double)

public CairoFont WithStroke(double[] color, double width)

Parameters

color double[]
width double

Returns

CairoFont

WithWeight(FontWeight)

Adds a weight to the font.

public CairoFont WithWeight(FontWeight weight)

Parameters

weight FontWeight

The weight of the font.

Returns

CairoFont