The error message you're encountering:
fontTools.varLib.errors.VariationModelError: Base master not found.
indicates that the VariationModel in the FontTools library cannot find a "base master" among the provided master positions. This "base master" is essential for interpolation and must have all axis values set to zero (the origin of the design space).
Understanding the Error:
- Base Master: In font interpolation, the base master serves as the default or starting point. It's the master font from which variations are calculated along different axes (e.g., weight, width). The base master should be located at the origin point of the design space, where all axis values are zero.
- VariationModel: When you create a
VariationModel, it requires a list of master positions (locations in the design space). If none of these positions correspond to the origin (all zeros), the model cannot determine which master to use as the base.
Why This Error Occurs:
You likely supplied a list of master_positions to models.VariationModel, but none of these positions is at the origin (i.e., {axis1: 0, axis2: 0, ...}). Without this base master, the interpolation cannot proceed, leading to the error.
How to Fix It:
-
Ensure a Base Master Is Provided:
- Verify that one of your masters is designated as the base master.
- This master should have all its axis coordinates set to zero.
-
Modify Master Positions:
- If you have a master that represents the "default" style but its coordinates are not zeros, adjust its position in the
master_positions list.
- For example, if your axes are
"weight" and "width", the base master should be at {"weight": 0, "width": 0}.
-
Adjust Axis Definitions:
- Check your axis definitions to ensure that zero corresponds to the default or base value.
- If your design space doesn't naturally have a master at zero, you may need to adjust the axis mappings or redefine the axes so that zero represents the base master.
Example Solution:
Suppose you have the following masters and positions:
master_positions = [
{"weight": -1.0}, # Light master
{"weight": 1.0}, # Bold master
]
In this setup, there's no master at {"weight": 0}. You need to add or designate a master at the origin:
master_positions = [
{"weight": -1.0}, # Light master
{"weight": 0.0}, # Regular master (Base master)
{"weight": 1.0}, # Bold master
]
Ensure that the glyph data for this base master is included in your masters list.
Additional Tips:
- Consistency: Make sure all masters have consistent glyph sets and that their outlines are compatible for interpolation.
- Axis Defaults: In your font's axis definitions, explicitly set the default value to zero for each axis, reinforcing that zero is the base.
- Validation: Use tools or scripts to validate that your masters are correctly set up before interpolation.
References:
- FontTools Documentation: Review the FontTools documentation for
VariationModel to understand how it expects master positions.
- Understanding Variations: Familiarize yourself with OpenType Font Variations to grasp the concepts of axes, masters, and the design space.
Conclusion:
By ensuring that a base master at the origin is included in your master_positions, the VariationModel should be able to proceed without errors. Double-check your masters and axes to align with this requirement.
If you continue to experience issues, please provide additional details about your master configurations, and I can offer more specific guidance.