fontlabapp.fontui.outline_routes.add_extremes
add_extremes
Add on-curve nodes at the horizontal and vertical extremes of curves.
What: For each selected glyph and master, the table lists every contour whose curves have an extreme without a node: the node count now and the number of extremes to add. Add Extremes inserts them.
How: For each cubic curve, the script solves the derivative of x and of y for t; extremes closer than 2 % of the parameter t to an end node are ignored. FontLab's own split, flContour.insertNodeTo, inserts each node, so the curve keeps its shape up to FontLab's rounding of the new node. Cuts within 0.1 Manhattan units of an end or an earlier cut are not offered. The splits run from the last curve back, so the segment numbers of the earlier curves stay valid. TrueType (quadratic) contours and open contours are left alone.
Why: Fonts need nodes at extremes for good hinting and rasterisation, and font tests flag missing extremes. With "Keep masters compatible" ticked, a glyph is held back when the masters would get different nodes, or when only some masters are in scope: different nodes break interpolation.
Use: Select glyphs. Run the script. Choose the masters. Press Add Extremes. Press Reload selection after you change the selection.
Benefit: Fixes many glyphs over many masters in one Undo step, and keeps the masters compatible.
Safety: These shapes are listed and kept:
- shared outline data (an edit would change other glyphs too);
- shapes with scale, slant or rotation (an extreme in stored coordinates is not an extreme on screen).
A glyph that has an automatic layer is listed and skipped. So is a glyph that is a base of an automatic composite, also through other composites, unless you tick "Also edit bases of automatic composites" (FontLab then rebuilds those composites; anchor recovery through Undo is not assured). The script keeps the compatibility check; writes disclose queued ids and possible date changes. After the write, it reads the node counts back. If FontLab fails part-way, the error says that native changes may remain. The change is recorded as one Undo step. The one-step write, the automatic-layer rule, the pending-update check and the panel are shared (fly.ap.contours.writer, fly.ap.contours.panel.model); the planner belongs to this script.
Source: the author's own FontLab sample outlines_add_extremes.py, Apache-2.0. Adapted for the current FontLab 9 API.
Classes
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 |
|---|---|---|---|
Cubic |
attribute | ||
KEY |
attribute | ||
MARGIN |
attribute | ||
TITLE |
attribute | ||
XY |
attribute | (shared captured text) | |
contour_plan |
function | (points: list[outline_writer.Point]) -> list[tuple[int, list[float]]] |
[(segment number, [t, ...])] of one closed contour; [] when node 0 is off-curve. |
extreme_changes |
function | (layer: Any) -> list[outline_writer.Change] |
One row per contour that gets extremes; notes for kept shapes. |
extremes |
function | (p0: XY, p1: XY, p2: XY, p3: XY) -> list[float] |
Parameters t of the x and y extremes of one cubic, sorted. |
insert_extremes |
function | (contour: Any, plan: list[tuple[int, list[float]]]) -> int |
Insert the planned nodes from the last segment back. |
main |
function | () -> Any |
Open the panel, or replace the one that is already open. |
roots |
function | (a: float, b: float, c: float) -> list[float] |
Real roots of a t² + b t + c inside (MARGIN, 1 - MARGIN), rounded to 6 places. |
segments |
function | (points: list[outline_writer.Point]) -> list[tuple[int, Cubic]] |
[(segment number, cubic)] of a closed contour whose node 0 is on-curve. |