Skip to content

fontlabapp.studios.derived_glyphs.shadow

shadow

Add a shifted copy of the outline behind each selected glyph, as its own element.

What it does: For each selected glyph and chosen master, the script copies the contours of the layer, moves the copy by a horizontal and a vertical offset, and puts it behind the outline as a new element named "shadow". The original outline and the advance width do not change.

How it works: A non-modal panel lists every glyph and master with its contour count, or the reason why the layer is skipped. Apply reads the font again and writes all layers in one Undo step through the shared module fly.ap.core.history.glyphs. The copy is made from each contour with its element transform applied; FontLab can drop node names and raw node flags in a contour copy (fl#8569), so the script copies them back and clears the selection bit. After the write it checks that every layer starts with the shadow element and reports any difference. The contour copy and the panel are shared (fly.ap.contours.copy, fly.ap.contours.selection.panel.model).

Copy limits: Only node names and raw node flags are repaired (fl#8569); selection is cleared. Other node properties and contour names are not repaired. Copied contours are merged into one element; source element names and notes are not copied.

Why this design: - A separate element is easy to recolour, move or delete as one unit, and a layer font workflow can split it into shadow glyphs. Filled together with the outline it gives an extruded silhouette. - Layers with components are skipped: a copy of the contours alone would not be the full glyph. Locked layers and layers that already hold a shadow element are skipped too. - Automatic layers and glyphs with automatic layers are never edited. A base of automatic composites is skipped unless you tick "Edit bases of auto glyphs anyway": FontLab then rebuilds those composites, can drop their anchors and locks, and Undo does not restore them. - Apply discloses queued ids and their possible date changes. The script does not call UpdateAll (fl#8537). The panel binds to the font that was current when it opened.

How to use: Select glyphs in the Font window. Run the script. Set the offsets, choose the current master or all masters, check the table and press Add Shadow. The panel stays open; press "Use selection" after you select other glyphs. Each Apply is recorded as one Undo step.

Benefit: Shadowed or extruded display styles start from the real outline in one step, and the shadow stays a separate element.

Credit: Adapted from the author's own FontLab sample, Apache-2.0 (generate_shadow.py, "Shadow Copy").

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
KEY attribute
SHADOW attribute
TITLE attribute
add_shadows function (rows: Sequence[Row], dx: int, dy: int, facts: Any, allow_bases: bool) -> dict[str, Any] Insert one shifted shadow element first in every planned layer, as ONE Undo step.
layer_note function (layer: Any, reason: str) -> str Return why <code>layer</code> gets no shadow, or "" when it can get one.
main function () -> Any Open the panel. (shared captured text)
panel_type function () -> type Build the panel class once Qt is available (inside FontLab).
survey function (package: Any, names: Sequence[str], masters: Sequence[str], facts: Any, allow_bases: bool) -> list[Row] Plan every glyph/master. (shared captured text)