subframe7536/maple-font · error · ValueError

This script only supports TrueType (glyf) fonts. CFF support

Error message

This script only supports TrueType (glyf) fonts. CFF support not implemented.

What it means

auto_xheight_capheight() reads glyph outlines from the 'glyf' table (TrueType outlines) via _get_glyph_bounds. If the font uses CFF/PostScript outlines ('CFF ' table instead of 'glyf'), it raises this ValueError because CFF support is not implemented in this script.

Source

Thrown at source/py/task/merge_font/utils.py:181

    """Get (yMin, yMax) of a glyph by name from 'glyf' table."""
    glyph_order = font.getGlyphOrder()
    if glyph_name not in glyph_order:
        raise ValueError(f"Glyph '{glyph_name}' not found in font.")
    glyf = font["glyf"]
    glyph = glyf[glyph_name]
    if glyph.numberOfContours == 0:
        # Empty glyph
        return (0, 0)
    y_min = glyph.yMin
    y_max = glyph.yMax
    return (y_min, y_max)


def auto_xheight_capheight(font: TTFont):
    if "OS/2" not in font:
        raise ValueError("Font does not have an OS/2 table.")
    if "glyf" not in font:
        raise ValueError(
            "This script only supports TrueType (glyf) fonts. CFF support not implemented."
        )

    try:
        # Get bounds
        z_ymin, z_ymax = _get_glyph_bounds(font, "z")
        Z_ymin, Z_ymax = _get_glyph_bounds(font, "Z")

        x_height = round(z_ymax)  # xHeight = top of lowercase 'z'
        cap_height = round(Z_ymax)  # capHeight = top of uppercase 'Z'

        # Update OS/2 table
        os2 = font["OS/2"]
        os2.sxHeight = x_height  # type: ignore
        os2.sCapHeight = cap_height  # type: ignore
    except Exception as e:
        print(e)

View on GitHub (pinned to c08fda97fe)

Solutions

  1. Convert the CFF font to TrueType outlines (e.g. fontTools cu2qu: fontTools.ttLib with cu2qu or `otf2ttf`) before processing.
  2. Use a TTF source of the same font instead of the OTF.
  3. Guard the call: only run auto_xheight_capheight when 'glyf' in font.

Example fix

# before
python merge_font.py --input Font.otf

# after
# convert CFF to glyf first
from fontTools.ttLib import TTFont
f = TTFont("Font.otf")
f.flavor = None  # then run cu2qu-based otf2ttf conversion
# or simply use Font.ttf
Defensive patterns

Strategy: validation

Validate before calling

if "glyf" not in font:
    # convert CFF -> TrueType first, e.g. with cu2qu-based otf2ttf
    raise RuntimeError(f"{font.reader.file.name} is CFF; convert to TTF before processing")

Type guard

def is_truetype_outline(font) -> bool:
    return "glyf" in font and "CFF " not in font

Try / catch

try:
    auto_xheight_capheight(font)
except ValueError as e:
    if "glyf" in str(e):
        font = otf2ttf(font)  # convert outlines then retry
        auto_xheight_capheight(font)
    else:
        raise

Prevention

When it happens

Trigger: Running polish() on an OTF (CFF-flavored) font or any TTFont lacking a 'glyf' table while auto x-height computation is enabled.

Common situations: Feeding .otf CFF fonts (e.g. Adobe-sourced fonts) into a pipeline designed for .ttf; fonts converted to CFF; mixed inputs where some family members are CFF.

Related errors


AI-assisted analysis of subframe7536/maple-font@c08fda97fe (2026-08-28). Data as JSON: /api/errors/b67cf650eff8d568. Report an issue: GitHub.