More notes on font rendering
This commit is contained in:
parent
155e76df5f
commit
d9dea5d122
83
notes.md
83
notes.md
|
@ -73,6 +73,87 @@ float s = ScaleForMappingEmToPixels(1) / ScaleForPixelHeight(1);
|
|||
so 's' is actually equal to (ascent - descent) / unitsPerEm.
|
||||
|
||||
Then BakeFontBitmap is called and `font->size * s` is used for the pixel_height argument.
|
||||
So BakeFontBitmap gets, for pixel_height, (ascent - descent) * font->size / unitsPerEm.
|
||||
So BakeFontBitmap gets
|
||||
|
||||
```c
|
||||
pixel_height = (ascent - descent) * font->size / unitsPerEm;
|
||||
```
|
||||
|
||||
This is equal almost equal to font->height except the 0.5, the missing linegap calculation
|
||||
and the fact that this latter is an integer instead of a float.
|
||||
|
||||
## AGG Font Engine
|
||||
|
||||
Calls
|
||||
|
||||
FT_Init_FreeType (initialize the library)
|
||||
|
||||
In load_font() method:
|
||||
FT_New_Face or FT_New_Memory_Face (use FT_Done_Face when done)
|
||||
|
||||
FT_Attach_File
|
||||
FT_Select_Charmap
|
||||
|
||||
In update_char_size() method:
|
||||
FT_Set_Char_Size or FT_Set_Pixel_Sizes
|
||||
|
||||
In prepare_glyph() method:
|
||||
FT_Get_Char_Index
|
||||
FT_Load_Glyph
|
||||
FT_Render_Glyph (if glyph_render_native_mono or native_gray8)
|
||||
|
||||
in add_kerning() method
|
||||
FT_Get_Kerning
|
||||
|
||||
FT_Done_FreeType (end with library)
|
||||
|
||||
## Freetype2's metrics related function and structs
|
||||
|
||||
FT_New_Face
|
||||
|
||||
```c
|
||||
typedef struct FT_FaceRec_
|
||||
{
|
||||
FT_Long num_faces;
|
||||
FT_Long face_index;
|
||||
|
||||
FT_Long face_flags;
|
||||
FT_Long style_flags;
|
||||
|
||||
FT_Long num_glyphs;
|
||||
|
||||
FT_String* family_name;
|
||||
FT_String* style_name;
|
||||
|
||||
FT_Int num_fixed_sizes;
|
||||
FT_Bitmap_Size* available_sizes;
|
||||
|
||||
FT_Int num_charmaps;
|
||||
FT_CharMap* charmaps;
|
||||
|
||||
FT_Generic generic;
|
||||
|
||||
/*# The following member variables (down to `underline_thickness`) */
|
||||
/*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
|
||||
/*# for bitmap fonts. */
|
||||
FT_BBox bbox;
|
||||
|
||||
FT_UShort units_per_EM;
|
||||
FT_Short ascender;
|
||||
FT_Short descender;
|
||||
FT_Short height;
|
||||
|
||||
FT_Short max_advance_width;
|
||||
FT_Short max_advance_height;
|
||||
|
||||
FT_Short underline_position;
|
||||
FT_Short underline_thickness;
|
||||
|
||||
FT_GlyphSlot glyph;
|
||||
FT_Size size;
|
||||
FT_CharMap charmap;
|
||||
|
||||
/* private part omitted. */
|
||||
|
||||
} FT_FaceRec;
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue