ws-arch2: font/fon (Windows FNT 2 / 3, NE and PE .fon resources, several strikes; read) with FontForge-made fixtures vs FreeType
This commit is contained in:
1 parent
19f486031d
commit
7e792a6ae8
7 files changed
+375
-5
No files matched your search
@@ -11,7 +11,12 @@ for f in req["fonts"]:
|
||||
if face.num_fixed_sizes:
|
||||
face.select_size(0)
|
||||
glyphs = []
|
||||
unicode = any(cm.encoding == freetype.FT_ENCODING_UNICODE for cm in face.charmaps)
|
||||
if not unicode and face.charmaps:
|
||||
face.set_charmap(face.charmaps[0]) # Windows FNT: byte codes (compared for ASCII only)
|
||||
for cp in f["chars"]:
|
||||
if not unicode and cp >= 128:
|
||||
continue
|
||||
gi = face.get_char_index(cp)
|
||||
if gi == 0:
|
||||
continue
|
||||
@@ -28,7 +33,7 @@ for f in req["fonts"]:
|
||||
glyphs.append({"cp": cp, "width": w, "height": h, "left": g.bitmap_left, "top": g.bitmap_top,
|
||||
"advance": g.advance.x >> 6, "pixels": px.hex()})
|
||||
m = face.size
|
||||
out.append({"glyphs": glyphs, "ascent": m.ascender >> 6, "descent": -(m.descender >> 6), "height": m.height >> 6,
|
||||
out.append({"unicode": unicode, "glyphs": glyphs, "ascent": m.ascender >> 6, "descent": -(m.descender >> 6), "height": m.height >> 6,
|
||||
"family": (face.family_name or b"").decode("latin-1"), "style": (face.style_name or b"").decode("latin-1"),
|
||||
"numGlyphs": face.num_glyphs})
|
||||
print(json.dumps(out))
|
||||
Reference in new issue
Block a user