<html><head><style id="css_styles" type="text/css"><!--blockquote.cite { margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc }
blockquote.cite2 {margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc; margin-top: 3px; padding-top: 0px; }
a img { border: 0px; }
table { border-collapse: collapse; }
li[style='text-align: center;'], li[style='text-align: center; '], li[style='text-align: right;'], li[style='text-align: right; '] {  list-style-position: inside;}
body { font-family: 'Segoe UI'; font-size: 12pt; }
.quote { margin-left: 1em; margin-right: 1em; border-left: 5px #ebebeb solid; padding-left: 0.3em; }
a.em-mention[href] { text-decoration: none; color: inherit; border-radius: 3px; padding-left: 2px; padding-right: 2px; background-color: #e2e2e2; }
--></style></head><body><div><span>Thanks again guys!  This has been a fascinating journey, and I've learned a lot.</span></div><div><span><br /></span></div><div>My rationale for wondering if one could determine whether a font is variable or static was this:  I don't seem to have trouble calling <font face="Consolas">.setItalic()</font> on the static fonts -- that seems to work fine.  Although as Charles pointed out, if the font in question has an Italic style option, the Italic version I get from requesting that style sometimes differs slightly in appearance from the synthesized oblique I get from <font face="Consolas" size="3" style="font-size: 16px;">.setItalic()</font>.  But at least it seems to work.  It's only when I use <font face="Consolas" size="3" style="font-size: 16px;">.setItalic()</font> on variable fonts that things seem to go awry.  So I thought at least if I could distinguish between the two, I could take a stab at handling them differently.</div><div><br /></div><div>Interestingly, Maurizio, your idea seems to work.  A variable font should have an <font face="Consolas" size="3" style="font-size: 16px;">'avar'</font> (axis variations) table.  Testing on the fonts I have installed (including a couple additional variable fonts I added from Google fonts, just to add to the pile):</div><div><br /></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font face="Consolas" size="3" style="font-size: 16px;">f = QFontDatabase.font(family, style, size)
</font></div><div><font face="Consolas" size="3" style="font-size: 16px;">q = QtGui.QRawFont.fromFont(f)
</font></div><div><font face="Consolas" size="3" style="font-size: 16px;">v = q.fontTable('avar')</font></div></blockquote><div><br /></div><div>results in <font face="Consolas" style="font-size: 16px;" size="3">v</font> being <font face="Consolas" size="3" style="font-size: 16px;">True</font> (a non-null byte sequence) for the variable fonts, and <font face="Consolas" size="3" style="font-size: 16px;">False</font> (<font face="Consolas" size="3" style="font-size: 16px;">b''</font>) for the static fonts.  Whether I'll ever succeed in making any use of that fact remains to be seen, but it's interesting.</div><div><br /></div><div>In case you're wondering what I'm up to, I'm trying to create a font picker dialog for an app I'm working on (the same app, BTW, that I was working on when Maurizio first answered a question for me in 2019).  The idea is to allow the user to choose the font for various display items in the app window.</div><div><br /></div><div>As such, I only use fonts that have been given to me by <font face="Consolas" size="3" style="font-size: 16px;">QFontDatabase</font>.  I <i>think</i> that means that what I ask for with <font face="Consolas" size="3" style="font-size: 16px;">QFont()</font> and what I get, as reported by <font face="Consolas" size="3" style="font-size: 16px;">QFontInfo()</font>, should be the same.  I hope, since I'm not asking for anything <font face="Consolas" size="3" style="font-size: 16px;">QFontDatabase</font> hasn't already told me was there.</div><div><br /></div><div>And while I maybe wouldn't have described it as an endless journey into hell (yet), it would be fair to say it has proven to be an arduous task so far.  ðŸ˜</div><div><br /></div><div>Thanks again for the help.  This gives me a lot to chew on.  Learning all the time ...</div><div><br /></div><div>/John</div><div><span><br /></span></div><div><span>------ Original Message ------</span></div><div>
<div>From "Maurizio Berti" <<a href="mailto:maurizio.berti@gmail.com">maurizio.berti@gmail.com</a>></div>
<div>To "Charles" <<a href="mailto:peacech@gmail.com">peacech@gmail.com</a>></div>
<div>Cc "John Sturtz" <<a href="mailto:john@sturtz.org">john@sturtz.org</a>>; <a href="mailto:pyqt@riverbankcomputing.com">pyqt@riverbankcomputing.com</a></div>
<div>Date 1/11/2025 8:41:25 PM</div>
<div>Subject Re: Re[8]: QFontDatabase/QFont question</div></div><div x-em-quote=""><br /></div>
<div id="x264702309418407"><blockquote cite="CAPn+-XTtE81-C4uAwc6jX9iJ8GeuUXeFDwjCKraYV9AmOOAC9w@mail.gmail.com" type="cite" class="cite2">
<div dir="ltr"><div class="gmail_quote gmail_quote_container" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class="gmail_attr">Il giorno dom 12 gen 2025 alle ore 03:04 Charles <<a href="mailto:peacech@gmail.com">peacech@gmail.com</a>> ha scritto:<br /></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif;font-size:small">variableAxisTags displays the tags that you have set, not the available tags for the font.</div></div></blockquote></div><div class="gmail_quote gmail_quote_container"><br /></div><div class="gmail_quote gmail_quote_container">I was afraid of that.</div><div class="gmail_quote gmail_quote_container"><br /></div><div class="gmail_quote gmail_quote_container">Yet, a few hours ago I remembered about QRawFont, and I just found out that a <span style="font-family:monospace"><a href="https://doc.qt.io/qt-6/qrawfont.html#fontTable">QRawFont.fontTable()</a></span> function has been introduced as well since 6.7 (you can access a QRawFont object through the static <span style="font-family:monospace">QRawFont.fromFont()</span>).<br /></div><div class="gmail_quote gmail_quote_container">As said, I haven't had the opportunity to test variable fonts, so the above may still fall into the case mentioned by Charles.<br /></div><div class="gmail_quote gmail_quote_container">Still, it's worth a shot.<br /><br /></div><div class="gmail_quote gmail_quote_container">If it still doesn't provide valid results, and as long as nobody else finds a more simple and reliable way to check if a font has variable features, you may consider filing a feature request ("Suggestion" in the "Issue Type" field) on the Qt bug tracker. Assuming it's actually possible.</div><div class="gmail_quote gmail_quote_container"><br /></div><div class="gmail_quote gmail_quote_container">Just keep in mind that a QFont instance is more of an abstraction layer, and <b>does not</b> intrinsically represent a specific font.</div><div class="gmail_quote gmail_quote_container">From the description in its <a href="https://doc.qt.io/qt-6/qfont.html#details">documentation</a> (emphasis mine):<br /></div><div><br /></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>QFont can be regarded as a <b>query</b> for <b>one or more</b> fonts on the system.</div></blockquote><div><br /></div><div>That's why QFontMetrics also provides a constructor that is based on a given paint device, which may give different results based on that device and its capabilities.</div><div>Font management is tricky (especially for cross-platform aspects), and the variable font support introduced since 6.7 is relatively new.</div><div>We may need some time until all these aspects are properly addressed, and filing <i>proper</i> reports may be a good thing to carefully consider.<br /><br /></div><div>And don't forget that font/text layout and management is an endless journey into hell...<br /></div><div><br /></div><div>Cheers,<br /></div><div class="gmail_quote gmail_quote_container">MaurizioB<br /></div><div class="gmail_quote gmail_quote_container"><br /></div><span class="gmail_signature_prefix">-- </span><br /><div dir="ltr" class="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br /><a href="http://www.jidesk.net">http://www.jidesk.net</a></div></div>
</blockquote></div>
</body></html>