A textlayout is lower-level text rendering object used by higher-level entities such as TextField. More...

+ Collaboration diagram for TextLayout:

Enumerations

enum  t_jgraphics_textlayout_flags { JGRAPHICS_TEXTLAYOUT_NOWRAP, JGRAPHICS_TEXTLAYOUT_USEELLIPSIS }
 Flags for setting text layout options. More...
 

Functions

t_jtextlayoutjtextlayout_create ()
 Create a new textlayout object. More...
 
t_jtextlayoutjtextlayout_withbgcolor (t_jgraphics *g, t_jrgba *bgcolor)
 Create a new textlayout object. More...
 
void jtextlayout_destroy (t_jtextlayout *textlayout)
 Release/free a textlayout object. More...
 
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. More...
 
void jtextlayout_settext (t_jtextlayout *textlayout, const char *utf8, t_jfont *jfont)
 Set the text of a textlayout object. More...
 
void jtextlayout_settextcolor (t_jtextlayout *textlayout, t_jrgba *textcolor)
 Set the color to render text in a textlayout object. More...
 
void jtextlayout_measuretext (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. More...
 
void jtextlayout_draw (t_jtextlayout *tl, t_jgraphics *g)
 Draw a textlayout in a given graphics context. More...
 
long jtextlayout_getnumchars (t_jtextlayout *tl)
 Retrieve a count of the number of characters in a textlayout object. More...
 
t_max_err jtextlayout_getcharbox (t_jtextlayout *tl, long index, t_rect *rect)
 Retrieve the t_rect containing a character at a given index. More...
 
t_max_err jtextlayout_getchar (t_jtextlayout *tl, long index, long *pch)
 Retrieve the unicode character at a given index. More...
 
t_jpathjtextlayout_createpath (t_jtextlayout *tl)
 Create a t_jpath object representing the text layout. More...
 

Detailed Description

A textlayout is lower-level text rendering object used by higher-level entities such as TextField.

Enumeration Type Documentation

Flags for setting text layout options.

Enumerator
JGRAPHICS_TEXTLAYOUT_NOWRAP 

disable word wrapping

JGRAPHICS_TEXTLAYOUT_USEELLIPSIS 

show ... if a line doesn't fit (implies NOWRAP too)

Function Documentation

t_jtextlayout* jtextlayout_create ( )

Create a new textlayout object.

Returns
The new textlayout object.
t_jpath* jtextlayout_createpath ( t_jtextlayout tl)

Create a t_jpath object representing the text layout.

Parameters
tlThe textlayout object to retrieve a path for.
Returns
A t_jpath. When finished with the path free it with jgraphics_path_destroy.
void jtextlayout_destroy ( t_jtextlayout textlayout)

Release/free a textlayout object.

Parameters
textlayoutThe textlayout object to release.
void jtextlayout_draw ( t_jtextlayout tl,
t_jgraphics g 
)

Draw a textlayout in a given graphics context.

Parameters
tlThe textlayout object to query.
gThe 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.

Parameters
tlThe textlayout object to query.
indexThe index from which to fetch the unicode character.
pchThe address of a variable to hold the unicode character value upon return.
Returns
A Max error code.
t_max_err jtextlayout_getcharbox ( t_jtextlayout tl,
long  index,
t_rect rect 
)

Retrieve the t_rect containing a character at a given index.

Parameters
tlThe textlayout object to query.
indexThe index from which to fetch the unicode character.
rectThe address of a valid t_rect which will be filled in upon return.
Returns
A Max error code.
long jtextlayout_getnumchars ( t_jtextlayout tl)

Retrieve a count of the number of characters in a textlayout object.

Parameters
tlThe textlayout object to query.
Returns
The number of characters.
void jtextlayout_measuretext ( 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.

Parameters
textlayoutThe textlayout object to query.
startindexYou can measure a subset of the characters. This defines the character from which to start.
numcharsPass -1 for all characters from startindex to end
includewhitespaceDefine whether to measure with or without whitespace truncated from edges.
widthReturns the width of text not including any margins.
heightReturns the height of text not including any margins.
numlinesReturns 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.

Parameters
textlayoutThe textlayout object.
utf8The text to render.
jfontThe font with which to render the text.
xThe text is placed within rect specified by x, y, width, height.
yThe text is placed within rect specified by x, y, width, height.
widthThe text is placed within rect specified by x, y, width, height.
heightThe text is placed within rect specified by x, y, width, height.
justificationHow to justify the text within the rect.
flagsAdditional flags to control behaviour.
void jtextlayout_settext ( t_jtextlayout textlayout,
const char *  utf8,
t_jfont jfont 
)

Set the text of a textlayout object.

Parameters
textlayoutThe textlayout object.
utf8The text to render.
jfontThe font with which to render the text.
void jtextlayout_settextcolor ( t_jtextlayout textlayout,
t_jrgba textcolor 
)

Set the color to render text in a textlayout object.

Parameters
textlayoutThe textlayout object for which to set the color.
textcolorThe 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.

Parameters
gThe graphics context for the textlayout.
bgcolorThe background color for the textlayout.
Returns
The new textlayout object.
  Copyright © 2015, Cycling '74