fontlab.flPinPoint
flPinPoint
Named anchor for mark positioning.
What is an anchor?
Anchors — represented in code as flPinPoint objects — are the small triangular markers you place on glyphs to tell FontLab how combining marks (like accents, dots, and cedillas) connect to base letters. If you've ever placed a "top" anchor on a lowercase a and a "_top" anchor on an acutecomb, you've been working with flPinPoint.
The system works by pairing anchors that share the same name, one from a base letter and one from a mark:
- An anchor without a leading underscore (e.g.
top,bottom,ogonek) lives on the base letter. It says: "This is the spot where a combining mark can attach to me." - An anchor with a leading underscore (e.g.
_top,_bottom,_ogonek) lives on the combining mark. It says: "This is my attachment point — align me here when connecting to a base."
When FontLab (or the OpenType shaping engine) needs to position acutecomb on top of a, it looks for a top anchor on the a and a _top anchor on the acutecomb, then positions the mark so those two points coincide.
Common anchor names you'll encounter:
- top / _top — for marks that sit above a letter (acute, grave, circumflex, etc.)
- bottom / _bottom — for marks below (cedilla, ogonek)
- ogonek / _ogonek — for the ogonek diacritic specifically
- horn / _horn — for the Vietnamese horn marks
Cloud mode
When you enable cloud mode on an anchor, the anchor's position is no longer fixed to absolute coordinates. Instead, FontLab calculates its position dynamically from the nearest point on the glyph's outline. This is useful for anchors on glyphs whose shapes vary significantly across masters in a variable font — the cloud anchor "floats" to an optically correct position at each master rather than staying locked to coordinates that might be wrong at extreme instances.
Expression anchors
Like guidelines, anchors can have their X and Y coordinates driven by arithmetic expressions. For example, you can set expressionX = "=lsb + (rsb - lsb) / 2" to always place an anchor at the horizontal center of a glyph's advance width, no matter how wide the glyph gets.
flPinPoint vs flAnchor — what's the difference?
This is a common point of confusion. There are two anchor classes in FontLab:
-
flPinPoint(Python name:flPinPoint) — the named anchor that lives on a glyph layer and participates in mark-to-base positioning. This is the one you create, name, and inspect when building an OpenType mark feature. It's what you see as the little triangle in the glyph editor. -
flAnchor— a lower-level geometric link that connects a shape to a guideline or another shape within FontLab's composite/smart-corner system. You don't create these by hand; they appear onshape.anchors()as part of FontLab's internal shape-attachment mechanism. They store references to the attached objects (node, shape, guideline) and record which movement directions are constrained. Unless you're doing advanced shape scripting or building smart components, you'll rarely need to touchflAnchordirectly.
In short: if you're building mark-to-base or mark-to-mark positioning, work with flPinPoint. If you're exploring how shapes lock to each other in composites, you might encounter flAnchor.
Tutorial
Anchors are the most reliable way to position diacritics and combining marks. Here is the complete workflow: adding anchors to a base letter, adding anchors to a mark, and verifying the pairs.
import fontlab as fl
from fontlab import flPinPoint
# Use the native Python class name:
flPinPoint = fl.flPinPoint
font = fl.CurrentFont()
# ============================================================
# Step 1: List existing anchors on a glyph.
# ============================================================
glyph = font['a']
if glyph is None:
print("No 'a' glyph in this font.")
raise SystemExit
layer = glyph.layers[0]
print(f"Anchors on '{glyph.name}':")
for anchor in layer.anchors:
expr = f" (formula: x={anchor.expressionX}, y={anchor.expressionY})" \
if anchor.hasExpression else ""
print(f" '{anchor.name}': ({anchor.point.x():.0f}, {anchor.point.y():.0f}){expr}")
# ============================================================
# Step 2: Add a 'top' anchor to a base letter.
# Place it at the top center of the glyph's bounding box.
# ============================================================
bbox = layer.boundingBox()
top_x = (bbox.left() + bbox.right()) / 2
top_y = bbox.top()
existing_names = {a.name for a in layer.anchors}
if 'top' not in existing_names:
top_anchor = flPinPoint(top_x, top_y)
top_anchor.name = "top"
layer.addAnchor(top_anchor)
print(f"\nAdded 'top' anchor at ({top_x:.0f}, {top_y:.0f})")
fl.Update()
else:
print("\n'top' anchor already exists — skipping.")
# ============================================================
# Step 3: Add the corresponding '_top' anchor to a mark glyph.
# The mark anchor should be at its attachment point (usually
# the bottom of the accent shape).
# ============================================================
mark_glyph = font['acutecomb']
if mark_glyph:
mark_layer = mark_glyph.layers[0]
mark_bbox = mark_layer.boundingBox()
attach_x = (mark_bbox.left() + mark_bbox.right()) / 2
attach_y = mark_bbox.bottom() # bottom of accent = attachment point
mark_names = {a.name for a in mark_layer.anchors}
if '_top' not in mark_names:
mark_anchor = flPinPoint(attach_x, attach_y)
mark_anchor.name = "_top"
mark_layer.addAnchor(mark_anchor)
print(f"Added '_top' anchor to 'acutecomb' at ({attach_x:.0f}, {attach_y:.0f})")
fl.Update()
# ============================================================
# Step 4: Use an expression anchor for the center-top position.
# This anchor always stays at the horizontal center regardless
# of the glyph width.
# ============================================================
center_anchor = flPinPoint(0, 0)
center_anchor.name = "top"
center_anchor.expressionX = "=(lsb + rsb) / 2 + width / 2"
center_anchor.expressionY = "=xHeight"
print(f"\nExpression anchor: x='{center_anchor.expressionX}'"
f" y='{center_anchor.expressionY}'")
print(f"Has expression: {center_anchor.hasExpression}")
Common Scripting Patterns
Add top/bottom anchors to all lowercase letters
import fontlab as fl
flPinPoint = fl.flPinPoint
font = fl.CurrentFont()
LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'
for char in LOWERCASE:
glyph = font[char]
if glyph is None:
continue
layer = glyph.layers[0]
bbox = layer.boundingBox()
cx = (bbox.left() + bbox.right()) / 2
existing = {a.name for a in layer.anchors}
if 'top' not in existing:
a = flPinPoint(cx, bbox.top()); a.name = "top"
layer.addAnchor(a)
if 'bottom' not in existing:
a = flPinPoint(cx, bbox.bottom()); a.name = "bottom"
layer.addAnchor(a)
fl.Update()
print(f"Added top/bottom anchors to {len(LOWERCASE)} glyphs.")
Find all anchor name pairs (base + mark)
import fontlab as fl
font = fl.CurrentFont()
base_names = set()
mark_names = set()
for glyph in font.glyphs:
for layer in glyph.layers:
for anchor in layer.anchors:
if anchor.name.startswith("_"):
mark_names.add(anchor.name[1:])
else:
base_names.add(anchor.name)
pairs = base_names & mark_names
orphans = (base_names | mark_names) - pairs
print(f"Paired anchor names: {sorted(pairs)}")
print(f"Unpaired: {sorted(orphans)}")
flPinPoint.PinPointStyle
Use the flPinPoint.PinPointStyle dictionary with subscription.
| Key | Native value | Description |
|---|---|---|
FreePosition |
flPinPoint::PinPointStyle::FreePosition |
Native enum value. |
ShapeBound |
flPinPoint::PinPointStyle::ShapeBound |
Native enum value. |
Inherited binding members: flObject.
Constructors: flPinPoint() flPinPoint(flPinPoint) flPinPoint(flObject) flPinPoint(QPointF[, PinPointStyle=FreePosition])
Native bases: object
Captured native MRO: flPinPoint, object
Native new allocation evidence (not an init overload): (args, *kwargs) Create and return a new object. See help(type) for accurate signature.
Supplemental documentation:
A pin point object with a point position, a style, an appearance value and the boolean attributes anchor, isLatch, markEnabled, cloudEnabled and hasExpression, plus the text attributes expressionX and expressionY. The captured declaration also exposes translate, createInstance and the object property, flag and history methods shared with the base editing object.
Source: FontLab Proteus API documentation
Source: generated/fontlab.py: flPinPoint captured declaration
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 |
|---|---|---|---|
PinPointStyle |
attribute | dict |
|
__init__ |
function | (self, /, *args: Any, **kwargs: Any) -> None |
Initialize self. (shared captured text) |
anchor |
attribute | Any |
When True, this is a mark attachment anchor for mark-to-base positioning. |
appearance |
attribute | Any |
Visual style index controlling how this anchor is drawn in the editor. |
changed |
function | (self) -> Any |
(shared captured text) |
checkInitHistoryState |
function | (self, history_ix: int) -> Any |
(shared captured text) |
clearAboveHistory |
function | (self, history_ix: int) -> Any |
(shared captured text) |
clearFlag |
function | (self, f: int) -> Any |
(shared captured text) |
clearFlags |
function | (self) -> Any |
(shared captured text) |
clone |
function | (self, *args: Any, **kwargs: Any) -> Any |
Clone the object (shared captured text) |
cloneObject |
function | (*args: Any, **kwargs: Any) -> Any |
(shared captured text) |
cloudEnabled |
attribute | Any |
Enables glyph construction, automatic positioning, Anchor Clouds, and live Mark Attachment preview. |
createInstance |
function | () -> flPinPoint |
Allocates and returns a new, empty anchor instance. |
createObject |
function | (*args: Any, **kwargs: Any) -> Any |
FlObject/Nothing createObject(int); (shared captured text) |
currentHistoryState |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
expressionX |
attribute | Any |
Arithmetic expression controlling the anchor's X position. |
expressionY |
attribute | Any |
Arithmetic expression for the anchor's Y position. |
flObjectFlags |
attribute | dict |
(shared captured text) |
flag |
function | (self, f: int) -> Any |
(shared captured text) |
getProperties |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get object's properties list (shared captured text) |
getProperty |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get object property by 'key' or number (shared captured text) |
getPropertyFloat |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get float object property by 'key' (shared captured text) |
getPropertyInt |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get int object property by 'key' (shared captured text) |
hasChanges |
attribute | Any |
(shared captured text) |
hasExpression |
attribute | Any |
True if either expressionX or expressionY is set. |
hasHistoryState |
function | (self, history_ix: int) -> Any |
(shared captured text) |
hasHistoryStates |
attribute | Any |
(shared captured text) |
haveObject |
function | (*args: Any, **kwargs: Any) -> Any |
(shared captured text) |
historyStates |
function | (self, accepted_state: bool) -> Any |
(shared captured text) |
id |
attribute | Any |
Object id (shared captured text) |
independedAll |
function | (self) -> Any |
(shared captured text) |
initialHistoryState |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
instanceType |
function | (*args: Any, **kwargs: Any) -> Any |
(shared captured text) |
isChanged |
attribute | Any |
(shared captured text) |
isEqual |
function | (self, arg0: flObject) -> Any |
(shared captured text) |
isLatch |
attribute | Any |
True if this anchor is in latch (locked) mode — snapped to and held at a specific contour position. |
isNull |
attribute | Any |
(shared captured text) |
isPresent |
attribute | Any |
(shared captured text) |
isReleased |
attribute | Any |
(shared captured text) |
isValid |
attribute | Any |
(shared captured text) |
markEnabled |
attribute | Any |
Enables participation in generated OpenType mark and mkmk features. |
name |
attribute | Any |
Object name |
point |
attribute | Any |
The anchor's position in font units. |
propertyNames |
function | (self, *args: Any, **kwargs: Any) -> Any |
PropertyNames(): sorted snapshot of dynamic property keys (shared captured text) |
refCnt |
attribute | Any |
Object references count (shared captured text) |
release |
function | (self) -> Any |
(shared captured text) |
remove |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
removeChild |
function | (self, arg0: flObject) -> Any |
(shared captured text) |
restoreHistoryState |
function | (self, history_ix: int) -> Any |
(shared captured text) |
setFlag |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
setProperty |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set object property by 'key' or number (shared captured text) |
setPropertyFloat |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set float object property by 'key' (shared captured text) |
setPropertyInt |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set int object property by 'key' (shared captured text) |
style |
attribute | Any |
The display style enum for this pin-point. |
tag |
function | (self, *args: Any, **kwargs: Any) -> Any |
(shared captured text) |
translate |
function | (self, arg0: QPointF) -> Any |
Moves the anchor by the given offset vector. |
type |
attribute | Any |
Object type (shared captured text) |
update |
function | (self) -> Any |
(shared captured text) |