Skip to content

Instantly share code, notes, and snippets.

@ermiry
Created January 3, 2020 20:30
Show Gist options
  • Save ermiry/f166db28d4b2e4d0d899de0de68a9a8e to your computer and use it in GitHub Desktop.
Save ermiry/f166db28d4b2e4d0d899de0de68a9a8e to your computer and use it in GitHub Desktop.
#include "cengine/renderer.h"
#include "cengine/ui/font.h"
int load_font (Renderer *renderer) {
int retval = 1;
if (renderer) {
// first create the font structure
Font *main_font = ui_font_create ("roboto", "./assets/fonts/Roboto-Regular.ttf");
if (main_font) {
// you need to specify up front the sizes for your font
ui_font_set_sizes (main_font, 6, 16, 20, 24, 32, 64, 200);
// then you can load the font and all the sizes witll be loaded as well
if (!ui_font_load (main_font, renderer, TTF_STYLE_NORMAL)) {
retval = 0;
}
}
}
return retval;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment