drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

[VF] Script fails with KeyError: 'NSCTVariationAxisName'

Open rsms opened this issue 3 years ago • 1 comments

When trying to use a variable font, I get the following error: KeyError: 'NSCTVariationAxisName'

Repro font: Inter.var.ttf.zip

Repro script:

fill(1,1,1)
rect(0, 0, width(), height())
fill(0,0,0)
t = FormattedString(
    font="Inter.var.ttf",
    fontSize=32,
    fontVariations={"wght":400})
t.append("hello")
path = BezierPath()
path.text(t, (width()/2,height()/2))
path.removeOverlap()
drawPath(path)

Error output

Traceback (most recent call last):
  File "vfbug1.py", line 7, in <module>
  File "drawBot/drawBotDrawingTools.pyc", line 1893, in FormattedString
  File "drawBot/context/baseContext.pyc", line 1095, in __init__
  File "drawBot/context/baseContext.pyc", line 1103, in _setAttribute
  File "drawBot/context/baseContext.pyc", line 1610, in fontVariations
  File "drawBot/context/baseContext.pyc", line 1627, in listFontVariations
  File "drawBot/misc.pyc", line 374, in wrapper
  File "drawBot/context/tools/variation.pyc", line 42, in getVariationAxesForFont
  File "objc/_convenience_mapping.pyc", line 18, in __getitem__objectForKey_
  File "objc/_convenience.pyc", line 113, in container_unwrap
KeyError: 'NSCTVariationAxisName'
  • DrawBot 3.128 (3.128)
  • macOS 10.15.7 (19H2026)

rsms avatar Oct 07 '22 22:10 rsms

The problem is that the font doesn't contain the name table IDs that the fvar axes refer to.

The solution is that DrawBot should fall back to the tag in this case.

justvanrossum avatar Oct 08 '22 06:10 justvanrossum