GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
An in-memory font description. More...
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | gp_glyph |
A data describing single Glyph. More... | |
struct | gp_glyphs |
An unicode glyphs block. More... | |
struct | gp_font_face_ops |
Font loader callback. More... | |
struct | gp_font_face |
A font face. More... | |
struct | gp_font_family |
A font family. More... | |
Typedefs | |
typedef struct gp_glyph | gp_glyph |
A data describing single Glyph. | |
typedef enum gp_font_bitmap_format | gp_font_bitmap_format |
Glyph bitmap data format. | |
typedef enum gp_font_style | gp_font_style |
Font style bitflags. | |
typedef struct gp_glyphs | gp_glyphs |
An unicode glyphs block. | |
typedef struct gp_font_face_ops | gp_font_face_ops |
Font loader callback. | |
typedef enum gp_font_ucode_block | gp_font_ucode_block |
Unicode block ids. | |
typedef struct gp_font_family | gp_font_family |
A font family. | |
Enumerations | |
enum | gp_font_bitmap_format { GP_FONT_BITMAP_1BPP , GP_FONT_BITMAP_8BPP } |
Glyph bitmap data format. More... | |
enum | gp_font_style { GP_FONT_REGULAR = 0x00 , GP_FONT_MONO = 0x01 , GP_FONT_BOLD = 0x02 , GP_FONT_ITALIC = 0x04 , GP_FONT_STYLE_MASK = 0x0f , GP_FONT_FALLBACK = 0x10 } |
Font style bitflags. More... | |
enum | gp_font_ucode_block { GP_UCODE_LATIN_BASIC = 0x0001 , GP_UCODE_LATIN_SUP = 0x0002 , GP_UCODE_LATIN_EXT_A = 0x0004 , GP_UCODE_GREEK = 0x0008 , GP_UCODE_CYRILIC = 0x0010 , GP_UCODE_HIRAGANA = 0x0020 , GP_UCODE_KATAKANA = 0x0030 } |
Unicode block ids. More... | |
Functions | |
static unsigned int | gp_font_height (const gp_font_face *font) |
Returns font height. | |
static unsigned int | gp_font_ascent (const gp_font_face *font) |
Returns font ascent. | |
static unsigned int | gp_font_descent (const gp_font_face *font) |
Returns font ascent. | |
static unsigned int | gp_font_max_width (const gp_font_face *font) |
Returns maximal glyph width. | |
static unsigned int | gp_font_max_advance_x (const gp_font_face *font) |
Returns maximal glyph advance. | |
static unsigned int | gp_font_avg_advance_x (const gp_font_face *font) |
Returns average glyph advance. | |
static const char * | gp_font_family_name (const gp_font_face *font) |
Returns font family name. | |
const char * | gp_font_style_name (gp_font_style style) |
Returns font style name. | |
gp_glyph * | gp_glyph_get (const gp_font_face *font, uint32_t ch) |
Looks up a glyph in a font. | |
gp_font_face * | gp_font_face_load (const char *path, uint32_t width, uint32_t height) |
Load a font face from a file. | |
gp_font_face * | gp_font_face_fc_load (const char *name, uint32_t width, uint32_t height) |
Uses fontconfig to lookup font file. | |
void | gp_font_face_free (gp_font_face *self) |
Frees the font face memory. | |
typedef enum gp_font_bitmap_format gp_font_bitmap_format |
Glyph bitmap data format.
Defines depth for the gp_glyph::bitmap.
typedef struct gp_font_face_ops gp_font_face_ops |
Font loader callback.
When TrueType font is loaded the ASCII part is pre-rendered into the memory, any other characters are loaded on-demand when needed.
typedef struct gp_font_family gp_font_family |
A font family.
Font family is a group of font faces of the same family and size but different style i.e. monospace, bold, italic...
The fonts array is NULL terminated.
typedef enum gp_font_style gp_font_style |
Font style bitflags.
The monospace and regular font flags can be bitwise combined with bold and italic.
typedef enum gp_font_ucode_block gp_font_ucode_block |
Unicode block ids.
All fonts must include LATIN_BASIC and it has to be the first table in the font.
A data describing single Glyph.
Note that glyph do not necessarily correspond to one character (for example ligature is a glyph but corresponds to at least two characters).
The glyphs are rendered to horizontal baseline, vertical rendering is not supported.
The structure could contain glyphs of different BPP and information about the bitmap format is stored in the font structure. The bitmap lines are byte aligned.
Glyph bitmap data format.
Defines depth for the gp_glyph::bitmap.
Enumerator | |
---|---|
GP_FONT_BITMAP_1BPP | 1 bit per pixel. |
GP_FONT_BITMAP_8BPP | 8 bit per pixel. |
enum gp_font_style |
Font style bitflags.
The monospace and regular font flags can be bitwise combined with bold and italic.
enum gp_font_ucode_block |
Unicode block ids.
All fonts must include LATIN_BASIC and it has to be the first table in the font.
|
inlinestatic |
Returns font ascent.
font | A font face. |
Definition at line 301 of file gp_font.h.
References gp_font_face::ascent.
|
inlinestatic |
Returns average glyph advance.
For monospace fonts all advances are the same.
font | A font face. |
Definition at line 359 of file gp_font.h.
References gp_font_face::avg_glyph_advance, and gp_font_face::max_glyph_advance.
|
inlinestatic |
Returns font ascent.
font | A font face. |
Definition at line 317 of file gp_font.h.
References gp_font_face::descent.
gp_font_face * gp_font_face_fc_load | ( | const char * | name, |
uint32_t | width, | ||
uint32_t | height | ||
) |
Uses fontconfig to lookup font file.
Looks up a font path given a font name and loads it with gp_font_face_load().
name | A font name such as "Arial". |
width | A width passed to the gp_font_face_load(). |
height | A height passed to the gp_font_face_load(). |
void gp_font_face_free | ( | gp_font_face * | self | ) |
Frees the font face memory.
Frees the font face memory, closes FreeType hanles, etc.
self | A font face. |
gp_font_face * gp_font_face_load | ( | const char * | path, |
uint32_t | width, | ||
uint32_t | height | ||
) |
Load a font face from a file.
Loads a font using FreeType library. Only one of the width and height should be non-zero, to keep the correct aspect ratio for the glyph.
path | A path to a font file. |
width | A requested width. |
height | A requested height. |
|
inlinestatic |
Returns font family name.
font | A font face. |
Definition at line 375 of file gp_font.h.
References gp_font_face::family_name.
|
inlinestatic |
Returns font height.
font | A font face. |
Definition at line 285 of file gp_font.h.
References gp_font_face::ascent, and gp_font_face::descent.
|
inlinestatic |
Returns maximal glyph advance.
For monospace fonts all advances are the same.
font | A font face. |
Definition at line 345 of file gp_font.h.
References gp_font_face::max_glyph_advance.
|
inlinestatic |
Returns maximal glyph width.
For monospace fonts all letter widths are the same.
font | A font face. |
Definition at line 331 of file gp_font.h.
References gp_font_face::max_glyph_width.
const char * gp_font_style_name | ( | gp_font_style | style | ) |
Returns font style name.
Returns font style name for a bitwise combination of the GP_FONT_STYLE_MASK bits.
style | A font style. |
gp_glyph * gp_glyph_get | ( | const gp_font_face * | font, |
uint32_t | ch | ||
) |
Looks up a glyph in a font.
font | A font face. |
ch | An unicode glyph. |