typemytype/drawbot

listNamedInstances return wrong value

Opened this issue · 25 comments

Hi,

I tried recently to get instances name of a variable using listNamedInstances(fontPath)
I tried different variable font (mine and some from Google Font) and the function always return an OrderedDict which contain only the first instance.

Here are some results with Google Fonts :

OpenSans
OrderedDict([('OpenSansRoman-Light', {'wght': 800.0, 'wdth': 75.0})])

Montserrat
OrderedDict([('Montserrat-Thin', {'wght': 900.0})])

Raleway
OrderedDict([('Raleway-Thin', {'wght': 900.0})])

Inter
OrderedDict([('Inter-Regular_Thin', {'wght': 900.0, 'slnt': -10.0})])

I can't reproduce this on macOS 10.15. Which OS are you on?

I'm under macOS Ventura 13.0 and I'm pretty sure it's because of it.
It was working fine before this update.

works fine on Ventura..

image

did you install the fonts? and you dont have any duplicates installed?

Any news about this issue ?
Why print(platform.mac_ver()) return me wrong value ?

Don't worry about the "10.16" oddity that is unlikely to be related. (11 came after 10.15, so in some weird internal way, 10.16 is 11.)

Can you try with a font by using its file path? Like so:

font("/path/to/font/file.ttf")

I did this with every font I tested.
None of them were installed.

Capture d’écran 2023-01-10 à 15 15 05

Note that same font return 2 instances :

Capture d’écran 2023-01-10 à 15 16 41

But @typemytype under Ventura, has the right OS version with the command.
And this bug has appeared after switching on Ventura.

But @typemytype under Ventura, has the right OS version with the command.
And this bug has appeared after switching on Ventura.

You're right, I missed that, and that is very curious after all.

I'm assuming you are using DrawBot 3.128, as downloaded from drawbot.com? Can you see if you get any different results with 3.129?

I already installed DrawBot 3.129.
I tried to uninstall/re-install but nothing changed.

Something also strange if I run :

print(open('/System/Library/CoreServices/SystemVersion.plist').read())

I got this :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>ProductBuildVersion</key>
	<string>22C65</string>
	<key>ProductCopyright</key>
	<string>1983-2022 Apple Inc.</string>
	<key>ProductName</key>
	<string>Mac OS X</string>
	<key>ProductUserVisibleVersion</key>
	<string>10.16</string>
	<key>ProductVersion</key>
	<string>10.16</string>
	<key>iOSSupportVersion</key>
	<string>16.2</string>
</dict>
</plist>

But these infos are wrong. This is a screenshot of this .plist file with Xcode:
Capture d’écran 2023-01-10 à 15 25 40

I have no idea, sorry..

10.16 was Big Sur macOS 11.0 beta at some point

In drawBot, print(sys.version), return :

3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:23:25) 
[Clang 6.0 (clang-600.0.57)]

Where terminal or VSCode return :

3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23) 
[Clang 13.0.0 (clang-1300.0.29.30)]

Clang version is not the same.

I friend under MacOS Monterey (12.5.1) got the same problem.

import sys
import platform

print(sys.version)
print(platform.mac_ver())

FONT = pathtoOpenSans
print(listNamedInstances(FONT))

RETURN

3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:23:25) 
[Clang 6.0 (clang-600.0.57)]
('10.16', ('', '', ''), 'x86_64')
OrderedDict([('OpenSans-Italic', {'wght': 800.0, 'wdth': 75.0})])

We are both using a MacBook Pro M1.
@typemytype are on M1 or Intel ?

Using ttLib, I can have access to all instances :

from fontTools import ttLib

FONT = pathToVariableFont
ft = ttLib.TTFont(FONT, lazy=True, fontNumber=0)
if "fvar" in ft:
    fvar = ft["fvar"]

tagNameMap = {"wght":"Weight", "wdth":"Width"}

for instance in fvar.instances:
    fontVariations = dict()
    for axis, value in instance.coordinates.items():
        fontVariations[tagNameMap[axis]] = value
    print(fontVariations)

Maybe the problem come from CoreText ?

I tested it with another Mac Intel, and I got the same issue.

Capture d’écran 2023-01-10 à 18 21 12

yes M1,

really sorry, I cannot reproduce it...
I just re-tested with the latest DrawBot with a fresh download of OpenSans https://fonts.google.com/download?family=Open%20Sans

image

something really silly: My systems language is set to English

do you see the named instances in other apps when the font is installed?
image

I see named instances in other apps...
It's very weird bug :/

For now, I will manually get the names with fontTools

I just got a second report for the same problem (Cc @martelahaie)

Perhaps CoreText.CGFontCopyPostScriptName is not returning a unique name for each instance, so each instance uses the same key in the instances dict, leaving us with a single entry.

postScriptName = CoreText.CGFontCopyPostScriptName(varFont)
instances[postScriptName] = instance.coordinates

did some digging with @martelahaie and we found out that the OS system language setting seems to be responsible... When she switches from Dutch to English all named instances appear in DrawBot.

@HugoJourdan I assume your system language is French..

this is so silly and I have no idea how to even support this...

@martelahaie is on 12.6 and Im on 13.1 and its is reproducible on both systems

Yes, I'm using French.
Switching to "English" work for me too.