Skip to main content

Cubic-to-quadratic bezier curve conversion

Project description

Build Status PyPI Version Coverage

cu2qu

This library provides functions which take in UFO objects (Defcon Fonts or Robofab RFonts) and converts any cubic curves to quadratic. The most useful function is probably fonts_to_quadratic:

from defcon import Font
from cu2qu.ufo import fonts_to_quadratic
thin_font = Font('MyFont-Thin.ufo')
bold_font = Font('MyFont-Bold.ufo')
fonts_to_quadratic([thin_font, bold_font])

Interpolation compatibility is guaranteed during conversion. If it’s not needed, converting one font at a time may yield more optimized results:

for font in [thin_font, bold_font]:
    fonts_to_quadratic([font])

Some fonts may need a different error threshold than the default (0.001 em). This can also be provided by the caller:

fonts_to_quadratic([thin_font, bold_font], max_err_em=0.005)
for font in [thin_font, bold_font]:
    fonts_to_quadratic([font], max_err_em=0.001)

fonts_to_quadratic can print a string reporting the number of curves of each length. For example fonts_to_quadratic([font], dump_stats=True) may print something like:

3: 1000
4: 2000
5: 100

meaning that the font now contains 1000 curves with three points, 2000 with four points, and 100 with five. Given multiple fonts, the function will report the total counts across all fonts. You can also accumulate statistics between calls by providing your own report dictionary:

stats = {}
for font in [thin_font, bold_font]:
    fonts_to_quadratic([font], stats=stats)
# "stats" will report combined statistics for both fonts

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

cu2qu-1.3.0.zip (118.1 kB view details)

Uploaded Source

Built Distribution

cu2qu-1.3.0-py2.py3-none-any.whl (16.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cu2qu-1.3.0.zip.

File metadata

  • Download URL: cu2qu-1.3.0.zip
  • Upload date:
  • Size: 118.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cu2qu-1.3.0.zip
Algorithm Hash digest
SHA256 8744003bfe13bf93aef39af517080834bb21c169ab9f295ae58b89094d918935
MD5 573565017926a6185ece5bab8ad2f70c
BLAKE2b-256 da209ed497ab551479ca24558d4e69d60f8ae13740e733013c3e94e408b14289

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cu2qu-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 44b32e7a315e617c273219752310736bab013ed0a149ef3ced0e393abfaea8f6
MD5 f6cc74ea650be9136fc857fe4697dfe2
BLAKE2b-256 d45dd58ed3fb53deba14640abe37ac9a22beae99be34df4f39ba8939f595aa0f

See more details on using hashes here.

Provenance

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