diff options
Diffstat (limited to 'app/converter/cover.py')
| -rw-r--r-- | app/converter/cover.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/converter/cover.py b/app/converter/cover.py index b2d3cb5..9bf9237 100644 --- a/app/converter/cover.py +++ b/app/converter/cover.py @@ -122,6 +122,10 @@ _FONT = { _GLYPH_WIDTH = 5 _GLYPH_HEIGHT = 7 +# Any character outside the embedded font (accented letters, CJK, +# Cyrillic, ...) renders as an empty box: silently dropping it would +# blank those titles while still counting their width for centering. +_UNKNOWN_GLYPH = [0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F] _TEXT_SCALE = 6 # render each font pixel as a 6x6 block _TEXT_MARGIN = 60 # horizontal padding when wrapping _TEXT_COLOR = (255, 255, 255) @@ -194,9 +198,7 @@ def _render_line(pixels: List[List[Tuple[int, int, int]]], text: str, x0: int, y stays tinted by the gradient behind it). """ for char_index, char in enumerate(text): - glyph = _FONT.get(char) - if glyph is None: - continue + glyph = _FONT.get(char, _UNKNOWN_GLYPH) x_off = x0 + char_index * (_GLYPH_WIDTH + 1) * _TEXT_SCALE for gy, bits in enumerate(glyph): for gx in range(_GLYPH_WIDTH): |
