{"record":{"id":"6a991b3d0196ef44","repo":"subframe7536/maple-font","slug":"font-weight-of-thin-must-be-100","errorCode":null,"errorMessage":"Font weight of `thin` must be 100","messagePattern":"Font weight of `thin` must be 100","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/py/utils.py","lineNumber":455,"sourceCode":"    head.yMin = new_descender  # type: ignore\n    hhea.ascent = new_ascender  # type: ignore\n    hhea.descent = new_descender  # type: ignore\n    os2.sTypoAscender = new_ascender  # type: ignore\n    os2.sTypoDescender = new_descender  # type: ignore\n    os2.usWinAscent = new_ascender  # type: ignore\n    os2.usWinDescent = -new_descender  # type: ignore\n\n\ndef patch_instance(font: TTFont, all_weight_map: dict[str, int]):\n    if all_weight_map == default_weight_map:\n        print(\"Skip weight remapping since nothing changed.\")\n        return\n\n    if \"fvar\" not in font or \"STAT\" not in font:\n        return\n\n    if all_weight_map[\"thin\"] != 100:\n        raise Exception(\"Font weight of `thin` must be 100\")\n\n    if all_weight_map[\"extrabold\"] != 800:\n        raise Exception(\"Font weight of `extrabold` must be 800\")\n\n    value_to_name = {v: k for k, v in default_weight_map.items()}\n\n    for instance in font[\"fvar\"].instances:  # type: ignore\n        current_weight = int(instance.coordinates[\"wght\"])\n        weight_name = value_to_name.get(current_weight)\n        if weight_name and weight_name in all_weight_map:\n            instance.coordinates[\"wght\"] = all_weight_map[weight_name]\n\n    axes = font[\"fvar\"].axes  # type: ignore\n    wght_index = next((i for i, ax in enumerate(axes) if ax.axisTag == \"wght\"), None)\n    if wght_index is None:\n        return\n\n    stat = font[\"STAT\"].table  # type: ignore","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/subframe7536/maple-font/blob/c08fda97fef73d68c1755219852150770f6e6578/source/py/utils.py#L437-L473","documentation":"patch_instance post-processes a variable font's fvar instances and STAT table, assuming the weight axis covers named instances from thin (100) to extrabold (800). It raises this Exception when all_weight_map[\"thin\"] is not exactly 100, meaning the font's minimum named weight deviates from the variable-font spec value the patching logic relies on. The name-to-weight mapping (value_to_name) would otherwise be wrong.","triggerScenarios":"Calling build_variable_fonts → patch_instance when the wght axis's thin instance coordinates are not 100 — e.g. the design-space weight map was customized so thin maps to another value, or the axis range was changed.","commonSituations":"Editing the weight configuration (weight map / axis ranges) in the build config and setting thin to a non-100 value; regenerating the variable font with a changed wght axis minimum; a mis-merged config producing wrong instance coordinates.","solutions":["Set the thin weight back to 100 in the weight map / fvar instance coordinates configuration.","Verify the wght axis design space starts at 100 for the thin master/instance.","If a different thin weight is intentional, update patch_instance's expectation (the hardcoded 100 check) accordingly.","Diff your config against upstream defaults to find where the thin weight was changed."],"exampleFix":"// before\n# weight_map = {\"thin\": 200, ...}\n// after\n# weight_map = {\"thin\": 100, ...}  # thin must be exactly 100","handlingStrategy":"validation","validationCode":"def assert_thin_is_100(weight_map):\n    if weight_map.get(\"thin\") != 100:\n        raise ValueError(\n            f\"thin weight must be 100 for variable-font patching, got {weight_map.get('thin')}\"\n        )","typeGuard":"def has_valid_weight_axis(all_weight_map: dict) -> bool:\n    return all_weight_map.get(\"thin\") == 100 and all_weight_map.get(\"extrabold\") == 800","tryCatchPattern":"try:\n    build_variable_fonts(...)\nexcept Exception as e:\n    if \"thin\" in str(e) and \"100\" in str(e):\n        print(\"Fix thin weight to 100 in the weight map config\")\n    raise","preventionTips":["Keep the wght axis endpoints at the standard 100..800 in build config.","Validate the weight map against expected values before building.","Diff config changes against upstream defaults when altering weights.","Add a unit check that fvar thin instance coordinates == 100."],"tags":["font","variable-font","weight-axis","config"],"backgroundTag":"invalid-font-weight-value","analyzedSha":"c08fda97fef73d68c1755219852150770f6e6578","analyzedAt":"2026-08-28T22:07:29.503Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}