diff options
| author | Radomir Dopieralski <openstack@sheep.art.pl> | 2019-06-30 01:10:47 +0200 |
|---|---|---|
| committer | Radomir Dopieralski <openstack@sheep.art.pl> | 2019-06-30 01:10:47 +0200 |
| commit | 7c908b08ee3704a4784919e68b17e1a2f571fa17 (patch) | |
| tree | edbfb4b591d6f0fbca5b481721f35f829efec508 /tools/gen_display_resources.py | |
| parent | f0a112ef5d04fc17a49ad8e2d74e5e23f3c40dd5 (diff) | |
Use FONTBOUNDINGBOX for font metrics
Instead of iterating over all the glyphs and calculating the maximum
width and height, use the FONTBOUNDINGBOX to determine the size of a
tile for terminalio.
This works better with fonts such as generated by FontForge, that don't
include the empty space in the glyph bitmap itself. It also lets the
font author specify vertical spacing they want.
I only tested this with the default font and with one I generated with
FontForge.
Diffstat (limited to 'tools/gen_display_resources.py')
| -rw-r--r-- | tools/gen_display_resources.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/tools/gen_display_resources.py b/tools/gen_display_resources.py index 7b28c3105..2c674c8eb 100644 --- a/tools/gen_display_resources.py +++ b/tools/gen_display_resources.py @@ -29,7 +29,6 @@ class BitmapStub: self.rows[y] = bytes(row) f = bitmap_font.load_font(args.font, BitmapStub) -real_bb = [0, 0] # Load extra characters from the sample file. sample_characters = set() @@ -61,13 +60,11 @@ for c in all_characters: print("Font missing character:", c, ord(c)) filtered_characters = filtered_characters.replace(c, "") continue - x, y, dx, dy = g["bounds"] if g["shift"][1] != 0: raise RuntimeError("y shift") - real_bb[0] = max(real_bb[0], x - dx) - real_bb[1] = max(real_bb[1], y - dy) -tile_x, tile_y = real_bb +x, y, dx, dy = f.get_bounding_box() +tile_x, tile_y = x - dx, y - dy total_bits = tile_x * len(all_characters) total_bits += 32 - total_bits % 32 bytes_per_row = total_bits // 8 |
