Skip to content

Convert BDF fonts to Unicode-capable font system #128

Description

@pbalduino

Summary

Convert existing BDF font files to support Unicode codepoints and implement a Unicode-aware font rendering system.

Description

Replace the current ASCII-only font system with a Unicode-capable system that can load and render glyphs from the existing Terminus BDF font files.

Current State

  • Font system supports only 256 ASCII characters
  • Uses hardcoded glyph definitions in src/kernel/fonts.c
  • BDF Unicode font files exist in fonts/ directory but are unused

Tasks

  • Create BDF font parser to load fonts/ter-u16*.bdf files
  • Implement Unicode codepoint to glyph mapping system
  • Replace font_glyph(uint8_t ascii) with font_glyph(uint32_t codepoint)
  • Add fallback glyph handling for unsupported codepoints
  • Implement font caching for performance
  • Support multiple font sizes/styles
  • Add memory-efficient storage for large Unicode font sets

Implementation Details

Update include/kernel/fonts.h:

typedef struct {
  uint32_t codepoint;
  uint8_t width;
  uint8_t height;
  uint8_t *bitmap;
} unicode_glyph_t;

typedef struct {
  size_t glyph_count;
  unicode_glyph_t *glyphs;
  // Hash table or tree for fast codepoint lookup
} unicode_font_t;

Files to Modify

  • src/kernel/fonts.c - Font loading and glyph lookup
  • include/kernel/fonts.h - Font data structures
  • src/kernel/framebuffer.c - Update glyph rendering calls

Success Criteria

  • Can render basic Latin characters (U+0000-U+007F)
  • Can render extended Latin characters (U+0080-U+00FF)
  • Fallback glyph displays for unsupported characters
  • Performance acceptable for console rendering
  • Memory usage reasonable for embedded system

Dependencies

Priority

High - Required for Unicode text display

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions