Table of Contents

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 Context
font CairoFont
text string
lineX double
lineY double
flowPath TextFlowPath[]
orientation EnumTextOrientation
linebreak EnumLinebreakBehavior

Returns

double

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 Context

The context of the text.

font CairoFont

The font of the text.

text string

The text itself.

boxWidth double

The width of the box containing the text.

orientation EnumTextOrientation

The 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 Context

The context of the text.

font CairoFont

The font of the text.

text string

The text itself.

posX double

The X position of the text.

posY double

The Y position of the text.

boxWidth double

The width of the box containing the text.

orientation EnumTextOrientation

The 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 Context

The context of the text.

font CairoFont

The font of the text

lines TextLine[]

The preformatted lines of the text.

orientation EnumTextOrientation

The 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 Context

The context of the text.

font CairoFont

The font of the text.

lines TextLine[]

The lines of text.

posX double

The X position of the text.

posY double

The Y position of the text.

boxWidth double

The width of the box containing the text.

orientation EnumTextOrientation

The 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 Context

The context of the text.

font CairoFont

The font of the text.

text string

The text to draw.

offsetX double

The X offset for the text start position. (Default: 0)

offsetY double

The Y offset for the text start position. (Default: 0)

textPathMode bool

Whether 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 CairoFont

The 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 CairoFont
text string
boxWidth double
linebreak EnumLinebreakBehavior

Returns

double

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 CairoFont

The font of the text.

text string

The text itself.

linebreak EnumLinebreakBehavior
flowPath TextFlowPath[]

The path for the text.

lineY double

The 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 CairoFont
text string
boxWidth double
linebreak EnumLinebreakBehavior

Returns

int

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 CairoFont

The font of the text.

text string

The text itself.

linebreak EnumLinebreakBehavior
flowPath TextFlowPath[]

The path for the text.

lineY double

The 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 Context
text string
boxwidth double
lineHeightMultiplier double
linebreak EnumLinebreakBehavior
keepLinebreakChar 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 Context

Contexts of the GUI.

text string

The text to be split

linebreak EnumLinebreakBehavior
flowPath TextFlowPath[]

Sets the general flow of text.

startOffsetX double

The offset start position for X

startY double

The offset start position for Y

lineHeightMultiplier double
keepLinebreakChar 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 CairoFont
fulltext string
boxWidth double
linebreak EnumLinebreakBehavior
keepLinebreakChar 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 CairoFont

The font of the text.

fulltext string

The text of the lines.

linebreak EnumLinebreakBehavior
flowPath TextFlowPath[]

The flow direction of text.

startOffsetX double

The offset start position for X

startY double

The offset start position for Y

keepLinebreakChar bool

Returns

TextLine[]

The text broken up into lines.