cu2qu
raw JSON → 1.6.7.post2 verified Fri May 01 auth: no python maintenance
cu2qu is a Python library for converting cubic bezier curves to quadratic bezier curves, commonly used in font engineering workflows such as converting cubic outlines (TrueType) to quadratic outlines (OpenType). Current version 1.6.7.post2 is in maintenance mode, with infrequent updates.
pip install cu2qu Common errors
error ModuleNotFoundError: No module named 'cu2qu' ↓
cause cu2qu is not installed.
fix
Run 'pip install cu2qu' to install the library.
error AttributeError: module 'cu2qu' has no attribute 'curve_to_quadratic' ↓
cause The function is not exposed at the top level; it's inside pens submodule.
fix
Use 'from cu2qu.pens import CurveToQuadraticPen' instead.
Warnings
gotcha cu2qu functions are primarily designed for use with fonttools pens. Direct usage without fonttools may require additional adaptation. ↓
fix Ensure fonttools is installed and use pens like fonttools.pens.recordingPen.RecordingPen to capture output.
deprecated The 'cu2qu.ufo' module is deprecated and may be removed in future versions. Use fonttools instead. ↓
fix Migrate to fonttools' own quadratic conversion tools or use the pens module directly.
gotcha Version 1.6.7.post2 is a post-release; it may not be the final stable release. Check for newer stable versions or rely on 1.6.7. ↓
fix Pin to cu2qu==1.6.7 if post-release causes issues.
Imports
- curve_to_quadratic wrong
import cu2qucorrectfrom cu2qu.pens import CurveToQuadraticPen - cubic_approx_quadratic
from cu2qu import cubic_approx_quadratic
Quickstart
from cu2qu.pens import CurveToQuadraticPen
from fonttools.pens.recordingPen import RecordingPen
# Example: convert a cubic path to quadratic
recorder = RecordingPen()
# Assume you have a cubic path to draw
# For demonstration, we create a dummy converter
pen = CurveToQuadraticPen(recorder, max_err=1.0)
pen.moveTo((0, 0))
pen.lineTo((100, 0))
pen.curveTo((50, 150), (150, 150), (100, 0))
pen.closePath()
print('Conversion done. Check recorder for output.')