drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

listNamedInstances return wrong value

Open HugoJourdan opened this issue 2 years ago • 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})])

HugoJourdan avatar Dec 17 '22 17:12 HugoJourdan

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

justvanrossum avatar Dec 19 '22 09:12 justvanrossum

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

HugoJourdan avatar Dec 19 '22 10:12 HugoJourdan

works fine on Ventura..

image

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

typemytype avatar Dec 19 '22 13:12 typemytype

There is something strange, print(platform.mac_ver()), return me 10.16 instead of 13.0

[image: Capture d’écran 2022-12-19 à 14.16.44.png]

Le lun. 19 déc. 2022 à 14:10, Frederik Berlaen @.***> a écrit :

works fine on Ventura..

[image: image] https://user-images.githubusercontent.com/1190358/208433139-28658e0d-a5fd-4473-8462-9cc6ac960895.png

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

— Reply to this email directly, view it on GitHub https://github.com/typemytype/drawbot/issues/495#issuecomment-1357644602, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASJ4QX4BCMRM5WNKKOEXVE3WOBNCTANCNFSM6AAAAAATCBUGPA . You are receiving this because you authored the thread.Message ID: @.***>

-- *Hugo Jourdan * [ Type Designer ] & [ Font Engineer ] Paris, France Instagram https://www.instagram.com/hjxdesign – Behance https://www.behance.net/Hugo_Jourdan – GitHub https://github.com/HugoJourdan

HugoJourdan avatar Dec 19 '22 13:12 HugoJourdan

I tried to run the same command in VSCode and in Terminal both return me correct OS Version:

[image: Capture d’écran 2022-12-19 à 14.42.22.png]

Le lun. 19 déc. 2022 à 14:18, Hugo Jourdan @.***> a écrit :

There is something strange, print(platform.mac_ver()), return me 10.16 instead of 13.0

[image: Capture d’écran 2022-12-19 à 14.16.44.png]

Le lun. 19 déc. 2022 à 14:10, Frederik Berlaen @.***> a écrit :

works fine on Ventura..

[image: image] https://user-images.githubusercontent.com/1190358/208433139-28658e0d-a5fd-4473-8462-9cc6ac960895.png

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

— Reply to this email directly, view it on GitHub https://github.com/typemytype/drawbot/issues/495#issuecomment-1357644602, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASJ4QX4BCMRM5WNKKOEXVE3WOBNCTANCNFSM6AAAAAATCBUGPA . You are receiving this because you authored the thread.Message ID: @.***>

-- *Hugo Jourdan * [ Type Designer ] & [ Font Engineer ] Paris, France Instagram https://www.instagram.com/hjxdesign – Behance https://www.behance.net/Hugo_Jourdan – GitHub https://github.com/HugoJourdan

-- *Hugo Jourdan * [ Type Designer ] & [ Font Engineer ] Paris, France Instagram https://www.instagram.com/hjxdesign – Behance https://www.behance.net/Hugo_Jourdan – GitHub https://github.com/HugoJourdan

HugoJourdan avatar Dec 19 '22 13:12 HugoJourdan

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

HugoJourdan avatar Jan 10 '23 14:01 HugoJourdan

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")

justvanrossum avatar Jan 10 '23 14:01 justvanrossum

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

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

HugoJourdan avatar Jan 10 '23 14:01 HugoJourdan

Note that same font return 2 instances :

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

HugoJourdan avatar Jan 10 '23 14:01 HugoJourdan

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

HugoJourdan avatar Jan 10 '23 14:01 HugoJourdan

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?

justvanrossum avatar Jan 10 '23 14:01 justvanrossum

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

HugoJourdan avatar Jan 10 '23 14:01 HugoJourdan

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

HugoJourdan avatar Jan 10 '23 14:01 HugoJourdan

I have no idea, sorry..

10.16 was Big Sur macOS 11.0 beta at some point

typemytype avatar Jan 10 '23 15:01 typemytype

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.

HugoJourdan avatar Jan 10 '23 15:01 HugoJourdan

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 ?

HugoJourdan avatar Jan 10 '23 16:01 HugoJourdan

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 ?

HugoJourdan avatar Jan 10 '23 17:01 HugoJourdan

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

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

HugoJourdan avatar Jan 10 '23 17:01 HugoJourdan

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

typemytype avatar Jan 10 '23 20:01 typemytype

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

typemytype avatar Jan 10 '23 20:01 typemytype

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

For now, I will manually get the names with fontTools

HugoJourdan avatar Jan 11 '23 10:01 HugoJourdan

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.

https://github.com/typemytype/drawbot/blob/60952e5db162aaae260ac83c3f7838c94771b2e2/drawBot/context/tools/variation.py#L85-L86

justvanrossum avatar Feb 14 '23 14:02 justvanrossum

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...

typemytype avatar Feb 15 '23 16:02 typemytype

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

typemytype avatar Feb 15 '23 16:02 typemytype

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

HugoJourdan avatar Feb 15 '23 17:02 HugoJourdan