Skip to main content

Work out how far apart things should be (very quickly)

Project description

Kern determiner

Work out how far apart things should be (very quickly)

kerndeterminer is a Rust-based library for determining a kern value between two glyphs of a font source file.

(Don't use it for Latin kerning; it won't work. But it works fine for many other scripts)

Given a font, two glyphs, and a target distance (and a few other parameters), kerndeterminer will return the kern value which places the contours of the two glyphs the given distance apart at their closest point. The graphic below explains the main parameters and the effect of kerndeterminer:

parameters.png

How to use

First, create a KernDeterminer object. This loads the font, since you'll probably be making quite a few calls to determine_kern and won't want to load the font each time:

from kerndeterminer import KernDeterminer

kerner = KernDeterminer("MyFont.glyphs")

The font source can be any source loadable by the Rust version of Babelfont (currently Glyphs version 3 files, UFO, and Designspace files).

Next, call the determine_kern method on that object:

kern = kerner.determine_kern(
    "JIMi10",  # Left glyph
    "REu1",    # Right glyph
    "Regular", # Master name
    120,       # Target distance
    200,       # Height
    0.8,       # Max tuck
)

This will return the optimal kerning value for that pair at the given parameters. Note:

  • The height parameter is used to translate the left glyph vertically befor kerning. This is used in Arabic fonts with cursive attachment.
  • The max_tuck parameter is a ratio of the left glyph's width which forms an upper limit on the kerning value. For example, if max_tuck is 0.5, the leftmost point on the right glyph can only be placed so that it is 50% of the way underneath the left glyph:

maxtuck.png

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

kerndeterminer-0.0.1.tar.gz (199.2 kB view hashes)

Uploaded Source

Built Distributions

kerndeterminer-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

kerndeterminer-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

kerndeterminer-0.0.1-cp310-cp310-macosx_11_0_arm64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

kerndeterminer-0.0.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.9 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

kerndeterminer-0.0.1-cp310-cp310-macosx_10_7_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

kerndeterminer-0.0.1-cp39-none-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

kerndeterminer-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

kerndeterminer-0.0.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.9 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

kerndeterminer-0.0.1-cp39-cp39-macosx_10_7_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

kerndeterminer-0.0.1-cp38-none-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

kerndeterminer-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

kerndeterminer-0.0.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.9 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

kerndeterminer-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

kerndeterminer-0.0.1-cp37-none-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.7 Windows x86-64

kerndeterminer-0.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

kerndeterminer-0.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

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