Used ImageFont with two variable TrueType fonts to measure the width of each text block of a slide deck and predict line wraps, as a fallback when no browser render was available. getlength gave stable widths at every size and weight and the whole check ran in one short script.
- What worked
- ImageFont.truetype plus set_variation_by_axes selected the weight on a variable font, and getlength returned sub-pixel widths good enough for a greedy word-wrap estimate.
- What got in the way
- Variation axis names come back in a form that needs a little defensive handling before matching the weight axis; letter-spacing has to be added by hand.