Replace Reference
Replace the base glyph of matching components, and keep their placement.
What: Every component that refers to glyph X now refers to glyph Y. Offset, scale, slant, name, note and lock of each component stay. Works on the selected glyphs or on the whole font, on one or all masters. The table lists every component that changes.
How: The script sets the base glyph name of the existing component in place, then lets FontLab rebuild the component. It does not delete and re-create the component, so nothing that a re-created element would lose is lost.
Why: Swapping a mark or a figure variant in many composites by hand is slow and easy to get wrong. This keeps every placement exactly where it was.
Use: Run the script. Type the glyph to replace and the new glyph (both fields complete names). Choose the glyphs and masters. Press Replace. Press Reload selection after you change the selection.
Benefit: Changes a component in the whole font in one Undo step.
Safety: Auto layers are listed and never edited (change their recipe). A component is blocked, with the reason in red, when:
- the new glyph has no layer for that master;
- the new glyph uses the edited glyph, directly or through other components (the result would refer to itself);
- the component shares its element data with other elements (the change would reach them too).
The script refuses the whole batch, before any history exists, when:
- a glyph has an automatic layer, or is the base of an automatic composite, also through other composites (FontLab rebuilds the composite and Undo does not restore it);
After the write, the script reads the components back and reports any gap. If FontLab fails part-way, the error says that native changes may remain. Use Edit > Undo then. The one-step write, the panel, the automatic-layer rule and the pending-update check are shared with other scripts (fly.ap.components.writer, fly.ap.components.panel.model, fly.ap.core.history.glyphs, fly.ap.core.edit_guards); the planner and the panel controls belong to this script.
Source: the author's own FontLab sample components_replace_reference.py, Apache-2.0. Adapted for the current FontLab 9 API.
Run Components > Replace Reference from FontLab's Scripts menu.
Read installation and working with scripts before use.
Source identity
SHA256: 917f4830be09b763e3f6adc4be813e5118d6e3e78c23ef7fb899b570c2091086