Fonts: anti-aliasing flag, overhanging glyphs, Font Creator byte 18

The Font Creator's anti-aliased fonts are 1-bit glyphs with header flag 0x1E (the simulator draws
them with two colours). Map bytes 3/4 are extra columns left/right of the advance width; glyphs
are drawn starting 'left' px early. Editor-generated fonts now round-trip byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-16 00:42:03 +01:00
1 parent 6616b47cb4
commit 55c2f9d6b6
6 files changed
+49 -12

No files matched your search

+10
View File
@@ -95,6 +95,16 @@ class Format4(unittest.TestCase):
self.assertEqual(img.getpixel((1, 0))[3], 226) # 227 * 127 // 255 = 113 -> 226
self.assertEqual(img.getpixel((2, 0))[3], 2)
def test_overhang_columns(self):
# Font Creator fonts: map bytes 3/4 = extra columns left/right of the advance width
rows = [[1, 0, 0, 1, 1]] * 2
g = fonts.Glyph(ord("j"), 4, rows, bytes([1, 0]))
f = fonts.Font("t", 4, 2, 1, 0x6A, 0x6A, [g])
back = fonts.Font.parse(f.pack())
self.assertEqual((back.glyphs[0].width, back.glyphs[0].data_width, back.glyphs[0].left), (4, 5, 1))
self.assertEqual(back.glyphs[0].pixels, rows)
self.assertFalse(back.antialias)
@unittest.skipUnless(HAVE_PIL, "needs Pillow")
def test_font_follows_project_direction(self):
# an Intelligent landscape project (0 degrees): glyphs row by row, header byte 3 = 0x0A,