-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (25 loc) · 903 Bytes
/
test.py
File metadata and controls
28 lines (25 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np
import matplotlib.pyplot as plt
from fontTools.ttLib import TTFont
from bitmapPen import BitmapPen
from scale import ScaledBitmap
import png
import sys
if __name__ == '__main__':
argv = sys.argv
font = TTFont(argv[1])
glyf = font['glyf']['ampersand']
glyf.getCoordinates(font['glyf'])
pen = BitmapPen(font['glyf'], glyf.xMin, glyf.yMin, glyf.xMax, glyf.yMax, 64, 64)
glyf.draw(pen, font['glyf'])
#scaled = ScaledBitmap(64,64)
#scaled.loadBitmap(pen.getBitmap())
#g = Grid(64,64,glyf.xMin, glyf.xMax, glyf.yMin, glyf.yMax)
#bz = CubicBezier((0.5,0.2),(0.8,0.4), (0.7,0.9))
#g.draw_curve(bz)
#bz = CubicBezier((0.7,0.9),(0.5,0.4), (0.3,0.9))
#g.draw_curve(bz)
png.from_array(pen.getBitmap(), 'L').save("temp/export.png")
plt.imshow(pen.getBitmap(), cmap='Greys', vmin=0, vmax=255)
plt.colorbar()
plt.show()