pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Pebble JavaScript API
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
    • Rocky
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

Fonts

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:

GFont custom_font = fonts_load_custom_font
   (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 chapter App Resources in the Pebble Developer Guides which explains how to work with font resources and embed a font into your app.

Function Documentation

  • SDK 3
  • SDK 4
GFont fonts_get_system_font(const char * font_key)

Loads a system font corresponding to the specified font key.

Note

This may load a font from the flash peripheral into RAM.

Parameters

font_key

The 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.

GFont fonts_get_system_font(const char * font_key)

Loads a system font corresponding to the specified font key.

Note

This may load a font from the flash peripheral into RAM.

Parameters

font_key

The string key of the font to load. See System Fonts guide 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.

GFont fonts_load_custom_font(ResHandle handle)

Loads a custom font.

Note

this may load a font from the flash peripheral into RAM.

Parameters

handle

The 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

Read the App Resources guide on how to embed a font into your app.

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

font

The font to unload.

Typedef Documentation

typedef struct FontInfo FontInfo
typedef FontInfo * GFont

Pointer to opaque font data structure.

See Also

fonts_load_custom_font()

Need some help?

Functions

  • fonts_get_system_font
  • fonts_load_custom_font
  • fonts_unload_custom_font

Typedefs

  • FontInfo
  • GFont

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can send us a message through the website!