Max 5 API Reference
A textlayout is lower-level text rendering object used by higher-level entities such as TextField. More...
![]() |
Enumerations | |
enum | t_jgraphics_textlayout_flags { JGRAPHICS_TEXTLAYOUT_NOWRAP = 1, JGRAPHICS_TEXTLAYOUT_USEELLIPSIS = 3 } |
Flags for setting text layout options. More... | |
Functions | |
t_jtextlayout * | jtextlayout_create () |
Create a new textlayout object. | |
t_jtextlayout * | jtextlayout_withbgcolor (t_jgraphics *g, t_jrgba *bgcolor) |
Create a new textlayout object. | |
void | jtextlayout_destroy (t_jtextlayout *textlayout) |
Release/free a textlayout object. | |
void | jtextlayout_set (t_jtextlayout *textlayout, const char *utf8, t_jfont *jfont, double x, double y, double width, double height, t_jgraphics_text_justification justification, t_jgraphics_textlayout_flags flags) |
Set the text and attributes of a textlayout object. | |
void | jtextlayout_settextcolor (t_jtextlayout *textlayout, t_jrgba *textcolor) |
Set the color to render text in a textlayout object. | |
void | jtextlayout_measure (t_jtextlayout *textlayout, long startindex, long numchars, long includewhitespace, double *width, double *height, long *numlines) |
Return a measurement of how much space will be required to draw the text of a textlayout. | |
void | jtextlayout_draw (t_jtextlayout *tl, t_jgraphics *g) |
Draw a textlayout in a given graphics context. | |
long | jtextlayout_getnumchars (t_jtextlayout *tl) |
Retrieve a count of the number of characters in a textlayout object. | |
t_max_err | jtextlayout_getcharbox (t_jtextlayout *tl, long index, t_rect *rect) |
Retrieve the t_rect containing a character at a given index. | |
t_max_err | jtextlayout_getchar (t_jtextlayout *tl, long index, long *pch) |
Retrieve the unicode character at a given index. |
A textlayout is lower-level text rendering object used by higher-level entities such as TextField.
Flags for setting text layout options.
JGRAPHICS_TEXTLAYOUT_NOWRAP |
disable word wrapping |
JGRAPHICS_TEXTLAYOUT_USEELLIPSIS |
show ... if a line doesn't fit (implies NOWRAP too) |
Definition at line 916 of file jgraphics.h.
t_jtextlayout* jtextlayout_create | ( | ) |
Create a new textlayout object.
void jtextlayout_destroy | ( | t_jtextlayout * | textlayout | ) |
Release/free a textlayout object.
textlayout | The textlayout object to release. |
void jtextlayout_draw | ( | t_jtextlayout * | tl, | |
t_jgraphics * | g | |||
) |
Draw a textlayout in a given graphics context.
tl | The textlayout object to query. | |
g | The graphics context in which to draw the text. |
t_max_err jtextlayout_getchar | ( | t_jtextlayout * | tl, | |
long | index, | |||
long * | pch | |||
) |
Retrieve the unicode character at a given index.
tl | The textlayout object to query. | |
index | The index from which to fetch the unicode character. | |
pch | The address of a variable to hold the unicode character value upon return. |
t_max_err jtextlayout_getcharbox | ( | t_jtextlayout * | tl, | |
long | index, | |||
t_rect * | rect | |||
) |
long jtextlayout_getnumchars | ( | t_jtextlayout * | tl | ) |
Retrieve a count of the number of characters in a textlayout object.
tl | The textlayout object to query. |
void jtextlayout_measure | ( | t_jtextlayout * | textlayout, | |
long | startindex, | |||
long | numchars, | |||
long | includewhitespace, | |||
double * | width, | |||
double * | height, | |||
long * | numlines | |||
) |
Return a measurement of how much space will be required to draw the text of a textlayout.
textlayout | The textlayout object to query. | |
startindex | You can measure a subset of the characters. This defines the character from which to start. | |
numchars | Pass -1 for all characters from startindex to end | |
includewhitespace | Define whether to measure with or without whitespace truncated from edges. | |
width | Returns the width of text not including any margins. | |
height | Returns the height of text not including any margins. | |
numlines | Returns the number of lines of text. |
void jtextlayout_set | ( | t_jtextlayout * | textlayout, | |
const char * | utf8, | |||
t_jfont * | jfont, | |||
double | x, | |||
double | y, | |||
double | width, | |||
double | height, | |||
t_jgraphics_text_justification | justification, | |||
t_jgraphics_textlayout_flags | flags | |||
) |
Set the text and attributes of a textlayout object.
textlayout | The textlayout object. | |
utf8 | The text to render. | |
jfont | The font with which to render the text. | |
x | The text is placed within rect specified by x, y, width, height. | |
y | The text is placed within rect specified by x, y, width, height. | |
width | The text is placed within rect specified by x, y, width, height. | |
height | The text is placed within rect specified by x, y, width, height. | |
justification | How to justify the text within the rect. | |
flags | Additional flags to control behaviour. |
void jtextlayout_settextcolor | ( | t_jtextlayout * | textlayout, | |
t_jrgba * | textcolor | |||
) |
Set the color to render text in a textlayout object.
textlayout | The textlayout object for which to set the color. | |
textcolor | The color for the text. |
t_jtextlayout* jtextlayout_withbgcolor | ( | t_jgraphics * | g, | |
t_jrgba * | bgcolor | |||
) |
Create a new textlayout object.
This gives a hint to the textlayout as to what the text bgcolor will be. It won't actually paint the bg for you. But, it does let it do a better job.
g | The graphics context for the textlayout. | |
bgcolor | The background color for the textlayout. |