Skip to content

Erroneous handling of out of range values on the 'opsz'-axis of variable fonts #340

@fkett

Description

@fkett

For testing purposes, I tried to run this little script using my newly finished variable font. Unsatisfyingly, it did not work as expected (let's be honest: it didn't work at all).

Info: the font has three axes:

  • wght {'name': 'Weight', 'minValue': 100, 'maxValue': 900, 'defaultValue': 400}
  • wdth {'name': 'Width', 'minValue': 75, 'maxValue': 125, 'defaultValue': 100}
  • opsz {'name': 'Optical Size', 'minValue': 16, 'maxValue': 36, 'defaultValue': 16}

After some further research (and simplifying the test setup), I found that DrawBot was only able to use those axis coordinates that were also defined as instances. I checked the font file (very thoroughly) to make sure that everything was according to specification and there were no errors causing this unexpected behaviour. I did find some problems, but even after fixing all of them, I wouldn't get any different results.

Eventually, my second finding was that when I set the optical size value to its minimum (16) or below using the fontVariations() method, it did not work. Some further try and error led me to the conclusion, that DrawBot's variable font axes handling caused the problems:

image

Apparently, DrawBot automatically sets the value for the optical size (opsz) axis according to the specified font size. I had used text with a font size of 60px (which is bigger than the axis' defined maximum value of 36). It seems like DrawBot did not handle this discrepancy correctly: According to the OpenType specification, “if an application specifies a value greater than the maxValue defined in the font, then maxValue must be used”. Instead, the whole variable fonts functionality responded in an unexpectable way.

Conclusion:
example: opsz (16–36, default 16)

Input Expected Behaviour DrawBots behaviour
fontVariations(opsz=8) opsz <- 16 💥
fontVariations(opsz=16) opsz <- 16 💥
fontVariations(opsz=24) opsz <- 24 ✔️
fontVariations(opsz=36) opsz <- 36 ✔️
fontVariations(opsz=48) opsz <- 36 ✔️
fontSize(8) opsz <- 16 💥
fontSize(16) opsz <- 16 ✔️
fontSize(24) opsz <- 24 ✔️
fontSize(36) opsz <- 36 ✔️
fontSize(48) opsz <- 36 💥

There are a few problems, obviously:

  • “error” handling of fontVariations does not work properly
  • “error” handling of fontSize does not work properly
  • fontVariations and fontSize work differently in similar situations
  • “automatic opsz adjustment” functionality is not mentioned in the documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions