Class TextDrawUtil
- Namespace
- Vintagestory.API.Client
- Assembly
- VintagestoryAPI.dll
public class TextDrawUtil
- Inheritance
-
TextDrawUtil
- Inherited Members
- Extension Methods
Methods
AutobreakAndDrawMultilineText(Context, CairoFont, string, double, double, TextFlowPath[], EnumTextOrientation, EnumLinebreakBehavior)
public double AutobreakAndDrawMultilineText(Context ctx, CairoFont font, string text, double lineX, double lineY, TextFlowPath[] flowPath, EnumTextOrientation orientation = EnumTextOrientation.Left, EnumLinebreakBehavior linebreak = EnumLinebreakBehavior.AfterWord)
Parameters
ctxContextfontCairoFonttextstringlineXdoublelineYdoubleflowPathTextFlowPath[]orientationEnumTextOrientationlinebreakEnumLinebreakBehavior
Returns
AutobreakAndDrawMultilineText(Context, CairoFont, string, double, EnumTextOrientation)
Use Matrix transformation to move the draw position
public void AutobreakAndDrawMultilineText(Context ctx, CairoFont font, string text, double boxWidth, EnumTextOrientation orientation = EnumTextOrientation.Left)
Parameters
ctxContextThe context of the text.
fontCairoFontThe font of the text.
textstringThe text itself.
boxWidthdoubleThe width of the box containing the text.
orientationEnumTextOrientationThe orientation of the text.
AutobreakAndDrawMultilineTextAt(Context, CairoFont, string, double, double, double, EnumTextOrientation)
Draws the text with matrix transformations.
public double AutobreakAndDrawMultilineTextAt(Context ctx, CairoFont font, string text, double posX, double posY, double boxWidth, EnumTextOrientation orientation = EnumTextOrientation.Left)
Parameters
ctxContextThe context of the text.
fontCairoFontThe font of the text.
textstringThe text itself.
posXdoubleThe X position of the text.
posYdoubleThe Y position of the text.
boxWidthdoubleThe width of the box containing the text.
orientationEnumTextOrientationThe orientation of the text.
Returns
- double
The new height of the text.
DrawMultilineText(Context, CairoFont, TextLine[], EnumTextOrientation)
lineX is set to 0 after the second line, lineY is advanced by line height for each line
public void DrawMultilineText(Context ctx, CairoFont font, TextLine[] lines, EnumTextOrientation orientation = EnumTextOrientation.Left)
Parameters
ctxContextThe context of the text.
fontCairoFontThe font of the text
linesTextLine[]The preformatted lines of the text.
orientationEnumTextOrientationThe orientation of text (Default: Left)
DrawMultilineTextAt(Context, CairoFont, TextLine[], double, double, double, EnumTextOrientation)
Draws the text with pre-set breaks.
public void DrawMultilineTextAt(Context ctx, CairoFont font, TextLine[] lines, double posX, double posY, double boxWidth, EnumTextOrientation orientation = EnumTextOrientation.Left)
Parameters
ctxContextThe context of the text.
fontCairoFontThe font of the text.
linesTextLine[]The lines of text.
posXdoubleThe X position of the text.
posYdoubleThe Y position of the text.
boxWidthdoubleThe width of the box containing the text.
orientationEnumTextOrientationThe orientation of the text.
DrawTextLine(Context, CairoFont, string, double, double, bool)
Draws a line of text on the screen.
public void DrawTextLine(Context ctx, CairoFont font, string text, double offsetX = 0, double offsetY = 0, bool textPathMode = false)
Parameters
ctxContextThe context of the text.
fontCairoFontThe font of the text.
textstringThe text to draw.
offsetXdoubleThe X offset for the text start position. (Default: 0)
offsetYdoubleThe Y offset for the text start position. (Default: 0)
textPathModeboolWhether or not to use TextPathMode.
GetLineHeight(CairoFont)
Gets the height of the font to calculate the height of the line.
public double GetLineHeight(CairoFont font)
Parameters
fontCairoFontThe font to calculate from.
Returns
- double
The height of the line.
GetMultilineTextHeight(CairoFont, string, double, EnumLinebreakBehavior)
public double GetMultilineTextHeight(CairoFont font, string text, double boxWidth, EnumLinebreakBehavior linebreak = EnumLinebreakBehavior.Default)
Parameters
fontCairoFonttextstringboxWidthdoublelinebreakEnumLinebreakBehavior
Returns
GetMultilineTextHeight(CairoFont, string, EnumLinebreakBehavior, TextFlowPath[], double)
Get the final height of the text.
public double GetMultilineTextHeight(CairoFont font, string text, EnumLinebreakBehavior linebreak, TextFlowPath[] flowPath, double lineY = 0)
Parameters
fontCairoFontThe font of the text.
textstringThe text itself.
linebreakEnumLinebreakBehaviorflowPathTextFlowPath[]The path for the text.
lineYdoubleThe height of the line
Returns
- double
The final height of the text.
GetQuantityTextLines(CairoFont, string, double, EnumLinebreakBehavior)
public int GetQuantityTextLines(CairoFont font, string text, double boxWidth, EnumLinebreakBehavior linebreak = EnumLinebreakBehavior.Default)
Parameters
fontCairoFonttextstringboxWidthdoublelinebreakEnumLinebreakBehavior
Returns
GetQuantityTextLines(CairoFont, string, EnumLinebreakBehavior, TextFlowPath[], double)
Gets the number of lines of text.
public int GetQuantityTextLines(CairoFont font, string text, EnumLinebreakBehavior linebreak, TextFlowPath[] flowPath, double lineY = 0)
Parameters
fontCairoFontThe font of the text.
textstringThe text itself.
linebreakEnumLinebreakBehaviorflowPathTextFlowPath[]The path for the text.
lineYdoubleThe height of the line
Returns
- int
The number of lines.
Lineize(Context, string, double, double, EnumLinebreakBehavior, bool)
public TextLine[] Lineize(Context ctx, string text, double boxwidth, double lineHeightMultiplier = 1, EnumLinebreakBehavior linebreak = EnumLinebreakBehavior.Default, bool keepLinebreakChar = false)
Parameters
ctxContexttextstringboxwidthdoublelineHeightMultiplierdoublelinebreakEnumLinebreakBehaviorkeepLinebreakCharbool
Returns
- TextLine[]
Lineize(Context, string, EnumLinebreakBehavior, TextFlowPath[], double, double, double, bool)
Turns the supplied text into line of text constrained by supplied flow path and starting at supplied start coordinates
public TextLine[] Lineize(Context ctx, string text, EnumLinebreakBehavior linebreak, TextFlowPath[] flowPath, double startOffsetX = 0, double startY = 0, double lineHeightMultiplier = 1, bool keepLinebreakChar = false)
Parameters
ctxContextContexts of the GUI.
textstringThe text to be split
linebreakEnumLinebreakBehaviorflowPathTextFlowPath[]Sets the general flow of text.
startOffsetXdoubleThe offset start position for X
startYdoubleThe offset start position for Y
lineHeightMultiplierdoublekeepLinebreakCharbool
Returns
- TextLine[]
The text broken up into lines.
Lineize(CairoFont, string, double, EnumLinebreakBehavior, bool)
public TextLine[] Lineize(CairoFont font, string fulltext, double boxWidth, EnumLinebreakBehavior linebreak = EnumLinebreakBehavior.Default, bool keepLinebreakChar = false)
Parameters
fontCairoFontfulltextstringboxWidthdoublelinebreakEnumLinebreakBehaviorkeepLinebreakCharbool
Returns
- TextLine[]
Lineize(CairoFont, string, EnumLinebreakBehavior, TextFlowPath[], double, double, bool)
Turns the supplied text into line of text constrained by supplied flow path and starting at supplied start coordinates
public TextLine[] Lineize(CairoFont font, string fulltext, EnumLinebreakBehavior linebreak, TextFlowPath[] flowPath, double startOffsetX = 0, double startY = 0, bool keepLinebreakChar = false)
Parameters
fontCairoFontThe font of the text.
fulltextstringThe text of the lines.
linebreakEnumLinebreakBehaviorflowPathTextFlowPath[]The flow direction of text.
startOffsetXdoubleThe offset start position for X
startYdoubleThe offset start position for Y
keepLinebreakCharbool
Returns
- TextLine[]
The text broken up into lines.