fontlab.flTTHCommand
flTTHCommand
A TrueType hinting instruction.
What is flTTHCommand?
TrueType fonts can contain a hint program — a small sequence of instructions embedded in each glyph that tells the rasterizer how to snap outlines to the pixel grid at small display sizes. Each individual instruction in that program is one flTTHCommand.
The instructions you will most commonly see are: - Align — snap a single point to a zone boundary (e.g. snap the top of 'x' to the x-height zone) - Single Link — constrain the distance between two points to match a stem width (e.g. the two edges of a stroke) - Double Link — constrain three points so that the stem width is centred on the midpoint - Delta — a manual pixel-level correction at a specific PPEM size (e.g. "at 11px, move this node 1/8 pixel to the right")
Most designers using FontLab's automatic TrueType hinting will not need to create flTTHCommand objects manually — the autohinting engine handles this. But if you are auditing, exporting, or modifying TT hints programmatically, these are the objects you work with.
Tutorial
import fontlab as fl
font = fl.CurrentFont()
# ============================================================
# Inspect TT hinting commands on a glyph layer.
# Run this after applying TT autohinting to a glyph to see
# what instructions were generated.
# ============================================================
glyph = font['H'] # 'H' is a good test — it has vertical stems
layer = glyph.layers[0]
commands = layer.tthCommands()
print(f"TT hint commands on 'H': {len(commands)}")
for i, cmd in enumerate(commands):
direction = "V" if cmd.isVertical() else "H"
if cmd.isDelta():
kind = "Delta"
elif cmd.isFinal():
kind = "FinalDelta"
else:
kind = f"code={cmd.code}"
print(f" [{i}] [{direction}] {kind}")
print(f" Points: {cmd.point_names}")
print(f" Parameters: {cmd.parameters}")
# For link commands, show which stem they reference:
stem_idx = cmd.stemIndex()
if stem_idx >= 0:
stems = layer.stems
if stem_idx < len(stems):
print(f" Stem: '{stems[stem_idx].name}' "
f"width={stems[stem_idx].value}")
# For delta commands, decode the PPEM/value pairs:
if cmd.isDelta():
params = cmd.parameters
print(f" Delta corrections: {params}")
# ============================================================
# Find all delta commands — these are the manual corrections
# a hinting engineer has added on top of the autohinting.
# ============================================================
print("\n--- Delta commands only ---")
deltas = [cmd for cmd in commands if cmd.isDelta()]
print(f"Found {len(deltas)} delta command(s).")
for d in deltas:
print(f" Points: {d.point_names} Params: {d.parameters}")
# ============================================================
# Count commands by direction across the whole font.
# ============================================================
v_count = 0
h_count = 0
d_count = 0
for glyph in font.glyphs:
for layer in glyph.layers:
for cmd in layer.tthCommands():
if cmd.isVertical(): v_count += 1
if cmd.isHorizontal(): h_count += 1
if cmd.isDelta(): d_count += 1
print(f"\nFont-wide TT hints: "
f"V={v_count} H={h_count} Deltas={d_count}")
Common Scripting Patterns
Count TT hints per glyph
import fontlab as fl
font = fl.CurrentFont()
for glyph in font.glyphs:
layer = glyph.layers[0]
cmds = layer.tthCommands()
if cmds:
print(f"'{glyph.name}': {len(cmds)} hint(s)")
Find all glyphs with delta corrections
import fontlab as fl
font = fl.CurrentFont()
for glyph in font.glyphs:
layer = glyph.layers[0]
deltas = [c for c in layer.tthCommands() if c.isDelta()]
if deltas:
print(f"'{glyph.name}': {len(deltas)} delta(s)")
List all point names used in TT hints for a glyph
import fontlab as fl
font = fl.CurrentFont()
glyph = font['n']
layer = glyph.layers[0]
all_points = set()
for cmd in layer.tthCommands():
all_points.update(cmd.point_names)
print(f"Hinted points in 'n': {sorted(all_points)}")
Constructors: flTTHCommand() - default
Native bases: object
Captured native MRO: flTTHCommand, 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 TrueType hinting command with code, parameters and point_names attributes. The captured declaration exposes fromString, isDelta, isFinal, isHorizontal, isVertical, nodesCount, parametersCount, stemIndex and zoneIndex. It is created as flTTHCommand().
Source: FontLab Proteus API documentation
Source: generated/fontlab.py: flTTHCommand 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 |
|---|---|---|---|
__init__ |
function | (self, /, *args: Any, **kwargs: Any) -> None |
Initialize self. (shared captured text) |
code |
attribute | Any |
The instruction opcode identifying what kind of hinting command this is. |
fromString |
function | (self, arg0: str, itr: Any) -> bool |
Deserialises this command from its string representation. |
isDelta |
function | (self) -> bool |
Returns True if this is a Delta instruction — a fine manual correction applied at one or more specific PPEM sizes. |
isFinal |
function | (self) -> bool |
Returns True if this is a Final Delta — a delta applied in the final pass of the hint program, after all other hints have already been executed. |
isHorizontal |
function | (self) -> bool |
Returns True if this instruction operates in the horizontal direction — snapping to x-axis features like stem widths and sidebearing references. |
isVertical |
function | (self) -> bool |
Returns True if this instruction operates in the vertical direction — snapping to y-axis features like zone boundaries, stem heights, and cap heights. |
nodesCount |
function | (self) -> int |
Returns the number of point names involved in this instruction. |
parameters |
attribute | Any |
Additional parameters. |
parametersCount |
function | (self) -> int |
Returns the number of additional parameters for this command. |
point_names |
attribute | Any |
The names of the points (nodes) this instruction applies to. |
stemIndex |
function | (self) -> int |
Returns the index of the stem this instruction references, or -1 if not stem-related. |
zoneIndex |
function | (self) -> int |
Returns the index of the alignment zone this instruction references, or -1 if not zone-related. |