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

Uploaded Source

Built Distribution

tensorfont-0.0.4-py2.py3-none-any.whl (9.7 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: tensorfont-0.0.4.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/18.5 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.10

File hashes

Hashes for tensorfont-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b4c97ebbec69344526fea55c8137f88bbb6f07651f78a25b5298d89923eb9ac9
MD5 34ffe8cb2925268d9683457d723de9e9
BLAKE2b-256 10efcf7654d91a5a6f5ffddcf0e72e0c0654bfcc80bad03c506c0ce878ac6e4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tensorfont-0.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/18.5 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.10

File hashes

Hashes for tensorfont-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9a249d3ee555f5ea88ec4e06f0c2a240c35510579e4a52e993ba37d2fe6db84e
MD5 2db8577cc1fea8cc7e2944b74b4d9b00
BLAKE2b-256 ac7b90c0ecba66d22a67acb695d9328b55f65f0612565f9b22fcb70f0c9bbda3

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