Font System Overview
The font library consists of several components:- Font Library: Manages font resources and rendering
- Font Renderer: Performs glyph rasterization
- Font Sets: Collections of fonts for different character sets
- Glyphs: Individual character bitmaps
Initialization
Initialize Font System
Set up the font library:The
fontConfig structure from font/font.h:36-46 contains:Opening Fonts
You can open fonts from system font sets or from files.System Fonts
Font Types
Common font types fromfont/fontset.h:
Custom Font Files
Load fonts from TTF files:Font from Memory
Load a font from memory:Configuring Font Size
Set the font size before rendering:Point Size
Pixel Size
DPI Resolution
Set resolution for point-to-pixel conversion:Rendering Text
Creating a Render Surface
Define where glyphs will be rendered:Rendering a Character
Render a single character glyph:Rendering a String
Render multiple characters:Glyph Metrics
ThefontGlyphMetrics structure provides glyph dimensions:
Getting Metrics Without Rendering
Measuring Text Width
Layout Information
Get font layout properties:Horizontal Layout
Vertical Layout
Kerning
Kerning adjusts spacing between specific character pairs:Rendering with Kerning
Font Effects
Apply weight and slant effects:Weight (Bold)
Slant (Italic)
Advanced Rendering
Generating Glyph Outlines
Get vector outline data:Custom Glyph Rendering
Render with custom style:Complete Example
Integrating with RSX
To display font-rendered text on screen:Memory Management
Cleanup when done:API Reference
fontInit()
fontInit()
Initialize the font system.
fontOpenFontFile()
fontOpenFontFile()
Open a font from file.
fontRenderCharGlyphImage()
fontRenderCharGlyphImage()
Render a character glyph.
fontGetCharGlyphMetrics()
fontGetCharGlyphMetrics()
Get glyph metrics without rendering.
fontSetScalePixel()
fontSetScalePixel()
Set font size in pixels.