Skip to content

Commit

Permalink
Boxdrawing: Overhaul symbol font
Browse files Browse the repository at this point in the history
[why]
All the glyphs have overlap (negative bearings). That in itself is ok,
altough it (the glyph width for example) is not consistent for all
subsets.

The overlaps can interact strangely with the overlap given by the
font-patcher script.

[how]
It seems better to remove the negative bearings.
Also some glyph width are corrected (unified).
The font is then stored uncompressed.

[note]
The script used to modify the font:

import fontforge, psMat

font = fontforge.open('src/glyphs/extraglyphs_orig.sfd')
font.encoding = 'UnicodeFull'

def adjust(f, rang, left, width):
    for c in rang:
        g = f[c]
        if c in range(0x2599, 0x259f + 1):
            plus = 0
            g.transform(psMat.scale(1233/1234, 1))
        if c == 0x259D or c == 0x2595:
            g.width = width
            g.right_side_bearing = 0
        else:
            g.left_side_bearing = int(g.left_side_bearing + left)
            g.width = width
        print('{:X} {} {} {} {}'.format(c, g.boundingBox(), g.left_side_bearing, g.width, g.right_side_bearing))

adjust(font,
    [*range(0x2500, 0x2570 + 1), *range(0x2574, 0x257f + 1)],
    20, 1233 + 40)
adjust(font,
    range(0x2571, 0x2573 + 1),
    87, 1280+127)
adjust(font,
    range(0x2580, 0x259f + 1),
    0, 1233)

font.generate('TEST.sfd')
font.generate('TEST.ttf')

Signed-off-by: Fini Jastrow <[email protected]>
  • Loading branch information
Finii committed Nov 15, 2024
1 parent a103502 commit 51a8edc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,7 @@ class font_patcher:
BOX_SCALE_LIST = {'ShiftMode': 'xy', 'ScaleGroups': [
[*range(0x2500, 0x2570 + 1), *range(0x2574, 0x257f + 1)], # box drawing
range(0x2571, 0x2573 + 1), # diagonals
[*range(0x2580, 0x2590 + 1), 0x2594, 0x2595], # blocks
range(0x2591, 0x2593 + 1), # greys
range(0x2594, 0x259f + 1), # quards (Note: quard 2597 in Hack is wrong, scales like block!)
range(0x2580, 0x259f + 1), # blocks
]}
CODI_SCALE_LIST = {'ShiftMode': 'xy', 'ScaleGroups': [
[0xea61, 0xeb13], # lightbulb
Expand Down
Binary file modified src/glyphs/extraglyphs.sfd
Binary file not shown.

0 comments on commit 51a8edc

Please sign in to comment.