Cubic-to-quadratic bezier curve conversion
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for cu2qu-1.6.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd75aa7c7f9a0d70daafd250a6d7acc9bbfecd1ec5c4bb4e4b96b8c9b986ed0d |
|
MD5 | 167df46924ea3557747788f99dd0c289 |
|
BLAKE2b-256 | 1c932dffac4c0ff292ad4e55b39f65a0d2325e2d2971070931d9bee1b4382d4b |
Hashes for cu2qu-1.6.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10a0b22254f9781909f77ab1b471ed0120b9de81a221e97053a11cf4bbf4db6f |
|
MD5 | 081f04f7b6c6d4d0411cedd9ca910bd0 |
|
BLAKE2b-256 | bd1d1621ce186d16c7da7bc6cea096148e183457f1a3a33afe84dbee9b591424 |
Hashes for cu2qu-1.6.4-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a30c375d1de626db52c36cbaa1ffcad3dee4e741f41a124b2adf11ba47c82b8 |
|
MD5 | a32da13eb353ca66e29a7e805e256995 |
|
BLAKE2b-256 | fb35afcaaeef38a356f2e8abc8ac9f3bf7732f9a2db24e0006a9ebe09f3bd098 |
Hashes for cu2qu-1.6.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be920fef28a4dade50c3c0ccfadd813894481ddae4a8a62ff4d4f004bbe192eb |
|
MD5 | 6545b6921cfec3ed2dbfe36b4dc89d8b |
|
BLAKE2b-256 | ba0b629f5bd7dd22cc2ce9b22fb51f57aa42ba7c477d49ed3af1f39ed82857c4 |
Hashes for cu2qu-1.6.4-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3cd53d909e15e83eccb35537d3b27ee61b97dad7440d7975964a9896bafe648 |
|
MD5 | 13864aefc809fc49f7cfa6a56374f1da |
|
BLAKE2b-256 | 1919df18e0fe9364cd552734967a1e78e58c53f0b951fbe78d47293ea8273bb2 |
Hashes for cu2qu-1.6.4-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 | eb86d5cefed83d15bac7b470719044b003322d476c99b954fbbb3884793a69be |
|
MD5 | 97dc443f0e33b220c01e43a8efc8e0d2 |
|
BLAKE2b-256 | ed37f243554aa24c4a6d0056809627d1865f189939d7b658b62f4b20dbd6180a |
Hashes for cu2qu-1.6.4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89c46655ea139568ad2d2ae5778244342eb2f12d19b8d2929a538f2082844dea |
|
MD5 | 41408a3c21de31d57056e7c3bd89b21c |
|
BLAKE2b-256 | 3620a4c81f5383bed8d52463cc3e0cc4f85a1e8804f1a337e711885332d7a8a0 |
Hashes for cu2qu-1.6.4-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11a718a57c3e6595eef0fa917ec6c6867e93781cf594e97e753cc37143044755 |
|
MD5 | b157ecf06e6b06d5799155948055f3fb |
|
BLAKE2b-256 | cab299290c496158f27c5cd3216601a86252f688daed69f4c72cf689d531b2ea |
Hashes for cu2qu-1.6.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2260c3c638576945985b6a58de24ee0bf33f20cd2e495d529312eaa648066a5a |
|
MD5 | 5098f67714f409d4db73dc8799532939 |
|
BLAKE2b-256 | 2e94d95d252548014bc61242a4b877224cd5859ea50df5e4252138a6bcf5aa1a |
Hashes for cu2qu-1.6.4-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ab43303bc1e010c285bec278f6a6ffcd395a8a0e9c0443718a0e377ce3e704f |
|
MD5 | e9a26784c4c7384e9414684ab8ee112d |
|
BLAKE2b-256 | 3751d593d8131822afad7b5b21da5e31c8925dc0e6c116c1c59e1b42116b27d4 |
Hashes for cu2qu-1.6.4-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 | d6bb169aebda1403c7e08eb68b2c81515f62f1b27f8866e1adb0ad7141470794 |
|
MD5 | e7f76ce47b563b8bcc8efdca1e2e0006 |
|
BLAKE2b-256 | 109a413f4806fa569f0aa626830b26889bfb92fd9dffcfadbf99b2ef76418cff |
Hashes for cu2qu-1.6.4-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e321e12fdce96b98e6fa7e25422bda4980181157058dd8925a53fa0d018e5e24 |
|
MD5 | f9615364d9a77da8bd990c4903e28525 |
|
BLAKE2b-256 | f5538ef1ba741f08234af878af2fff94c3516f5abd972456c7d0adc1a4f2b9f0 |
Hashes for cu2qu-1.6.4-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b9c218986b9b779cdc0768b6c901243c93ae2f337feeaf1c80a79eb8c2df81b |
|
MD5 | 36aed89ffdde47f2d66ed3c08e108d5b |
|
BLAKE2b-256 | a3f2288d8adbdf7449ec711f5d77aa1052d3f95b5f09cff48f21c168b126b169 |
Hashes for cu2qu-1.6.4-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7461fe12ae42ebe4427c1d588270b184c57a6a9667dd5af82e62dc2925bde06 |
|
MD5 | 4a9611ad90bcb79df017a8969c2beed3 |
|
BLAKE2b-256 | 6d55638146d9458861eb6b78578903e92150751db5ff9ec1f25204a591dee03e |
Hashes for cu2qu-1.6.4-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca9084fec41d20e4a1a506a2984b5f5ebc2a68568b3aa97dab53c47c754dbed9 |
|
MD5 | 1b64945d42edfc403cf5bc80204a7131 |
|
BLAKE2b-256 | dcff53c0783fdef5dc243e3b4c29ffa9510912ca3334d89b695726b72b054283 |
Hashes for cu2qu-1.6.4-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2fa6dbdfec0515f939685ddbc211a564ce954998d114b43c43a20d6a54e5da4 |
|
MD5 | 30cfc2f9e2619cda3a831e87018d4a5a |
|
BLAKE2b-256 | 86d6507bedf5037bc5a213edc99f70386f439f9b69321c6fba557622f3978983 |
Hashes for cu2qu-1.6.4-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a997dea5a7a07a3649237cefad57aa1134d18687d6268d84190b03d46669218 |
|
MD5 | d6e15aab3652f2549cc96d2bcdcde8f4 |
|
BLAKE2b-256 | 47877ec361298633fddb4559b5c9b6294c0485708096efedc01be2adfea2426f |
Hashes for cu2qu-1.6.4-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 | e7ff729c3ad0d9815da70088dc7960fe983594ccfd0704761c5c756320e25867 |
|
MD5 | d412c55463844efabacfac3ba4f4c1e6 |
|
BLAKE2b-256 | 8e672f490a5867cceecb5027850b387d56dbae2504dc927fb5b77c80a2ae0260 |