ChevalierJoseph commited on
Commit
99a9027
·
verified ·
1 Parent(s): 196b279

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -12,9 +12,6 @@ import glob
12
  from fontmake.font_project import FontProject
13
  from defcon import Font, Glyph
14
  from fontTools.pens.svgPathPen import SVGPathPen
15
- from fontTools.ttLib import TTFont
16
- from fontTools.ttLib.tables import cmap, hmtx, maxp, name, OS_2, post, hhea
17
- from fontTools.ttLib.sfnt import woff2
18
 
19
  # ------------------------
20
  # MODELE
@@ -97,10 +94,12 @@ def build_ufo_from_glyphs(glyphs):
97
  except Exception as e:
98
  print(f"Error injecting SVG for {letter}: {e}")
99
  font.insertGlyph(glyph)
 
100
  return font
101
 
102
  def save_otf_font(glyphs, font_name="TipTopType-Regular.otf"):
103
  if not glyphs:
 
104
  return None
105
  with tempfile.TemporaryDirectory() as tmpdir:
106
  ufo_path = os.path.join(tmpdir, "font.ufo")
@@ -112,6 +111,7 @@ def save_otf_font(glyphs, font_name="TipTopType-Regular.otf"):
112
  project = FontProject()
113
  try:
114
  project.run_from_ufos([ufo_path], output=["otf"], output_dir=output_dir)
 
115
  except Exception as e:
116
  print(f"Error running fontmake: {e}")
117
  return None
@@ -120,8 +120,10 @@ def save_otf_font(glyphs, font_name="TipTopType-Regular.otf"):
120
  print("No OTF files generated by fontmake.")
121
  return None
122
  generated_path = otf_files[0]
 
123
  final_path = os.path.join(tempfile.gettempdir(), font_name)
124
  os.replace(generated_path, final_path)
 
125
  return final_path
126
 
127
  # ------------------------
 
12
  from fontmake.font_project import FontProject
13
  from defcon import Font, Glyph
14
  from fontTools.pens.svgPathPen import SVGPathPen
 
 
 
15
 
16
  # ------------------------
17
  # MODELE
 
94
  except Exception as e:
95
  print(f"Error injecting SVG for {letter}: {e}")
96
  font.insertGlyph(glyph)
97
+ print(f"Total glyphs in font: {len(font)}")
98
  return font
99
 
100
  def save_otf_font(glyphs, font_name="TipTopType-Regular.otf"):
101
  if not glyphs:
102
+ print("No glyphs provided to generate OTF font.")
103
  return None
104
  with tempfile.TemporaryDirectory() as tmpdir:
105
  ufo_path = os.path.join(tmpdir, "font.ufo")
 
111
  project = FontProject()
112
  try:
113
  project.run_from_ufos([ufo_path], output=["otf"], output_dir=output_dir)
114
+ print("Fontmake ran successfully.")
115
  except Exception as e:
116
  print(f"Error running fontmake: {e}")
117
  return None
 
120
  print("No OTF files generated by fontmake.")
121
  return None
122
  generated_path = otf_files[0]
123
+ print(f"OTF file generated at: {generated_path}")
124
  final_path = os.path.join(tempfile.gettempdir(), font_name)
125
  os.replace(generated_path, final_path)
126
+ print(f"OTF file moved to: {final_path}")
127
  return final_path
128
 
129
  # ------------------------