All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups
Drawing Text

Detailed Description

Functions to draw text into a graphics context.

See Graphics Context for more information about the graphics context.

Other drawing functions and related documentation:

Function Documentation

void graphics_draw_text ( GContext *  ctx,
const char *  text,
GFont const  font,
const GRect  box,
const GTextOverflowMode  overflow_mode,
const GTextAlignment  alignment,
const GTextLayoutCacheRef  layout 
)

Draw text into the current graphics context, using the context's current text color. The text will be drawn inside a box with the specified dimensions and configuration, with clipping occuring automatically.

Parameters
ctxThe destination graphics context in which to draw
textThe zero terminated UTF-8 string to draw
fontThe font in which the text should be set
boxThe bounding box in which to draw the text. The first line of text will be drawn against the top of the box.
overflow_modeThe overflow behavior, in case the text is larger than what fits inside the box.
alignmentThe horizontal alignment of the text
layoutOptional layout cache data. Supply NULL to ignore the layout caching mechanism.
GSize graphics_text_layout_get_content_size ( const char *  text,
GFont const  font,
const GRect  box,
const GTextOverflowMode  overflow_mode,
const GTextAlignment  alignment 
)

Obtain the maximum size that a text with given font, overflow mode and alignment occupies within a given rectangular constraint.

Parameters
textThe zero terminated UTF-8 string for which to calculate the size
fontThe font in which the text should be set while calculating the size
boxThe bounding box in which the text should be constrained
overflow_modeThe overflow behavior, in case the text is larger than what fits inside the box.
alignmentThe horizontal alignment of the text
Returns
The maximum size occupied by the text

Typedef Documentation

typedef TextLayout* GTextLayoutCacheRef

Pointer to opaque text layout cache data structure.

Enumeration Type Documentation

Text aligment controls the way the text is aligned inside the box the text is drawn into.

See Also
graphics_draw_text
text_layer_set_text_alignment
Enumerator
GTextAlignmentLeft 

Aligns the text to the left of the drawing box.

GTextAlignmentCenter 

Aligns the text centered inside the drawing box.

GTextAlignmentRight 

Aligns the text to the right of the drawing box.

Text overflow mode controls the way text overflows when the string that is drawn does not fit inside the area constraint.

See Also
graphics_draw_text
text_layer_set_overflow_mode
Enumerator
GTextOverflowModeWordWrap 

On overflow, wrap words to a new line below the current one. Once vertical space is consumed, the last line may be clipped.

GTextOverflowModeTrailingEllipsis 

On overflow, wrap words to a new line below the current one. Once vertical space is consumed, truncate as needed to fit a trailing ellipsis (...). Clipping may occur if the vertical space cannot accomodate the first line of text.

GTextOverflowModeFill 

Acts like GTextOverflowModeTrailingEllipsis, plus trims leading and trailing newlines, while treating all other newlines as spaces.