Functions to draw text into a graphics context.
More...
|
typedef struct GTextAttributes | GTextAttributes |
|
|
GTextAttributes * | graphics_text_attributes_create (void) |
|
void | graphics_text_attributes_destroy (GTextAttributes *text_attributes) |
| Destroys a previously created instance of GTextAttributes.
|
|
void | graphics_text_attributes_restore_default_text_flow (GTextAttributes *text_attributes) |
|
void | graphics_text_attributes_enable_screen_text_flow (GTextAttributes *text_attributes, uint8_t inset) |
|
void | graphics_text_attributes_restore_default_paging (GTextAttributes *text_attributes) |
|
void | graphics_text_attributes_enable_paging (GTextAttributes *text_attributes, GPoint content_origin_on_screen, GRect paging_on_screen) |
|
void | graphics_draw_text (GContext *ctx, const char *text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, GTextAttributes *text_attributes) |
|
GSize | graphics_text_layout_get_content_size (const char *text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment) |
|
GSize | graphics_text_layout_get_content_size_with_attributes (const char *text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, GTextAttributes *text_attributes) |
|
Functions to draw text into a graphics context.
See Graphics Context for more information about the graphics context.
Other drawing functions and related documentation:
◆ GTextAlignment
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.
|
◆ GTextOverflowMode
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.
|
◆ graphics_draw_text()
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
-
ctx | The destination graphics context in which to draw |
text | The zero terminated UTF-8 string to draw |
font | The font in which the text should be set |
box | The bounding box in which to draw the text. The first line of text will be drawn against the top of the box. |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
text_attributes | Optional text attributes to describe the characteristics of the text |
◆ graphics_text_attributes_create()
GTextAttributes* graphics_text_attributes_create |
( |
void |
| ) |
|
Creates an instance of GTextAttributes for advanced control when rendering text.
- Returns
- New instance of GTextAttributes
- See also
- graphics_draw_text
◆ graphics_text_attributes_enable_paging()
void graphics_text_attributes_enable_paging |
( |
GTextAttributes * |
text_attributes, |
|
|
GPoint |
content_origin_on_screen, |
|
|
GRect |
paging_on_screen |
|
) |
| |
◆ graphics_text_attributes_enable_screen_text_flow()
void graphics_text_attributes_enable_screen_text_flow |
( |
GTextAttributes * |
text_attributes, |
|
|
uint8_t |
inset |
|
) |
| |
◆ graphics_text_attributes_restore_default_paging()
void graphics_text_attributes_restore_default_paging |
( |
GTextAttributes * |
text_attributes | ) |
|
◆ graphics_text_attributes_restore_default_text_flow()
void graphics_text_attributes_restore_default_text_flow |
( |
GTextAttributes * |
text_attributes | ) |
|
◆ graphics_text_layout_get_content_size()
Obtain the maximum size that a text with given font, overflow mode and alignment occupies within a given rectangular constraint.
- Parameters
-
text | The zero terminated UTF-8 string for which to calculate the size |
font | The font in which the text should be set while calculating the size |
box | The bounding box in which the text should be constrained |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
- Returns
- The maximum size occupied by the text
- See also
- app_graphics_text_layout_get_content_size_with_attributes
◆ graphics_text_layout_get_content_size_with_attributes()
Obtain the maximum size that a text with given font, overflow mode and alignment occupies within a given rectangular constraint.
- Parameters
-
text | The zero terminated UTF-8 string for which to calculate the size |
font | The font in which the text should be set while calculating the size |
box | The bounding box in which the text should be constrained |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
text_attributes | Optional text attributes to describe the characteristics of the text |
- Returns
- The maximum size occupied by the text
- See also
- app_graphics_text_layout_get_content_size