Dusted off - made to work to some extent
This commit is contained in:
22
ffimport.py
22
ffimport.py
@@ -18,6 +18,7 @@ def run(path, font_name):
|
||||
font.fontname = font_name
|
||||
# noinspection SpellCheckingInspection
|
||||
font.familyname = 'Hershey'
|
||||
print(os.listdir(os.path.join(svg_folder, font_name)))
|
||||
for svg in os.listdir(os.path.join(svg_folder, font_name)):
|
||||
if svg[-4:] == '.svg':
|
||||
match = re.match(r'ascii(\d+)_l(-?[\d.]+)_r(-?[\d.]+).svg', svg)
|
||||
@@ -26,18 +27,29 @@ def run(path, font_name):
|
||||
|
||||
glyph = font.createMappedChar(character)
|
||||
# Import the outlines *before* setting the bearings. Otherwise, everything will be reset.
|
||||
glyph.importOutlines(os.path.join(svg_folder, font_name, svg))
|
||||
|
||||
print("and then?", os.path.join(svg_folder, font_name, svg))
|
||||
glyph.importOutlines(os.path.join(svg_folder, font_name, svg)) # SILENT CRASH
|
||||
|
||||
|
||||
glyph.stroke('circular', stroke_size, 'round', 'round')
|
||||
# glyph.correctDirection()
|
||||
glyph.removeOverlap()
|
||||
glyph.correctDirection()
|
||||
glyph.simplify()
|
||||
glyph.left_side_bearing = float(match.group(2))
|
||||
glyph.round()
|
||||
glyph.removeOverlap()
|
||||
|
||||
#glyph.stroke('circular', stroke_size, 'round', 'round')
|
||||
# glyph.correctDirection()
|
||||
#glyph.removeOverlap()
|
||||
#glyph.simplify()
|
||||
glyph.left_side_bearing = int(round(float(match.group(2))))
|
||||
# Compensate for the stroke with on the right side bearing
|
||||
glyph.right_side_bearing = float(match.group(3)) - stroke_size
|
||||
glyph.right_side_bearing = int(round(float(match.group(3)) - stroke_size))
|
||||
|
||||
else:
|
||||
print(f'Not a SVG file: {os.path.join(svg_folder, font_name, svg)}')
|
||||
|
||||
# Assumes ttf folder exists
|
||||
print("Done gen, writing")
|
||||
ttf_folder = os.path.join(path, 'ttf')
|
||||
font.generate(os.path.join(ttf_folder, font_name + '.ttf'))
|
||||
|
||||
Reference in New Issue
Block a user