fontlabapp.fontui.teaching_painter.polygon
polygon
What: Draw a star polygon in the current FontLab layer as one Undo step. How: Alternate radii in font units, with Y up. Centre the contour on half the active layer advance and half its associated master's FontMetrics cap height. Why: Start ornamental glyphs from repeatable, font-sized construction. Usage: Open a glyph. Set tips, radii in ems and rotation. Generate Preview, then Draw in Current Layer. Each Draw adds one closed contour in a new shape. Auto layers and bases of auto composites are refused. Read-back checks the new contour and verifies every pre-existing shape's geometry. Layers without an associated master are refused. Draw coordinates use whole-unit half-up rounding (ties away from zero); read-back allows 0.5 units on each new-node coordinate. A partial-write error directs you to Edit > Undo. Benefit: Create geometric artwork directly in the active glyph layer.
The read-only shape preview is centred at the origin; drawing placement uses the current advance and cap height. Equal radii produce a regular polygon with twice the tip count. Positive rotation turns counterclockwise. SVG is secondary output for an external vector editor. Generate Preview, then copy the SVG text or Save New SVG to a new absolute .svg path. SVG uses a Y-down em square and contains no font metrics, anchors or hints. Setup: FontLab 9, Python 3.11, Fly and fontlabapp. Modeless panel. The App panel owns signals and completion. No painter or plugin is needed.
Independent rewrite of the Qt polygonwidget example idea, David Boddie and Trolltech ASA. Based on the author's own FontLab sample, Apache-2.0. No upstream code or assets copied.
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
current_svg |
function | (tips: int, outer: float, inner: float, rotation: float) -> str |
Read and fence the current font UPM. |
draw_current |
function | (tips: int, outer: float, inner: float, rotation: float, *, disclosure: dict[str, Any] | None=None) -> None |
Append one closed contour, fence context and check attached node geometry. |
layer_geometry |
function | (layer: Any, qt: Any) -> tuple |
Snapshot each shape's transform basis, closure and raw/transformed nodes. |
main |
function | () -> Any |
Compatibility entrypoint for the retained standalone lesson. |
panel_type |
function | (qt: Any) -> type |
Open the shared App panel. |
polygon_points |
function | (upm: float, tips: int, outer: float, inner: float, rotation: float) -> list[tuple[float, float]] |
Return Y-up points centred at the origin. |
polygon_svg |
function | (upm: float, tips: int, outer: float, inner: float, rotation: float) -> str |
Return Y-down SVG in an em square for an external vector editor. |
round_unit |
function | (value: float) -> float |
Round a finite coordinate half-up to whole units; ties go away from zero. |
save_svg |
function | (filename: str, text: str) -> None |
Save generated SVG to a new absolute path; never replace a file or link. |