menios icon indicating copy to clipboard operation
menios copied to clipboard

Implement Unicode text rendering in framebuffer

Open pbalduino opened this issue 4 months ago • 0 comments

Summary

Update the framebuffer text rendering system to properly handle UTF-8 encoded Unicode text.

Description

Modify the framebuffer console to decode UTF-8 byte sequences and render Unicode characters using the new Unicode-capable font system.

Current State

  • fb_putchar() treats all input as single-byte ASCII
  • Text rendering assumes 1 byte = 1 character
  • Console buffer stores only ASCII characters

Tasks

  • [ ] Update fb_putchar() to handle UTF-8 byte sequences
  • [ ] Implement UTF-8 state machine for multi-byte character assembly
  • [ ] Update console buffer to store Unicode codepoints
  • [ ] Handle variable-width character rendering
  • [ ] Update cursor positioning for Unicode text
  • [ ] Add support for combining characters (optional)
  • [ ] Handle right-to-left text (optional, future enhancement)

Implementation Details

Update src/kernel/framebuffer.c:

  • Modify console_cell_t to store uint32_t codepoint instead of char ch
  • Add UTF-8 decoder state to handle incomplete sequences
  • Update write_char() to call new Unicode font system
  • Handle width calculation for characters (most are single-width)

Key Functions to Update

  • fb_putchar(int c) - Add UTF-8 decoding
  • write_char(int c) - Change to write_codepoint(uint32_t cp)
  • draw_cell() - Use Unicode glyph lookup
  • Console buffer management functions

Success Criteria

  • [ ] Can display UTF-8 encoded text correctly
  • [ ] Handles incomplete UTF-8 sequences gracefully
  • [ ] Cursor positioning works correctly with Unicode text
  • [ ] Performance acceptable for interactive use
  • [ ] Backward compatible with existing ASCII text

Dependencies

  • Depends on: #127 (UTF-8 utilities)
  • Depends on: #128 (Unicode font system)

Priority

High - Core Unicode rendering functionality

pbalduino avatar Sep 29 '25 12:09 pbalduino