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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file tensorfont-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: tensorfont-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0943465c7f2dbe6a2542e3864a96f9ffbe46ae49d540b67e44bf7142f4b11b1 |
|
MD5 | b50159fe81e9deb9399c338cdfe7ffab |
|
BLAKE2b-256 | fdbbfac6ab2ebba1dd3c7a057398d6c55b7f56cf58a6e42b828a09bd158b1870 |