Skip to content

Draw better circles for circle annotations

Tobias Deiminger requested to merge haxtibal/poppler:bugfix/circleannot into master

Because PDF spec has no built in circle operator, we can only approximate a circle by joining cubic bezier curve segments.

We already did good approximation for line endings and radio buttons by setting distance of bezier control point to (4 * (sqrt(2) - 1) / 3) * r. But the older AnnotGeometry::draw code for subtype circle still used an equivalent of 0.5 * r, which yields a visibly non-circular circle. Fix it by using the bezierCircle define for AnnotGeometry too.

Does minor refactoring by introducing AnnotAppearanceBuilder::drawEllipse, and forwarding drawCircle to it.

Fixes #989 (closed).

Visual comparison

old new
circle_annot_unpatched circle_annot_patched

Recorded using

$ pdftoppm -x 145 -y 446 -W 159 -H 158 -f 0 -singlefile -png /ann.pdf ./circle
Edited by Tobias Deiminger

Merge request reports