drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

Feature variations do not work in multistyle Formatted String

Open djrrb opened this issue 4 years ago • 13 comments

I’m having some trouble where feature variations (in the opentype rvrn feature) are not applied when used in a multi-style formatted string.

I’ve included some code below to demonstrate the problem with Service Gothic’s $, but I’ve tested it in multiple fonts so I’m guessing you’ll be able to replicate this with the feature variation of your choice.

You can see that the bar of the dollar sign should be cut out in the Bold, but when it is appended to the Formatted String, the cut out doesn’t happen. The result doesn’t change if openTypeFeatures=dict(rvrn=True) is applied.

I am running Drawbot Version 3.126 on MacOS Catalina 10.15.7. I’ve also seen instances where this error seems to create bugs in letterspacing if the first variant is wider than the second... If helpful, l’m happy to email a font of mine where that happens.

As always, many thanks!

Screenshot showing my results of demo code: Screen Shot 2021-03-29 at 2 02 40 PM

Demo code:

fontPath = 'Service_Gothic_v0.1_Variable.ttf'
textString = '$$$\n'

# using a formatted string, and appending the new style
# it doesn’t work
newPage()
fs = FormattedString(textString, fontSize=250, font=fontPath, fontVariations=dict(wght=400))
fs.append('$$$', fontVariations=dict(wght=700), openTypeFeatures=dict(rvrn=True))
textBox(fs, (0, 0, width(), height()))

# using a formatted string, and appending the new style
# it works
newPage()
fs = FormattedString(textString*2, fontSize=250, font=fontPath, fontVariations=dict(wght=700))
textBox(fs, (0, 0, width(), height()))

# this page has multiple styles but does not use formatted string
newPage()
font(fontPath, 250)
fontVariations(wght=400)
textBox(textString, (0, 0, width(), height()))
fontVariations(wght=700)
textBox(textString, (0, 0, width(), height()-300))

Demo code showing spacing issue:

fs = FormattedString(
    font='Job Clarendon Variable',
    fontSize=400,
    )
fs.append('iinii\n', fontVariations=dict(wght=900))

fs.append('iinii\n', fontVariations=dict(wght=400))

textBox(fs, (0, 0, width(), height()))
Screen Shot 2021-03-29 at 2 01 25 PM

djrrb avatar Mar 29 '21 18:03 djrrb

I would love to test this with the actual font, if possible.

There have been some (yet unreleased) changes to how fonts from paths are loaded, which may or may not influence this behavior (#421).

justvanrossum avatar Mar 29 '21 18:03 justvanrossum

Emailed!

djrrb avatar Mar 29 '21 18:03 djrrb

Thanks! Bug confirmed with latest dev version of DB, on 10.15.7.

It could be an OS bug.

justvanrossum avatar Mar 29 '21 18:03 justvanrossum

Oh I think you might be right @justvanrossum, see what happens when I try to apply multiple styles in TextEdit, at least here on Catalina...

https://user-images.githubusercontent.com/6578861/112884855-ff27dd80-909d-11eb-8806-611377b5faba.mov

djrrb avatar Mar 29 '21 18:03 djrrb

Urgh :(

Btw the problem is reproducible with MutatorSans as well, with its barred/unbarred cap I.

size(900, 250)

fontPath = 'MutatorSans-VF.ttf'

fs = FormattedString()
fs.fontSize(200)
fs.font(fontPath)

fs.fontVariations(wdth=380)
fs.fontVariations()
fs.append('III')

fs.fontVariations(wdth=70)
fs.fontVariations()
fs.append('III')

text(fs, (50, 50))

Font: https://github.com/LettError/mutatorSans/blob/master/MutatorSans-VF.ttf

justvanrossum avatar Mar 29 '21 18:03 justvanrossum

If anyone can test this on Big Sur, that would be fantastic!

justvanrossum avatar Mar 29 '21 18:03 justvanrossum

your MutatorSans example on macOS10.13:

image

this is as it should be.

typemytype avatar Mar 29 '21 19:03 typemytype

Oh wow, things actually got worse...

justvanrossum avatar Mar 29 '21 19:03 justvanrossum

I'm so tired of Apple VF/rvrn bugs.

justvanrossum avatar Mar 29 '21 19:03 justvanrossum

on macOS 10.16 aka macOS11

image

typemytype avatar Mar 29 '21 19:03 typemytype

those are serious bugs in CoreText...

also see https://github.com/typemytype/drawbot/issues/332 (which worked perfectly on 10.13 but not newer OSs)

typemytype avatar Mar 29 '21 19:03 typemytype

Nuts.

justvanrossum avatar Mar 29 '21 19:03 justvanrossum

Confirming this behavior on macOS 11.3 Beta (20E5217a) which is the latest version available (AFAIK) Screen Shot 2021-03-29 at 23 17 23

frankrolf avatar Mar 29 '21 21:03 frankrolf