Font families are truncated
John F Sturtz
john at sturtz.org
Fri Nov 15 05:12:41 GMT 2024
Alas. Still working in (Py)Qt5. I'm probably stuck with it then.
Thanks.
/John
> Charles <mailto:peacech at gmail.com>
> Thursday, November 14, 2024 10:35 PM
> That is the limitation of using GDI font engine. If you are using
> Qt>=6.7, trying using -platform windows:fontengine=directwrite command
> line parameter.
>
> John F Sturtz <mailto:john at sturtz.org>
> Thursday, November 14, 2024 9:12 PM
> Greetings again!
>
> This is perhaps a bit of an esoteric question.
>
> I am using QFontDatabase and QFont 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 Bahnschrift
> family, for instance -- Bahnschrift SemiBold SemiCondensed,
> Bahnschrift SemiLight SemiCondensed, and so on.
>
> The Windows font settings app lists these with their full names.
> Also, if I query the .ttf file directly:
>
> path = r'C:\Windows\fonts\bahnschrift.ttf'
> font = ttLib.TTFont(path)
> for instance in font["fvar"].instances:
> style = font["name"].getName(instance.subfamilyNameID, 3, 1,
> 0x409)
> print(style)
>
> I get the full names.
>
> However, if I get a list of font families using
> QFontDatabase().families(), the names that are returned are truncated
> to (oddly) 31 characters. So, for example, Bahnschrift SemiBold
> SemiConden, Bahnschrift SemiLight SemiConde, and the like.
>
> And indeed, if I want to create a QFont object for these, I seem to
> need to use the truncated names:
>
> QFont('Bahnschrift SemiBold SemiConden') # These work
> QFont('Bahnschrift SemiLight SemiConde')
>
> QFont('Bahnschrift SemiBold SemiCondensed') # These do not
> QFont('Bahnschrift SemiLight SemiCondensed')
>
> Not a huge 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
> QFontDatabase().families() gave them to me that way). Any thoughts as
> to why?
>
> Thanks again, as always!
>
> /John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20241114/f5b43ceb/attachment-0001.htm>
More information about the PyQt
mailing list