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

Installation

You can install/upgrade cu2qu using pip, like any other Python package.

$ pip install --upgrade cu2qu

This will download the latest stable version available from the Python Package Index (PyPI).

If you wish to modify the sources in-place, you can clone the git repository from Github and install in --editable (or -e) mode:

$ git clone https://github.com/googlei18n/cu2qu
$ cd cu2qu
$ pip install --editable .

Optionally, you can build an optimized version of cu2qu which uses Cython to compile Python to C. The extension module thus created is more than twice as fast than its pure-Python equivalent.

When installing cu2qu from PyPI using pip, as long as you have a C compiler available, the cu2qu setup script will automatically attempt to build a C/Python extension module. If the compilation fails for any reasons, an error is printed and cu2qu will be installed as pure-Python, without the optimized extension.

If you have cloned the git repository, the C source files are not present and need to be regenerated. To do that, you need to install the latest Cython (as usual, pip install -U cython), and then use the global option --with-cython when invoking the setup.py script. You can also export a CU2QU_WITH_CYTHON=1 environment variable if you prefer.

For example, to build the cu2qu extension module in-place (i.e. in the same source directory):

$ python setup.py --with-cython build_ext --inplace

You can also pass --global-option when installing with pip from a local source checkout, like so:

$ pip install --global-option="--with-cython" -e .

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.6.5.zip (217.4 kB view details)

Uploaded Source

Built Distributions

cu2qu-1.6.5-cp37-cp37m-win_amd64.whl (168.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

cu2qu-1.6.5-cp37-cp37m-win32.whl (159.6 kB view details)

Uploaded CPython 3.7m Windows x86

cu2qu-1.6.5-cp37-cp37m-manylinux1_x86_64.whl (180.2 kB view details)

Uploaded CPython 3.7m

cu2qu-1.6.5-cp37-cp37m-manylinux1_i686.whl (170.9 kB view details)

Uploaded CPython 3.7m

cu2qu-1.6.5-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (247.7 kB view details)

Uploaded CPython 3.7m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

cu2qu-1.6.5-cp36-cp36m-win_amd64.whl (168.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

cu2qu-1.6.5-cp36-cp36m-win32.whl (159.7 kB view details)

Uploaded CPython 3.6m Windows x86

cu2qu-1.6.5-cp36-cp36m-manylinux1_x86_64.whl (180.5 kB view details)

Uploaded CPython 3.6m

cu2qu-1.6.5-cp36-cp36m-manylinux1_i686.whl (171.3 kB view details)

Uploaded CPython 3.6m

cu2qu-1.6.5-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (250.3 kB view details)

Uploaded CPython 3.6m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

cu2qu-1.6.5-cp27-cp27mu-manylinux1_x86_64.whl (177.0 kB view details)

Uploaded CPython 2.7mu

cu2qu-1.6.5-cp27-cp27mu-manylinux1_i686.whl (168.0 kB view details)

Uploaded CPython 2.7mu

cu2qu-1.6.5-cp27-cp27m-win_amd64.whl (166.5 kB view details)

Uploaded CPython 2.7m Windows x86-64

cu2qu-1.6.5-cp27-cp27m-win32.whl (157.8 kB view details)

Uploaded CPython 2.7m Windows x86

cu2qu-1.6.5-cp27-cp27m-manylinux1_x86_64.whl (177.0 kB view details)

Uploaded CPython 2.7m

cu2qu-1.6.5-cp27-cp27m-manylinux1_i686.whl (168.0 kB view details)

Uploaded CPython 2.7m

cu2qu-1.6.5-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (244.4 kB view details)

Uploaded CPython 2.7m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

File details

Details for the file cu2qu-1.6.5.zip.

File metadata

  • Download URL: cu2qu-1.6.5.zip
  • Upload date:
  • Size: 217.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for cu2qu-1.6.5.zip
Algorithm Hash digest
SHA256 b3b4a0d80798489906ca503c4a7a749e0a360670aa2f10f21dd01682e37b8293
MD5 083bc4e78c46d36b1cb9bf3ddad6f8ae
BLAKE2b-256 aef581b7f453c51574ea6563df5dde4c952077cb51f8d0dffffc71ff566510d2

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 168.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for cu2qu-1.6.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 309d40e11702034f3c6770db20be11712a26d2e2911e436ac1ecb1769f3024d6
MD5 f354fc5eb6a66f5ee94650a175c1f066
BLAKE2b-256 84cbfa98779b7336637445906048e03cf9984c4971956b2357e65faeed3ce72d

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp37-cp37m-win32.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 159.6 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for cu2qu-1.6.5-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 c9197aa2471112c2a7c87c8b509d81ca0daaadbe77a73ba6e0e9a72be3f58f20
MD5 7772b63769e2a893c92039ecae276bed
BLAKE2b-256 e00a153551096cea4065d32ebb8ab432da3cfaca5438e8f2a20c5b737343eb87

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 180.2 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 77fa964432afbc7501d60246b87a82de2cf99711eabb60121ce14dcf99f300f9
MD5 4285a7c7618931b6d2a2edbe4b1e3408
BLAKE2b-256 45d364fabc3a9e06a3b27414897fd164f12d29ff8716ddb92042269c2de04513

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 170.9 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ffc205cc5895c8a39563c63dd9b215345014aff2877155e9a33ee48408dbc352
MD5 dcf8e6b59174636ef5164c3f06a1b72f
BLAKE2b-256 8d0b69008d47ed25db4a5d8e4a93f2e1f6caad7a12802f23ddde1a3d0ea5350f

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for cu2qu-1.6.5-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 4b3bc12761c6ac5cfa3cc95babde8cbec5cd0041bc311a33f403efd7765d8cad
MD5 83c9d739748e79bc9427a69d051b7edc
BLAKE2b-256 6b5d40622c77d23aae3d3514bde7f987e9e427167bd135b01e805851e55a6a8f

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 168.8 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cu2qu-1.6.5-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 92e8db2338bde72df830556afb5d33cbd3c052c197b3262856646ff2308a2d0e
MD5 0ea72819a11d18299a296780684fc411
BLAKE2b-256 5b63483bed59188d92851fa5e45c9d210c1656abf2a6783fab75b5f013ba497d

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp36-cp36m-win32.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 159.7 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cu2qu-1.6.5-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 f68bfc3c75dfa77dce9813671c86fe1bda2ed0e732dd5818566193097f038e74
MD5 c2365566a39ba1bdfc410e1d85c06f3c
BLAKE2b-256 e490166690340c2c9ec7587b4fb53fa09a41fcb3c75da2040c7db819dce37830

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 180.5 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f3050119434c15cf47896fc50fd9ff2f46f18db3ada31fd8a9c996f456879c24
MD5 4ac81bb7428dd17e0db29d225614797b
BLAKE2b-256 27557b1703ea83bdac642dbfc8113b485a96ca1627c013745884ecc49ade9531

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 171.3 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 01a70624163b1a73792ef0f585b614e71e5c4885d06f545aebae85202f71ba62
MD5 9bf0c4a39c432e626ef7433072eff02b
BLAKE2b-256 94819e79c71580d91d67a46e95aa8643ec4df3535957f82b8c792d49c8feb363

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for cu2qu-1.6.5-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 d6727edac77b2d8d3e56b04fe3237c089c2b151db03d6ee777cbb163c52c1c0a
MD5 f647d7337a8bfac41505896a415b8914
BLAKE2b-256 cd57112e1af07fbf01b4e838cb5afac797048de30d4cf36586e945554abf996d

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 177.0 kB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0ff0161a4dbc4d84d1d38a17647332d304fbbb0f4536677ce83257d5921ad3fd
MD5 d7c0a37acf96235fb0eca23f3f1cb53c
BLAKE2b-256 f2936087c47bde2dff80e41520eb6a0e6f8b23556a25a5e2fa7e2fd7fcc589ba

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp27-cp27mu-manylinux1_i686.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp27-cp27mu-manylinux1_i686.whl
  • Upload date:
  • Size: 168.0 kB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 f10cd6088b7ee83b1a8f7eca886f4355e2152b47432a8e4e7b05eb6390cc7db4
MD5 fefba5f670aaf651b5f37bb666656f72
BLAKE2b-256 a6113864af7beb48a67969cba1d84c821620f3c27378d84e6ad34f52281a7248

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 166.5 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cu2qu-1.6.5-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 1ee2503516892af930b96fdc1176151314387a015b6af897bd6fa456084260cc
MD5 2906333032c29fe33ce9ac4d11ea3fae
BLAKE2b-256 cc16b4821329ee2c30901c6721cdf3e08d7254b076cd762e35e3c5f287471ab5

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp27-cp27m-win32.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 157.8 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cu2qu-1.6.5-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 321b62d398c6c39507acc223315b845a54c255ae7c4190289e2584a655b5e160
MD5 1171fa97a6f15cf032c4dbaf12b3500b
BLAKE2b-256 8012143b00bbab1e2907bd622ee96d77db4b2183e0249dbb3943bd91ad03cfb0

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 177.0 kB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6bf3dbd5daa5c3ec5e1d6efb1eed36ed2563304398d2100424b673de9f64fd79
MD5 e5ef754f5f49acd20e3672a5b0aeaf7f
BLAKE2b-256 d8963443eba568dd16a9c21292caf55d8a24b0ad979255c1e5442836a70b0451

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp27-cp27m-manylinux1_i686.whl.

File metadata

  • Download URL: cu2qu-1.6.5-cp27-cp27m-manylinux1_i686.whl
  • Upload date:
  • Size: 168.0 kB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for cu2qu-1.6.5-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 7a2f024e3a01fdba1a85290a0d7141abd8a375af80fb178d2412c1cf1e3f86df
MD5 839481aab37560386606565ee5fbddc4
BLAKE2b-256 fcbbc02845e6cda05ffa88974480010147650d5ef7983a2c69be3019b45152a4

See more details on using hashes here.

Provenance

File details

Details for the file cu2qu-1.6.5-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for cu2qu-1.6.5-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 57ed7856ee520df2cf10e288dbaeba2f9e54da918c12f2ac83d164055067295a
MD5 5f34a65e22e3059c89828a80facee273
BLAKE2b-256 785c5eb51175e9e4fceb7d5c3e405e1fb575549ce5832a890cd6cb1a18763404

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