Navigation C API Pages Python bindings Applications

Text Attributes

Text attributes describe text font, size, etc. Attributes can be either passed down as a C constants, e.g. GP_TATTR_BOLD | GP_TATTR_LARGE or parsed from a string from JSON e.g. "bold|large".


int gp_widget_tattr_parse(const char *attrs, gp_widget_tattr *tattr, int flags);

Parses text attribute string, returns zero on success.

The flags can be used to select which attributes should be enabled in the parser. Passing GP_TATTR_FONT enables font parsing and GP_TATTR_HALIGN enables horizontal alignment flags, both can be enabled by passing a bitwise or i.e. GP_TATTR_FONT | GP_TATTR_HALIGN.

const gp_text_style *gp_widget_tattr_font(gp_widget_tattr attr, const gp_widget_render_ctx *ctx)

Returns a font based on the attributes and render context, this is supposed to be used in widgets for size computation and rendering.

Table 1. Text attributes
enum string Description



Enables bold text.



Enables large text.



Monospace font.



Align text to the left.



Center text horizontally.



Align text to the right.

Labels with different text attributes

Label examples