66applies properties, saves.
77"""
88import fontforge
9- import psMat
109import unicodedata
1110
1211font_fname = '../generated/xkcd-script-pt7.sfd'
@@ -60,40 +59,6 @@ def _expand_with_variants(font, chars):
6059 return result
6160
6261
63- # ---------------------------------------------------------------------------
64- # Advance-width overrides
65- # ---------------------------------------------------------------------------
66-
67- # f's lsb (17) leaves too much space before the stem; shift left 12 units.
68- # Width is reduced by 110 total to bring natural spacing after the crossbar
69- # into line (~90 units for fo), leaving arm clearance handled by kern rules.
70- _f = font ['f' ]
71- _f .transform (psMat .translate (- 12 , 0 ))
72- _f .width -= 110
73- font ['r' ].transform (psMat .translate (10 , 0 ))
74-
75-
76- # g's bowl (above baseline) starts ~19 units further right than other rounded
77- # letters. Shift the whole glyph left by 90 to bring bowl_lsb to ~20, matching
78- # e/n/o. Width is reduced by 30 to leave a moderate right sidebearing (~25).
79- _g = font ['g' ]
80- _g .transform (psMat .translate (- 145 , 0 ))
81- _g .width -= 30
82-
83-
84- # j
85- _j = font ['j' ]
86- _j .transform (psMat .translate (- 115 , 0 ))
87- _j .width -= 25
88-
89-
90- # r's arm extends to ~x=402 but the default advance (440) leaves too much
91- # whitespace; reduce to give a slight negative right sidebearing.
92- _r = font ['r' ]
93- _r .transform (psMat .translate (- 30 , 0 ))
94- _r .width = 385
95-
96-
9762# ---------------------------------------------------------------------------
9863# Kerning
9964# ---------------------------------------------------------------------------
@@ -133,10 +98,15 @@ def expand(chars, left_side):
13398 return expanded
13499 font .autoKern ('kern' , sep , expand (left , left_side = True ), expand (right , left_side = False ), ** kwargs )
135100
101+ a = font ['_pad_space' ].width
102+ a = max (a - 20 , 0 )
103+
104+ # autoKern looks at the outline, so even if you change the padding, it absorbs all of it.
105+ # Use `+a` when you want to link the spacing after kerning to the padding.
136106 kern (150 , ['/' , '\\ ' ], ['/' , '\\ ' ])
137- kern (60 , ['s' ], set (lower ) - {'j' , 'f' }, minKern = 50 )
107+ kern (60 + a , ['s' ], set (lower ) - {'j' , 'f' }, minKern = 50 )
138108 # x has diagonal strokes that leave visual space on its left side.
139- kern (90 , set (lower ) - {'f' }, ['x' ], minKern = 40 )
109+ kern (90 + a , set (lower ) - {'f' }, ['x' ], minKern = 40 )
140110 # F/E are separated from T/J so they can use a tighter target gap.
141111 kern (130 , ['F' ], set (all_chars ) - {'f' , 'j' })
142112 kern (140 , ['E' ], ['V' , 'W' , 'Y' ])
@@ -149,6 +119,7 @@ def expand(chars, left_side):
149119
150120
151121autokern (font )
122+ font .removeGlyph (font ['_pad_space' ])
152123
153124
154125# ---------------------------------------------------------------------------
0 commit comments