1.1.0
font.h
1 #ifndef FONT_CHEF_FONT_H
2 #define FONT_CHEF_FONT_H
3 
12 #include <stdlib.h>
13 #include <stdint.h>
14 
15 #include "font-chef/font-chef-export.h"
16 #include "font-chef/unicode-block.h"
17 #include "font-chef/font-size.h"
18 #include "font-chef/character-mapping.h"
19 #include "font-chef/color.h"
20 #include "font-chef/size.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
34 struct fc_pixels {
38  unsigned char * data;
39 
44 };
45 
53  uint32_t line_count;
54 
58  uint32_t glyph_count;
59 };
60 
61 
69  struct fc_font;
70 
97 FONT_CHEF_EXPORT extern struct fc_font * fc_construct(
98  uint8_t const * font_data,
99  struct fc_font_size font_size,
100  struct fc_color font_color
101 );
102 
132 FONT_CHEF_EXPORT extern void fc_add(
133  struct fc_font * font,
134  uint32_t first,
135  uint32_t last
136 );
137 
167 FONT_CHEF_EXPORT extern void fc_cook(struct fc_font * font);
168 
212 FONT_CHEF_EXPORT extern struct fc_render_result fc_render(
213  struct fc_font const * font,
214  unsigned char const * text,
215  size_t byte_count,
216  struct fc_character_mapping * mapping
217 );
218 
240 FONT_CHEF_EXPORT struct fc_render_result fc_render_wrapped(
241  struct fc_font const * font,
242  unsigned char const * text,
243  size_t byte_count,
244  size_t line_width,
245  float line_height_multiplier,
246  enum fc_alignment alignment,
247  struct fc_character_mapping * mapping
248 );
249 
259 FONT_CHEF_EXPORT extern void fc_destruct(struct fc_font * font);
260 
272 FONT_CHEF_EXPORT extern struct fc_font_size fc_get_font_size(struct fc_font const * font);
273 
274 
286 FONT_CHEF_EXPORT extern struct fc_color fc_get_color(struct fc_font const * font);
287 
295 FONT_CHEF_EXPORT extern uint8_t const * fc_get_font_data(struct fc_font const * font);
296 
297 
304 FONT_CHEF_EXPORT extern size_t fc_get_block_count(struct fc_font const * font);
305 
306 
314 FONT_CHEF_EXPORT extern struct fc_unicode_block fc_get_block_at(struct fc_font const * font, size_t index);
315 
322 FONT_CHEF_EXPORT extern struct fc_pixels const * fc_get_pixels(struct fc_font const * font);
323 
334 FONT_CHEF_EXPORT extern struct fc_size fc_get_space_metrics(struct fc_font const * font);
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
340 #endif
fc_get_font_data
const uint8_t * fc_get_font_data(struct fc_font const *font)
Returns the font data specified in fc_construct.
fc_pixels::dimensions
struct fc_size dimensions
Width and height of this pixel data. Buffer size would be dimensions.width * dimensions....
Definition: font.h:43
fc_alignment
fc_alignment
Specifies an aligment to be used when rendering wrapped text.
Definition: character-mapping.h:57
fc_render_result::line_count
uint32_t line_count
How many lines were produced.
Definition: font.h:53
fc_cook
void fc_cook(struct fc_font *font)
Generates a bitmap and corresponding character information for a font.
fc_render_wrapped
struct fc_render_result fc_render_wrapped(struct fc_font const *font, unsigned char const *text, size_t byte_count, size_t line_width, float line_height_multiplier, enum fc_alignment alignment, struct fc_character_mapping *mapping)
A shortcut for rendering and then wrapping the result.
fc_font_size
Specifies the size of a font either in pixels or in points.
Definition: font-size.h:33
fc_size
Contains width and height as floats.
Definition: size.h:24
fc_construct
struct fc_font * fc_construct(uint8_t const *font_data, struct fc_font_size font_size, struct fc_color font_color)
Constructs a fc_font structure with the provided font, a size (either in pixels or points) and a font...
fc_font
A fc_font struct represents all data and metadata about a font.
fc_unicode_block
Provides information about a specific unicode block, as specified in ftp://ftp.unicode....
Definition: unicode-block.h:21
fc_destruct
void fc_destruct(struct fc_font *font)
Destroys and frees all memory allocated by this library.
fc_get_color
struct fc_color fc_get_color(struct fc_font const *font)
Returns the font color set to this font at construction time.
fc_add
void fc_add(struct fc_font *font, uint32_t first, uint32_t last)
Adds the given unicode range to the list of blocks to be cooked. You must add blocks before calling f...
fc_render_result
A structure holding the result of a call to fc_render or fc_render_wrapped
Definition: font.h:49
fc_get_block_at
struct fc_unicode_block fc_get_block_at(struct fc_font const *font, size_t index)
Returns a unicode block at the index position.
fc_get_space_metrics
struct fc_size fc_get_space_metrics(struct fc_font const *font)
Returns the space glyph width and height for this font at its specified size.
fc_render_result::glyph_count
uint32_t glyph_count
How many glphs were produced.
Definition: font.h:58
fc_get_block_count
size_t fc_get_block_count(struct fc_font const *font)
Returns count of added blocks in this font.
fc_color
Represents a 4-byte-per-pixel color with red, green, blue and alpha components.
Definition: color.h:25
fc_get_pixels
struct fc_pixels const * fc_get_pixels(struct fc_font const *font)
Returns the pixel data after for a font generated after a fc_cook was called.
fc_render
struct fc_render_result fc_render(struct fc_font const *font, unsigned char const *text, size_t byte_count, struct fc_character_mapping *mapping)
Produces a list of source and target rectangles that can be used as clipping rects (or UV maps) for t...
fc_get_font_size
struct fc_font_size fc_get_font_size(struct fc_font const *font)
Returns the font size set to this font at construction time.
fc_character_mapping
Specifies source and target rectangles to render the specified codepoint.
Definition: character-mapping.h:34
fc_pixels
A structure holding pixel data and its dimensions.
Definition: font.h:34
fc_pixels::data
unsigned char * data
The pixel data produced after fc_cook, a 4-byte-per-pixel RGBA bitmap.
Definition: font.h:38