# HG changeset patch # User Edouard Tisserant # Date 1617197407 -7200 # Node ID d6d002766a93b0e0b0ee2f83c189cf14d249305c # Parent da2481f359b7da6f5470b1ad617dd30d4a96cc3b# Parent bb314cdfc656e0c4bb5fdb421c3f88cc4cb7e38d merge diff -r bb314cdfc656 -r d6d002766a93 svghmi/fonts.py --- a/svghmi/fonts.py Wed Mar 31 09:08:15 2021 +0200 +++ b/svghmi/fonts.py Wed Mar 31 15:30:07 2021 +0200 @@ -7,10 +7,15 @@ # See COPYING file for copyrights details. from __future__ import print_function +import sys from base64 import b64encode from fontTools import ttLib +# Inkscape seems to refer to font with different family name depending on platform. +# this are heuristics that would need extensive testing to be sure. +FamilyNameIDs = [1] if sys.platform.startswith('win') else [1, 16] + def GetFontTypeAndFamilyName(filename): """ Getting font family, format and MIME type @@ -24,7 +29,8 @@ font = ttLib.TTFont(filename) # https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html for name in font["name"].names: - if name.nameID in [1,16] and name.platformID==3 and name.langID==1033: + #print(name.nameID, name.platformID, name.langID, name.toUnicode()) + if name.nameID in FamilyNameIDs and name.platformID==3 and name.langID==1033: familyname = name.toUnicode() if name.nameID==4 and name.platformID==3 and name.langID==1033: uniquename = name.toUnicode()