Text Rendering

Tags: None
State: None


  • Rasterization: rendering a glyph to pixels
  • Shaping:
    • how to layout a sequence of glyphs on multiple lines
    • may not be straight-forward such as for latin languages

CoreText / CoreGraphics

Notes on Metal


  1. Create CGContext
  2. Create MTLBuffer pointing to same memory
    1. Write to MTLBuffer with CGContext
  3. Create MTLTexture out of MTLBuffer
  • FreeType / Harfbuzz
  • FreeType for rasterization
  • Harfbuzz for shaping

Create a font with Harfbuzz

#include <hb-ft.h>
FT_New_Face(ft_library, font_path, index, &face);
FT_Set_Char_Size(face, 0, 1000, 0, 0);
hb_font_t *font = hb_ft_font_create(face);