18 #include <QApplication>
20 #include <QFontDatabase>
22 #include <QStringList>
27 QFontInfo fi = QFontInfo( f );
28 return fi.exactMatch();
33 QFont tmpFont = QFont( family );
35 return family.startsWith( tmpFont.family(), Qt::CaseInsensitive );
41 QStringList fontFamilies = fontDB.families();
44 QList<QString>::const_iterator it = fontFamilies.constBegin();
45 for ( ; it != fontFamilies.constEnd(); ++it )
48 if ( it->startsWith( family, Qt::CaseInsensitive ) )
55 *match = ( *it == family );
71 QFont f = QFont( family );
93 if ( fontstyle.isEmpty() )
103 bool hasstyle =
false;
104 foreach (
const QString &style, fontDB.styles( f.family() ) )
106 if ( style == fontstyle )
120 if ( fontstyle == fontDB.styleString( f ) )
125 int defaultSize = QApplication::font().pointSize();
128 bool foundmatch =
false;
130 styledfont = fontDB.font( f.family(), fontstyle, defaultSize );
131 if ( QApplication::font() != styledfont )
138 if ( fallback && !foundmatch )
140 QFont testFont = QFont( f );
141 testFont.setPointSize( defaultSize );
144 foreach (
const QString &style, fontDB.styles( f.family() ) )
146 styledfont = fontDB.font( f.family(), style, defaultSize );
147 styledfont = styledfont.resolve( f );
148 if ( testFont.toString() == styledfont.toString() )
158 foreach (
const QString &style, fontDB.styles( f.family() ) )
160 styledfont = fontDB.font( f.family(), style, defaultSize );
161 if ( QApplication::font() != styledfont )
174 if ( f.pointSizeF() != -1 )
176 styledfont.setPointSizeF( f.pointSizeF() );
178 else if ( f.pixelSize() != -1 )
180 styledfont.setPixelSize( f.pixelSize() );
182 styledfont.setCapitalization( f.capitalization() );
183 styledfont.setUnderline( f.underline() );
184 styledfont.setStrikeOut( f.strikeOut() );
185 styledfont.setWordSpacing( f.wordSpacing() );
186 styledfont.setLetterSpacing( QFont::AbsoluteSpacing, f.letterSpacing() );