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
doubleThe size of the font before scaling is applied.
fontName
stringThe 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
doubleThe size of the font before scaling is applied.
fontName
stringThe 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
FontConfigThe 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
Orientation
public EnumTextOrientation Orientation
Field Value
RenderTwice
Whether or not the font is rendered twice.
public bool RenderTwice
Field Value
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
stringThe text to adjust
bounds
ElementBoundsThe bounds to adjust the text to.
onlyGrow
boolIf 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
stringThe text of the object.
bounds
ElementBoundsThe 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
stringThe 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
ContextThe context to set up the CairoFont with.
SmallButtonText(EnumButtonStyle)
public static CairoFont SmallButtonText(EnumButtonStyle style = EnumButtonStyle.Normal)
Parameters
style
EnumButtonStyle
Returns
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
WithColor(double[])
Sets the color of the CairoFont.
public CairoFont WithColor(double[] color)
Parameters
color
double[]The color to set.
Returns
WithFont(string)
public CairoFont WithFont(string fontname)
Parameters
fontname
string
Returns
WithFontSize(float)
Sets the base size of the CairoFont.
public CairoFont WithFontSize(float fontSize)
Parameters
fontSize
floatThe new font size
Returns
WithLineHeightMultiplier(double)
public CairoFont WithLineHeightMultiplier(double lineHeightMul)
Parameters
lineHeightMul
double
Returns
WithOrientation(EnumTextOrientation)
public CairoFont WithOrientation(EnumTextOrientation orientation)
Parameters
orientation
EnumTextOrientation
Returns
WithRenderTwice()
Sets the font to render twice.
public CairoFont WithRenderTwice()
Returns
WithSlant(FontSlant)
public CairoFont WithSlant(FontSlant slant)
Parameters
slant
FontSlant
Returns
WithStroke(double[], double)
public CairoFont WithStroke(double[] color, double width)
Parameters
Returns
WithWeight(FontWeight)
Adds a weight to the font.
public CairoFont WithWeight(FontWeight weight)
Parameters
weight
FontWeightThe weight of the font.