On Fri, Dec 01, 2006 at 10:17:47AM +0100, Georg Baum wrote:
> According to the qt docs this should be safe: fi.family() is the family of
> the font that gets used. If that matches font.rawName() (which is either
> the requested family or an XLFD or some xft stuff), then that means that
> this font was actually found.
>
> _But_: If we go this way we trust that fi.family() is correct. Then we can
> as well use the attached patch instead. So the question is: Is the comment
> about qt lying in fi.family() still true?
I think that the comment was due to a misunderstanding. When Qt can't
find a requested family it always returns another one, and this could
be interpreted as "lying".
I also tought about reducing the code as you did, but I did not dared...
Maybe your patch could be augmented like the attached?
--
Enrico
Index: src/frontends/qt4/GuiFontLoader.C
===================================================================
--- src/frontends/qt4/GuiFontLoader.C (revision 16123)
+++ src/frontends/qt4/GuiFontLoader.C (working copy)
@@ -131,32 +131,19 @@ bool isSymbolFamily(LyXFont::FONT_FAMILY
bool isChosenFont(QFont & font, string const & family)
{
- lyxerr[Debug::FONT] << "raw: " << fromqstr(font.rawName()) << endl;
-
- QFontInfo fi(font);
// QFontInfo won't find a font that has only a few glyphs at unusual
// positions, e.g. the original esint10 font.
// The workaround is to add dummy glyphs at least at all ASCII
// positions.
+ QFontInfo fi(font);
- // Note Qt lies about family quite often
- lyxerr[Debug::FONT] << "alleged fi family: "
- << fromqstr(fi.family()) << endl;
+ lyxerr[Debug::FONT] << "got: " << fromqstr(fi.family()) << endl;
- // So we check rawName first
- if (contains(fromqstr(font.rawName()), family)) {
+ if (contains(fromqstr(fi.family()), family)) {
lyxerr[Debug::FONT] << " got it ";
return true;
}
- // Qt 4.1 returns "Multi" for all ? xft fonts
- if (font.rawName() == "xft" || font.rawName() == "Multi") {
- if (contains(fromqstr(fi.family()), family)) {
- lyxerr[Debug::FONT] << " got it (Xft) ";
- return true;
- }
- }
-
return false;
}
@@ -177,6 +164,7 @@ pair<QFont, bool> const getSymbolFont(st
return make_pair<QFont, bool>(font, true);
}
+ lyxerr[Debug::FONT] << "Trying " << upper << " ... ";
font.setFamily(toqstr(upper));
if (isChosenFont(font, upper)) {
@@ -186,7 +174,9 @@ pair<QFont, bool> const getSymbolFont(st
// A simple setFamily() fails on Qt 2
- font.setRawName(toqstr(getRawName(family)));
+ string const rawName = getRawName(family);
+ lyxerr[Debug::FONT] << "Trying " << rawName << " ... ";
+ font.setRawName(toqstr(rawName));
if (isChosenFont(font, family)) {
lyxerr[Debug::FONT] << "raw version!" << endl;