Turn font glyphs into numpy arrays
Project description
Tensorfont is a library to help those performing numerical analysis of font data, particular with reference to letterfitting and spacing.
Here is an example session:
>>> from tensorfont import Font >>> f = Font("../atospace/kern-dump/normal/MrsEavesOT-Bold.otf") >>> f.m_width 828.0 >>> f.baseline_ratio 0.28835063437139563 >>> f.pair_distance("A","V") -149 >>> f.pair_kerning("A","V") -73 >>> f.glyph("G").lsb 71 >>> m = f.glyph("G").as_matrix() .with_sidebearings() .crop_descender() .scale_to_height(50) >>> m.left_contour() array([25, 22, 20, 18, 16, 15, 14, 13, 12, 11, 10, 10, 9, 9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 9, 10, 10, 11, 12, 13, 13, 15, 16, 17, 19, 21]) >>> plt.imgshow(m) ; plt.show() # The letter "G" is shown
Full documentation is available at https://simoncozens.github.io/tensorfont/index.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tensorfont-0.0.2.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for tensorfont-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da64ecfc6da71eafc0798633d3695c68c4a36f72024467d2a5a1e48db6f04fec |
|
MD5 | 1819935ea4195229f1ec294f0ec0ced0 |
|
BLAKE2b-256 | c3531cc06449172de4bcd68a6a348d067d709e5c77021e0fead950465b36165d |