mirror of
https://github.com/phooky/Apple-410.git
synced 2024-05-28 23:41:32 +00:00
rough font extract!
This commit is contained in:
parent
51cc15f152
commit
2e5109bdbf
3667
roms/Apple410.ttf
Normal file
3667
roms/Apple410.ttf
Normal file
File diff suppressed because it is too large
Load Diff
37
roms/ff_import.py
Normal file
37
roms/ff_import.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import fontforge
|
||||||
|
import tempfile
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
font = fontforge.font()
|
||||||
|
font.fontname = "Apple410"
|
||||||
|
base = "alpha"
|
||||||
|
matcher = re.compile(r"{}_([0-9a-f][0-9a-f]).svg".format(base))
|
||||||
|
|
||||||
|
for path in os.listdir('.'):
|
||||||
|
m = matcher.match(path)
|
||||||
|
if m:
|
||||||
|
idx = int(m.group(1),16)
|
||||||
|
print "{} : {}".format(idx,path)
|
||||||
|
# fontforge can't handle % colors, so we need to hack those out. Luckily, these are the only %
|
||||||
|
# characters in the files, so...
|
||||||
|
tf = tempfile.NamedTemporaryFile(suffix='.svg')
|
||||||
|
inf = open(path)
|
||||||
|
for c in inf.read():
|
||||||
|
if c != '%':
|
||||||
|
tf.write(c)
|
||||||
|
tf.flush()
|
||||||
|
font.createChar(idx)
|
||||||
|
font[idx].importOutlines(tf.name)
|
||||||
|
tf.close()
|
||||||
|
inf.close()
|
||||||
|
|
||||||
|
print "glyph count {}".format(len(font))
|
||||||
|
#print font.createChar(0x41)
|
||||||
|
#font[0x41].importOutlines("alpha_41.svg")
|
||||||
|
|
||||||
|
font.save("Apple410.ttf")
|
||||||
|
|
|
@ -27,12 +27,13 @@ def get_char(ft,off):
|
||||||
|
|
||||||
def unpack_byte(b):
|
def unpack_byte(b):
|
||||||
"convert two 4-bit signed packed numbers to a tuple"
|
"convert two 4-bit signed packed numbers to a tuple"
|
||||||
def sign4b(x):
|
# this packing is... unusual.
|
||||||
# not... quite two's complement
|
x = b >> 4
|
||||||
if x > 8:
|
y = b % 16
|
||||||
return x - 16
|
if y > 8: # now the weird
|
||||||
return x
|
x -= 1
|
||||||
return (sign4b(b>>4), sign4b(b % 16))
|
y -= 16
|
||||||
|
return (x,y)
|
||||||
|
|
||||||
# H:W for a char is 3:2
|
# H:W for a char is 3:2
|
||||||
def unpack_coords(b,xscale=66,yscale=100,xoff=10,yoff=10):
|
def unpack_coords(b,xscale=66,yscale=100,xoff=10,yoff=10):
|
||||||
|
@ -41,10 +42,10 @@ def unpack_coords(b,xscale=66,yscale=100,xoff=10,yoff=10):
|
||||||
return (x*xscale + xoff, (8 - y)*yscale + yoff)
|
return (x*xscale + xoff, (8 - y)*yscale + yoff)
|
||||||
|
|
||||||
def build_char_file(path, ft, offset):
|
def build_char_file(path, ft, offset):
|
||||||
surf = cairo.SVGSurface(path, 1000, 1000)
|
surf = cairo.SVGSurface(path, 1000, 1220)
|
||||||
c = cairo.Context(surf)
|
c = cairo.Context(surf)
|
||||||
d = list(get_char(ft, offset))
|
d = list(get_char(ft, offset))
|
||||||
c.set_source_rgb(0, 0, 0)
|
#c.set_source_rgb(0.0, 0.0, 0.0)
|
||||||
c.set_line_width(20)
|
c.set_line_width(20)
|
||||||
c.set_line_cap(cairo.LINE_CAP_ROUND)
|
c.set_line_cap(cairo.LINE_CAP_ROUND)
|
||||||
c.set_line_join(cairo.LINE_JOIN_ROUND)
|
c.set_line_join(cairo.LINE_JOIN_ROUND)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user