Skip to content

Fix symbol font encoding for dingbat fonts (Webdings, Wingdings)#523

Merged
Core447 merged 1 commit into
StreamController:mainfrom
designgears:symbol-fonts-workaround
Mar 5, 2026
Merged

Fix symbol font encoding for dingbat fonts (Webdings, Wingdings)#523
Core447 merged 1 commit into
StreamController:mainfrom
designgears:symbol-fonts-workaround

Conversation

@designgears

Copy link
Copy Markdown
Contributor

Description

Fixes issue #474 where symbol fonts like Webdings and Wingdings display rectangles instead of the correct symbols.

Root Cause

  1. Matplotlib exclusion: Matplotlib intentionally excludes symbol fonts from its font list
  2. Encoding mismatch: Symbol fonts use Microsoft Symbol encoding (platformID=3, platEncID=0) but PIL defaults to Unicode encoding

Solution

  1. Font discovery: Use fc-match to find symbol font paths that matplotlib skips
  2. Manual registration: Use matplotlib.font_manager.fontManager.addfont() to add symbol fonts to matplotlib's font list
  3. Proper encoding: Detect symbol fonts via cmap table and use encoding="symb" when loading with PIL

Changes

  • Added _ensure_symbol_fonts() function to dynamically find and register symbol fonts
  • Added _is_symbol_font() with @lru_cache to detect symbol encoding efficiently
  • Modified get_font_path() to ensure symbol fonts are available before lookup
  • Modified get_font() to use proper encoding for symbol fonts

Testing

  • Webdings now renders correct symbols instead of rectangles
  • Wingdings now renders correct symbols instead of rectangles
  • Regular fonts continue to work normally
  • Performance impact minimal due to caching

Files Changed

  • src/backend/DeckManagement/Subclasses/KeyLabel.py
image

- Add fontTools dependency for font encoding detection
- Implement cached symbol font detection using cmap table inspection
- Use fc-match to locate and register symbol fonts (Webdings, Wingdings) with matplotlib at startup
- Set appropriate encoding ("symb" vs "unic") when loading fonts in PIL to ensure correct character rendering for symbol fonts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants