Skip to content

Commit

Permalink
fix fc-font examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mobius3 committed May 26, 2020
1 parent 33b1fdc commit 2119c01
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions include/font-chef/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ struct fc_pixels {
*
* void main() {
* uint8_t * font_buffer = read_file("times.ttf"); // replace with real font path
* struct fc_font font;
* fc_construct(&font, font_buffer, fc_px(12), fc_color_red);
* struct fc_font * font = fc_construct(font_buffer, fc_px(12), fc_color_red);
* // font is ready to be used
* }
* @endcode
Expand Down Expand Up @@ -104,9 +103,9 @@ FONT_CHEF_EXPORT extern struct fc_font * fc_construct(
* **Example**
* @code
* void main() {
* struct fc_font font; // suppose already initialized with fc_construct
* fc_add(&font, fc_unicode_block_basic_latin.fist, fc_unicode_block_basic_latin.last);
* fc_add(&font, fc_unicode_block_latin_1_supplement.fist, fc_unicode_block_latin_1_supplement.last);
* struct fc_font * font; // suppose already initialized with fc_construct
* fc_add(font, fc_unicode_block_basic_latin.fist, fc_unicode_block_basic_latin.last);
* fc_add(font, fc_unicode_block_latin_1_supplement.fist, fc_unicode_block_latin_1_supplement.last);
* // font is ready for `fc_cook`
* }
* @endcode
Expand Down Expand Up @@ -138,12 +137,11 @@ FONT_CHEF_EXPORT extern void fc_add(
* void * create_texture(void * pixel_data, size_t width, size_t height);
*
* void main() {
* struct fc_font font; // suppose `fc_construct` and `fc_add` was called
* struct fc_font * font; // suppose `fc_construct` and `fc_add` was called
* fc_cook(&font);
* void * texutre = create_texture(
* font.pixels.data,
* font.pixels.dimensions.width,
* font.pixels.dimensions.height
* fc_get_pixels(font)->data,
* fc_get_pixels(font)->dimensions
* );
* // now you're ready for `fc_render`
* }
Expand Down Expand Up @@ -177,11 +175,11 @@ FONT_CHEF_EXPORT extern void fc_cook(struct fc_font * font);
* void render_clip(void * texture, fc_rect src, fc_rect dst);
*
* void main() {
* struct fc_font font; // suppose `fc_construct`, `fc_add` and `fc_cook` already called
* struct fc_font * font; // suppose `fc_construct`, `fc_add` and `fc_cook` already called
* void * texture; // suppose texture created as in `fc_cook` examples
* struct fc_character_mapping mapping[13];
* char const * hello_world = "Hello, World!";
* int glyph_count = fc_render(&font, hello_world, 13, &mapping);
* int glyph_count = fc_render(font, hello_world, 13, &mapping);
* for (int i = 0; i < glyph_count; ++i) {
* render_clip(texture, mapping[i].source, mapping[i].destination);
* }
Expand Down

0 comments on commit 2119c01

Please sign in to comment.