All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups

Detailed Description

Custom and system fonts.

Pebble OS provides you with a wide range of system fonts that you can use when you need to display and render text or numbers in your Pebble watchface or watchapp.

If you want to use a system font, you call fonts_get_system_font() and simply pass it the name of the system font you want.

To use a custom font, call fonts_load_custom_font(). The sample code feature_custom_font shows how you can do this programmatically, using a font resource to convert a TrueType font into a rasterized version of that font at a specified font size.

For example:

(resource_get_handle(RESOURCE_ID_FONT_OSP_DIN_44));

Raster Gothic Condensed is the font used throughout the Pebble system, largely because it is optimized for monochromatic displays. Pebble selected this font because it allows a relatively large number of characters to be displayed on a single line, also because the font has an excellent readability vs. size ratio.

Refer to the chapterManaging App Resources in Pebble Developer Guide which explains how to work with font resources and embed a font into your app.

See Also
TextLayer
Drawing Text
text_layer_set_font
graphics_draw_text

Function Documentation

GFont fonts_get_system_font ( const char *  font_key)

Loads a system font corresponding to the specified font key.

Parameters
font_keyThe string key of the font to load. See pebble_fonts.h for a list of system fonts.
Returns
An opaque pointer to the loaded font, or, a pointer to the default (fallback) font if the specified font cannot be loaded.
Note
This may load a font from the flash peripheral into RAM.
GFont fonts_load_custom_font ( ResHandle  handle)

Loads a custom font.

Parameters
resourceThe resource handle of the font to load. See resource_ids.auto.h for a list of resource IDs, and use resource_get_handle() to obtain the resource handle.
Returns
An opaque pointer to the loaded font, or a pointer to the default (fallback) font if the specified font cannot be loaded.
See Also
Managing App Resources in Pebble Developer Guide on how to embed a font into your app.
Note
this may load a font from the flash peripheral into RAM.
void fonts_unload_custom_font ( GFont  font)

Unloads the specified custom font and frees the memory that is occupied by it.

Note
When an application exits, the system automatically unloads all fonts that have been loaded.
Parameters
fontThe font to unload.

Typedef Documentation

typedef void* GFont

Pointer to opaque font data structure.

See Also
fonts_load_custom_font()
text_layer_set_font()
graphics_draw_text()