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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tensorfont-0.2.0-py2.py3-none-any.whl (11.9 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: tensorfont-0.2.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for tensorfont-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f3e94cf9b1cbfa046d11e3e3fd5f70fd52a95f0b12775ea7369ef64aff70b95c
MD5 1bb36e3430da870704160a5ab3236f22
BLAKE2b-256 ecb64a68d596bde5575ef2d73557d1f593dc4d649ea9e9b569a7370ef2a2abba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tensorfont-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for tensorfont-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 910ab0a873f0be1215bb4a43a098cc6b5df81e8541b75ef1f6765424b93c6094
MD5 81bd2cd939507ec77bc658c9f272b2a6
BLAKE2b-256 f2106a63424b70b24738eef45fb2e2c2925d92437dcdc8dbc45467abf034cb01

See more details on using hashes here.

Supported by

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