<html theme="themeKey23rand818" iconset="color"><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body
text="#194869">
Greetings again!<br>
<br>
This is perhaps a bit of an esoteric question.<br>
<br>
I am using <span style="font-family: monospace;">QFontDatabase</span>
and <span style="font-family: monospace;">QFont</span> to query and
manipulate some display fonts. On my system, there are some font
family/variant combinations that have pretty long names. Several in the
<span style="font-style: italic;">Bahnschrift</span> family, for
instance -- <span style="font-style: italic;">Bahnschrift SemiBold SemiCondensed,
Bahnschrift SemiLight SemiCondensed, </span>and so on.<span
style="font-style: italic;"></span><span style="font-style: italic;"></span><br>
<br>
The Windows font settings app lists these with their full names. Also,
if I query the <span style="font-family: monospace;">.ttf</span> file
directly:<br>
<br>
<span style="font-family: monospace;"> path =
r'C:\Windows\fonts\bahnschrift.ttf'</span><span style="font-family:
monospace;"><br>
</span><span style="font-family: monospace;"> font =
ttLib.TTFont(path)</span><span style="font-family: monospace;"><br>
</span><span style="font-family: monospace;"> for instance in
font["fvar"].instances:</span><span style="font-family: monospace;"><br>
</span><span style="font-family: monospace;"> style =
font["name"].getName(instance.subfamilyNameID, 3, 1, 0x409)</span><span
style="font-family: monospace;"><br>
</span><span style="font-family: monospace;"> print(style)</span><span
style="font-family: monospace;"><br>
</span><br>
I get the full names.<br>
<br>
However, if I get a list of font families using <span
style="font-family: monospace;">QFontDatabase().families()</span>, the
names that are returned are truncated to (oddly) 31 characters. So, for
example, <span style="font-style: italic;">Bahnschrift SemiBold
SemiConden, Bahnschrift SemiLight SemiConde, </span>and the like.<br>
<br>
And indeed, if I want to create a <span style="font-family: monospace;">QFont</span>
object for these, I seem to need to use the truncated names:<br>
<br>
<span style="font-family: monospace;">QFont('Bahnschrift SemiBold
SemiConden')</span><span style="font-family: monospace;"> # These
work<br>
</span><span style="font-family: monospace;">QFont('Bahnschrift
SemiLight Semi</span><span style="font-family: monospace;">Conde')</span><span
style="font-family: monospace;"><br>
</span><br>
<span style="font-family: monospace;"><span style="font-family:
monospace;">QFont('Bahnschrift SemiBold SemiCondensed') # These do
not</span><span style="font-family: monospace;"><br>
</span><span style="font-family: monospace;">QFont('Bahnschrift
SemiLight Semi</span><span style="font-family: monospace;">Condensed')</span><span
style="font-family: monospace;"><br>
</span></span><br>
Not a <span style="font-family: monospace;"><span style="font-style:
italic;">huge</span></span> deal, but it's a little difficult, because
the names PyQt seems to recognize aren't the ones I'd want to present to
the user (nor ones I would have thought to use, but for the fact that <span
style="font-family: monospace;">QFontDatabase(</span><span
style="font-family: monospace;">).families()</span> gave them to me that
way). Any thoughts as to why?<br>
<br>
Thanks again, as always!<br>
<br>
/John<br>
<span style="font-family: monospace;"></span>
</body>
</html>