Skip to main content

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


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.9.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

tensorfont-0.0.9-py2.py3-none-any.whl (14.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tensorfont-0.0.9.tar.gz.

File metadata

  • Download URL: tensorfont-0.0.9.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for tensorfont-0.0.9.tar.gz
Algorithm Hash digest
SHA256 9454ba404bf7fe088901501f8ffb3d53529b50f819829db2fc49f9edb5125709
MD5 03b97aad0c757d32bd3fb70aca09148b
BLAKE2b-256 71119d6a89c75139b85c7ecfe447630c23c59992fd71272e5cd728442a2c02c6

See more details on using hashes here.

File details

Details for the file tensorfont-0.0.9-py2.py3-none-any.whl.

File metadata

  • Download URL: tensorfont-0.0.9-py2.py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for tensorfont-0.0.9-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d782898e4d5a861f6bc73aa5c4290cb4bebdf3d692b947a7098ea94908e0a589
MD5 1d1f8d4e0c433d8c202f1364dd90fe3a
BLAKE2b-256 9e50174e376d33d4c3cf4a7893efcc57e479afb4c2cadae8381dc59622cd15a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page