Skip to content

fontlab.flHintingParameters

flHintingParameters

PostScript hinting settings.

What is flHintingParameters?

PostScript (CFF/Type 1) hinting makes your fonts look crisper at small sizes on screen by snapping certain features to pixel boundaries. The hinting parameters control exactly how aggressive or conservative that snapping is.

If you are a type designer who cares about these settings, you already know what BlueFuzz, BlueShift, and BlueScale mean. If you are not sure: the default values work well for most fonts — FontLab's autohinting engine will set them appropriately when you run autohint.

The settings here correspond directly to the Private dictionary in CFF/Type 1 fonts and to certain fields in the OpenType maxp and head tables (for TrueType hinting).

Access hinting parameters on a font via:

hp = font.hintingParameters(master_name)

PostScript / CFF Hinting Properties

These are the values written into the Private dictionary of a CFF/Type 1 font.

Name Type Access Description
forceBold bool rw If True, the rasterizer will artificially thicken strokes at very small sizes (below forceBoldTreshold). Rarely needed for modern screen rendering, but sometimes useful for bitmap-targeted fonts. Adobe's recommendation is False.
forceBoldTreshold double rw The display size (in PPEM) below which forceBold takes effect. Only matters if forceBold is True.
blueFuzz int rw Extends each blue zone by this many character-space units on each side, giving the zone a wider "fuzzy" capture region. A value of 0 means zones have sharp edges. Adobe recommends 0 for most fonts.
blueShift int rw The minimum distance between an overshoot and the alignment zone boundary for the overshoot to be suppressed at small sizes. Adobe recommends 7.
blueScale double rw The PPEM size at which overshoots are no longer suppressed and the full design curve is shown without snapping. Adobe recommends 0.039625 (corresponding to roughly 25 PPEM).
flex bool rw If True, nearly-horizontal curves (like the slight curve of a capital S at the mid-stroke) are eligible for the CFF flex hint, which reduces visual weight at small sizes by treating the nearly-flat curve as truly flat.
zonePPM int rw The minimum PPEM at which alignment zone hinting is active. Below this size, zone snapping is disabled.
stemSnapLimit int rw The maximum number of stems that can be included in the StemSnap arrays. CFF limits StemSnapH and StemSnapV to 12 values each.
codePPM int rw The PPEM at which code-level (glyph instruction) hinting engages.
dropoutPPM int rw The PPEM below which dropout control (a technique that improves rendering of thin diagonal strokes) is applied.

OpenType maxp / head Properties

These values are written into the OpenType binary and affect TrueType hinting behaviour and font metadata.

Name Type Access Description
lowestRecPPEM int rw The "lowest recommended pixel-per-em" value written to the OpenType head table. This tells applications the minimum display size at which the font is intended to be used. Typical values: 8–12 for body text fonts.
fontDirectionHint int rw Writing direction hint written to the head table. 2 = strongly left-to-right (Latin, Cyrillic, Greek, etc.), -2 = strongly right-to-left (Arabic, Hebrew), 0 = mixed. Most fonts use 2.
maxZones int rw Maximum number of TrueType hinting zones used by the glyph programs. Written to maxp.
maxTwilightPoints int rw Maximum number of "twilight zone" points used by the TrueType hint program. The twilight zone holds temporary reference points. Written to maxp.
maxStorage int rw Maximum number of storage area locations (variables) the TrueType hint program uses. Written to maxp.
maxFunctionDefs int rw Maximum number of functions defined in the TrueType hint program's FPGM table. Written to maxp.
maxInstructionDefs int rw Maximum number of instruction definitions (IDEF). Written to maxp.
maxStackElements int rw Maximum stack depth during TrueType hint program execution. Written to maxp.

Tutorial

import fontlab as fl

font = fl.CurrentFont()

# ============================================================
# Read the hinting parameters for the first master.
# ============================================================

master = font.masters[0]
hp = font.hintingParameters(master)

print(f"--- Hinting Parameters for master '{master}' ---")
print(f"BlueFuzz:      {hp.blueFuzz}")
print(f"BlueShift:     {hp.blueShift}")
print(f"BlueScale:     {hp.blueScale:.6f}")
print(f"ForceBold:     {hp.forceBold}")
print(f"Lowest PPEM:   {hp.lowestRecPPEM}")
print(f"Direction hint:{hp.fontDirectionHint}")

# ============================================================
# Apply Adobe's recommended values.
# These are good defaults for most professional Latin fonts.
# ============================================================

hp.blueFuzz       = 0         # sharp zone edges
hp.blueShift      = 7         # standard overshoot threshold
hp.blueScale      = 0.039625  # suppress overshoots below ~25 PPEM
hp.forceBold      = False
hp.lowestRecPPEM  = 8         # usable down to 8px
hp.fontDirectionHint = 2      # left-to-right

print("\nAdobe recommended values applied.")

# ============================================================
# Check TrueType maxp values (relevant only if the font
# has a TT hint program with custom functions).
# ============================================================

print(f"\nTT maxp values:")
print(f"  maxZones:          {hp.maxZones}")
print(f"  maxTwilightPoints: {hp.maxTwilightPoints}")
print(f"  maxStorage:        {hp.maxStorage}")
print(f"  maxFunctionDefs:   {hp.maxFunctionDefs}")
print(f"  maxStackElements:  {hp.maxStackElements}")

# ============================================================
# Iterate over all masters and apply consistent settings.
# ============================================================

for master_name in font.masters:
    hp = font.hintingParameters(master_name)
    hp.blueFuzz  = 0
    hp.blueShift = 7
    hp.blueScale = 0.039625

print("\nUpdated all masters.")

Common Scripting Patterns

Print hinting parameters for every master

import fontlab as fl

font = fl.CurrentFont()
for master in font.masters:
    hp = font.hintingParameters(master)
    print(f"[{master}] blueFuzz={hp.blueFuzz}  blueShift={hp.blueShift}  "
          f"blueScale={hp.blueScale:.6f}  lowestPPEM={hp.lowestRecPPEM}")

Reset to defaults

import fontlab as fl
from fontlab import flHintingParameters

font = fl.CurrentFont()
for master in font.masters:
    hp = font.hintingParameters(master)
    hp.init()   # restore factory defaults
print("All hinting parameters reset to defaults.")

Constructors: flHintingParameters() - default

Native bases: object

Captured native MRO: flHintingParameters, 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: Font-level hinting parameters. The captured declaration exposes the method init and the attributes blueFuzz, blueScale, blueShift, codePPM, dropoutPPM, flex, fontDirectionHint, forceBold, forceBoldTreshold, lowestRecPPEM, maxFunctionDefs, maxInstructionDefs, maxStackElements, maxStorage, maxTwilightPoints, maxZones, stemSnapLimit and zonePPM. It is created as flHintingParameters(). Note the captured spelling forceBoldTreshold.

Source: FontLab Proteus API documentation

Source: generated/fontlab.py: flHintingParameters 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)
blueFuzz attribute Any
blueScale attribute Any
blueShift attribute Any
codePPM attribute Any
dropoutPPM attribute Any
flex attribute Any
fontDirectionHint attribute Any
forceBold attribute Any
forceBoldTreshold attribute Any
init function (self) -> Any Resets all hinting parameters to their factory defaults.
lowestRecPPEM attribute Any
maxFunctionDefs attribute Any
maxInstructionDefs attribute Any
maxStackElements attribute Any
maxStorage attribute Any
maxTwilightPoints attribute Any
maxZones attribute Any
stemSnapLimit attribute Any
zonePPM attribute Any