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
ctx
Contextfont
CairoFonttext
stringlineX
doublelineY
doubleflowPath
TextFlowPath[]orientation
EnumTextOrientationlinebreak
EnumLinebreakBehavior
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
ctx
ContextThe context of the text.
font
CairoFontThe font of the text.
text
stringThe text itself.
boxWidth
doubleThe width of the box containing the text.
orientation
EnumTextOrientationThe 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
ctx
ContextThe context of the text.
font
CairoFontThe font of the text.
text
stringThe text itself.
posX
doubleThe X position of the text.
posY
doubleThe Y position of the text.
boxWidth
doubleThe width of the box containing the text.
orientation
EnumTextOrientationThe 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
ctx
ContextThe context of the text.
font
CairoFontThe font of the text
lines
TextLine[]The preformatted lines of the text.
orientation
EnumTextOrientationThe 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
ctx
ContextThe context of the text.
font
CairoFontThe font of the text.
lines
TextLine[]The lines of text.
posX
doubleThe X position of the text.
posY
doubleThe Y position of the text.
boxWidth
doubleThe width of the box containing the text.
orientation
EnumTextOrientationThe 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
ctx
ContextThe context of the text.
font
CairoFontThe font of the text.
text
stringThe text to draw.
offsetX
doubleThe X offset for the text start position. (Default: 0)
offsetY
doubleThe Y offset for the text start position. (Default: 0)
textPathMode
boolWhether 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
font
CairoFontThe 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
font
CairoFonttext
stringboxWidth
doublelinebreak
EnumLinebreakBehavior
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
font
CairoFontThe font of the text.
text
stringThe text itself.
linebreak
EnumLinebreakBehaviorflowPath
TextFlowPath[]The path for the text.
lineY
doubleThe 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
font
CairoFonttext
stringboxWidth
doublelinebreak
EnumLinebreakBehavior
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
font
CairoFontThe font of the text.
text
stringThe text itself.
linebreak
EnumLinebreakBehaviorflowPath
TextFlowPath[]The path for the text.
lineY
doubleThe 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
ctx
Contexttext
stringboxwidth
doublelineHeightMultiplier
doublelinebreak
EnumLinebreakBehaviorkeepLinebreakChar
bool
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
ctx
ContextContexts of the GUI.
text
stringThe text to be split
linebreak
EnumLinebreakBehaviorflowPath
TextFlowPath[]Sets the general flow of text.
startOffsetX
doubleThe offset start position for X
startY
doubleThe offset start position for Y
lineHeightMultiplier
doublekeepLinebreakChar
bool
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
font
CairoFontfulltext
stringboxWidth
doublelinebreak
EnumLinebreakBehaviorkeepLinebreakChar
bool
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
font
CairoFontThe font of the text.
fulltext
stringThe text of the lines.
linebreak
EnumLinebreakBehaviorflowPath
TextFlowPath[]The flow direction of text.
startOffsetX
doubleThe offset start position for X
startY
doubleThe offset start position for Y
keepLinebreakChar
bool
Returns
- TextLine[]
The text broken up into lines.