1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QFontDatabase Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QFontDatabase Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QFontDatabase class provides information about the fonts available in the underlying window system. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qfontdatabase.html#WritingSystem-enum">WritingSystem</a></b> { Any, Latin, Greek, Cyrillic, ..., WritingSystemsCount }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qfontdatabase.html#QFontDatabase">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qfontdatabase.html#QFontDatabase-2">__init__</a></b> (<i>self</i>, QFontDatabase)</li><li><div class="fn" />bool <b><a href="qfontdatabase.html#bold">bold</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i>)</li><li><div class="fn" />QStringList <b><a href="qfontdatabase.html#families">families</a></b> (<i>self</i>, WritingSystem <i>writingSystem</i> = QFontDatabase.Any)</li><li><div class="fn" />QFont <b><a href="qfontdatabase.html#font">font</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i>, int <i>pointSize</i>)</li><li><div class="fn" />bool <b><a href="qfontdatabase.html#isBitmapScalable">isBitmapScalable</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i> = QString())</li><li><div class="fn" />bool <b><a href="qfontdatabase.html#isFixedPitch">isFixedPitch</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i> = QString())</li><li><div class="fn" />bool <b><a href="qfontdatabase.html#isScalable">isScalable</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i> = QString())</li><li><div class="fn" />bool <b><a href="qfontdatabase.html#isSmoothlyScalable">isSmoothlyScalable</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i> = QString())</li><li><div class="fn" />bool <b><a href="qfontdatabase.html#italic">italic</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i>)</li><li><div class="fn" />int-list <b><a href="qfontdatabase.html#pointSizes">pointSizes</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i> = QString())</li><li><div class="fn" />int-list <b><a href="qfontdatabase.html#smoothSizes">smoothSizes</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i>)</li><li><div class="fn" />QStringList <b><a href="qfontdatabase.html#styles">styles</a></b> (<i>self</i>, QString <i>family</i>)</li><li><div class="fn" />QString <b><a href="qfontdatabase.html#styleString">styleString</a></b> (<i>self</i>, QFont <i>font</i>)</li><li><div class="fn" />QString <b><a href="qfontdatabase.html#styleString-2">styleString</a></b> (<i>self</i>, QFontInfo <i>fontInfo</i>)</li><li><div class="fn" />int <b><a href="qfontdatabase.html#weight">weight</a></b> (<i>self</i>, QString <i>family</i>, QString <i>style</i>)</li><li><div class="fn" />QFontDatabase.WritingSystem-list <b><a href="qfontdatabase.html#writingSystems">writingSystems</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />int-list <b><a href="qfontdatabase.html#standardSizes">standardSizes</a></b> ()</li><li><div class="fn" />QString <b><a href="qfontdatabase.html#writingSystemName">writingSystemName</a></b> (WritingSystem <i>writingSystem</i>)</li><li><div class="fn" />QString <b><a href="qfontdatabase.html#writingSystemSample">writingSystemSample</a></b> (WritingSystem <i>writingSystem</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QFontDatabase class provides information about the fonts available in the underlying window system.</p>
<p>The most common uses of this class are to query the database for the list of font <a href="qfontdatabase.html#families">families</a>() and for the <a href="qfontdatabase.html#pointSizes">pointSizes</a>() and <a href="qfontdatabase.html#styles">styles</a>() that are available for each family. An alternative to <a href="qfontdatabase.html#pointSizes">pointSizes</a>() is <a href="qfontdatabase.html#smoothSizes">smoothSizes</a>() which returns the sizes at which a given family and style will look attractive.</p>
<p>If the font family is available from two or more foundries the foundry name is included in the family name, e.g. "Helvetica [Adobe]" and "Helvetica [Cronyx]". When you specify a family you can either use the old hyphenated Qt 2.x "foundry-family" format, e.g. "Cronyx-Helvetica", or the new bracketed Qt 3.x "family [foundry]" format e.g. "Helvetica [Cronyx]". If the family has a foundry it is always returned, e.g. by <a href="qfontdatabase.html#families">families</a>(), using the bracketed format.</p>
<p>The <a href="qfontdatabase.html#font">font</a>() function returns a <a href="qfont.html">QFont</a> given a family, style and point size.</p>
<p>A family and style combination can be checked to see if it is <a href="qfontdatabase.html#italic">italic</a>() or <a href="qfontdatabase.html#bold">bold</a>(), and to retrieve its <a href="qfontdatabase.html#weight">weight</a>(). Similarly we can call <a href="qfontdatabase.html#isBitmapScalable">isBitmapScalable</a>(), <a href="qfontdatabase.html#isSmoothlyScalable">isSmoothlyScalable</a>(), <a href="qfontdatabase.html#isScalable">isScalable</a>() and <a href="qfontdatabase.html#isFixedPitch">isFixedPitch</a>().</p>
<p>Use the <a href="qfontdatabase.html#styleString">styleString</a>() to obtain a text version of a style.</p>
<p>The QFontDatabase class also supports some static functions, for example, <a href="qfontdatabase.html#standardSizes">standardSizes</a>(). You can retrieve the description of a writing system using <a href="qfontdatabase.html#writingSystemName">writingSystemName</a>(), and a sample of characters in a writing system with <a href="qfontdatabase.html#writingSystemSample">writingSystemSample</a>().</p>
<p>Example:</p>
<pre>
#include <qapplication.h>
#include <qfontdatabase.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QFontDatabase fdb;
QStringList families = fdb.families();
for (QStringList.Iterator f = families.begin(); f != families.end(); ++f) {
QString family = *f;
qDebug(family);
QStringList styles = fdb.styles(family);
for (QStringList.Iterator s = styles.begin(); s != styles.end(); ++s) {
QString style = *s;
QString dstyle = "\t" + style + " (";
QList<int> smoothies = fdb.smoothSizes(family, style);
for (QList<int>.Iterator points = smoothies.begin();
points != smoothies.end(); ++points) {
dstyle += QString.number(*points) + " ";
}
dstyle = dstyle.left(dstyle.length() - 1) + ")";
qDebug(dstyle);
}
}
return 0;
}
</pre>
<p>This example gets the list of font families, then the list of styles for each family and the point sizes that are available for each family/style combination.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="WritingSystem-enum" />QFontDatabase.WritingSystem</h3><table border="1" cellpadding="2" cellspacing="1" width="40%">
<tr>
<th width="60%">Constant</th>
<th width="40%">Value</th>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Any</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Latin</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Greek</tt></td>
<td align="center" valign="top"><tt>2</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Cyrillic</tt></td>
<td align="center" valign="top"><tt>3</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Armenian</tt></td>
<td align="center" valign="top"><tt>4</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Hebrew</tt></td>
<td align="center" valign="top"><tt>5</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Arabic</tt></td>
<td align="center" valign="top"><tt>6</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Syriac</tt></td>
<td align="center" valign="top"><tt>7</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Thaana</tt></td>
<td align="center" valign="top"><tt>8</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Devanagari</tt></td>
<td align="center" valign="top"><tt>9</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Bengali</tt></td>
<td align="center" valign="top"><tt>10</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Gurmukhi</tt></td>
<td align="center" valign="top"><tt>11</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Gujarati</tt></td>
<td align="center" valign="top"><tt>12</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Oriya</tt></td>
<td align="center" valign="top"><tt>13</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Tamil</tt></td>
<td align="center" valign="top"><tt>14</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Telugu</tt></td>
<td align="center" valign="top"><tt>15</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Kannada</tt></td>
<td align="center" valign="top"><tt>16</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Malayalam</tt></td>
<td align="center" valign="top"><tt>17</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Sinhala</tt></td>
<td align="center" valign="top"><tt>18</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Thai</tt></td>
<td align="center" valign="top"><tt>19</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Lao</tt></td>
<td align="center" valign="top"><tt>20</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Tibetan</tt></td>
<td align="center" valign="top"><tt>21</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Myanmar</tt></td>
<td align="center" valign="top"><tt>22</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Georgian</tt></td>
<td align="center" valign="top"><tt>23</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Khmer</tt></td>
<td align="center" valign="top"><tt>24</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.SimplifiedChinese</tt></td>
<td align="center" valign="top"><tt>25</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.TraditionalChinese</tt></td>
<td align="center" valign="top"><tt>26</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Japanese</tt></td>
<td align="center" valign="top"><tt>27</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Korean</tt></td>
<td align="center" valign="top"><tt>28</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Vietnamese</tt></td>
<td align="center" valign="top"><tt>29</tt></td>
</tr>
<tr>
<td valign="top"><tt>QFontDatabase.Other</tt></td>
<td align="center" valign="top"><tt>30</tt></td>
</tr>
</table>
<br />
<br />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QFontDatabase" />QFontDatabase.__init__ (<i>self</i>)</h3><p>Creates a font database object.</p>
<h3 class="fn"><a name="QFontDatabase-2" />QFontDatabase.__init__ (<i>self</i>, <a href="qfontdatabase.html">QFontDatabase</a>)</h3><h3 class="fn"><a name="bold" />bool QFontDatabase.bold (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i>)</h3><p>Returns true if the font that has family <i>family</i> and style <i>style</i> is bold; otherwise returns false.</p>
<p>See also <a href="qfontdatabase.html#italic">italic</a>() and <a href="qfontdatabase.html#weight">weight</a>().</p>
<h3 class="fn"><a name="families" /><a href="qstringlist.html">QStringList</a> QFontDatabase.families (<i>self</i>, <a href="qfontdatabase.html#WritingSystem-enum">WritingSystem</a> <i>writingSystem</i> = QFontDatabase.Any)</h3><p>Returns a sorted list of the available font families which support the <i>writingSystem</i>.</p>
<p>If a family exists in several foundries, the returned name for that font is in the form "family [foundry]". Examples: "Times [Adobe]", "Times [Cronyx]", "Palatino".</p>
<p>See also <a href="qfontdatabase.html#writingSystems">writingSystems</a>().</p>
<h3 class="fn"><a name="font" /><a href="qfont.html">QFont</a> QFontDatabase.font (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i>, int <i>pointSize</i>)</h3><p>Returns a <a href="qfont.html">QFont</a> object that has family <i>family</i>, style <i>style</i> and point size <i>pointSize</i>. If no matching font could be created, a <a href="qfont.html">QFont</a> object that uses the application's default font is returned.</p>
<h3 class="fn"><a name="isBitmapScalable" />bool QFontDatabase.isBitmapScalable (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i> = QString())</h3><p>Returns true if the font that has family <i>family</i> and style <i>style</i> is a scalable bitmap font; otherwise returns false. Scaling a bitmap font usually produces an unattractive hardly readable result, because the pixels of the font are scaled. If you need to scale a bitmap font it is better to scale it to one of the fixed sizes returned by <a href="qfontdatabase.html#smoothSizes">smoothSizes</a>().</p>
<p>See also <a href="qfontdatabase.html#isScalable">isScalable</a>() and <a href="qfontdatabase.html#isSmoothlyScalable">isSmoothlyScalable</a>().</p>
<h3 class="fn"><a name="isFixedPitch" />bool QFontDatabase.isFixedPitch (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i> = QString())</h3><p>Returns true if the font that has family <i>family</i> and style <i>style</i> is fixed pitch; otherwise returns false.</p>
<h3 class="fn"><a name="isScalable" />bool QFontDatabase.isScalable (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i> = QString())</h3><p>Returns true if the font that has family <i>family</i> and style <i>style</i> is scalable; otherwise returns false.</p>
<p>See also <a href="qfontdatabase.html#isBitmapScalable">isBitmapScalable</a>() and <a href="qfontdatabase.html#isSmoothlyScalable">isSmoothlyScalable</a>().</p>
<h3 class="fn"><a name="isSmoothlyScalable" />bool QFontDatabase.isSmoothlyScalable (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i> = QString())</h3><p>Returns true if the font that has family <i>family</i> and style <i>style</i> is smoothly scalable; otherwise returns false. If this function returns true, it's safe to scale this font to any size, and the result will always look attractive.</p>
<p>See also <a href="qfontdatabase.html#isScalable">isScalable</a>() and <a href="qfontdatabase.html#isBitmapScalable">isBitmapScalable</a>().</p>
<h3 class="fn"><a name="italic" />bool QFontDatabase.italic (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i>)</h3><p>Returns true if the font that has family <i>family</i> and style <i>style</i> is italic; otherwise returns false.</p>
<p>See also <a href="qfontdatabase.html#weight">weight</a>() and <a href="qfontdatabase.html#bold">bold</a>().</p>
<h3 class="fn"><a name="pointSizes" />int-list QFontDatabase.pointSizes (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i> = QString())</h3><p>Returns a list of the point sizes available for the font that has family <i>family</i> and style <i>style</i>. The list may be empty.</p>
<p>See also <a href="qfontdatabase.html#smoothSizes">smoothSizes</a>() and <a href="qfontdatabase.html#standardSizes">standardSizes</a>().</p>
<h3 class="fn"><a name="smoothSizes" />int-list QFontDatabase.smoothSizes (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i>)</h3><p>Returns the point sizes of a font that has family <i>family</i> and style <i>style</i> that will look attractive. The list may be empty. For non-scalable fonts and bitmap scalable fonts, this function is equivalent to <a href="qfontdatabase.html#pointSizes">pointSizes</a>().</p>
<p>See also <a href="qfontdatabase.html#pointSizes">pointSizes</a>() and <a href="qfontdatabase.html#standardSizes">standardSizes</a>().</p>
<h3 class="fn"><a name="standardSizes" />int-list QFontDatabase.standardSizes ()</h3><p>Returns a list of standard font sizes.</p>
<p>See also <a href="qfontdatabase.html#smoothSizes">smoothSizes</a>() and <a href="qfontdatabase.html#pointSizes">pointSizes</a>().</p>
<h3 class="fn"><a name="styles" /><a href="qstringlist.html">QStringList</a> QFontDatabase.styles (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>)</h3><p>Returns a list of the styles available for the font family <i>family</i>. Some example styles: "Light", "Light Italic", "Bold", "Oblique", "Demi". The list may be empty.</p>
<p>See also <a href="qfontdatabase.html#families">families</a>().</p>
<h3 class="fn"><a name="styleString" /><a href="qstring.html">QString</a> QFontDatabase.styleString (<i>self</i>, <a href="qfont.html">QFont</a> <i>font</i>)</h3><p>Returns a string that describes the style of the <i>font</i>. For example, "Bold Italic", "Bold", "Italic" or "Normal". An empty string may be returned.</p>
<h3 class="fn"><a name="styleString-2" /><a href="qstring.html">QString</a> QFontDatabase.styleString (<i>self</i>, <a href="qfontinfo.html">QFontInfo</a> <i>fontInfo</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns a string that describes the style of the <i>fontInfo</i>. For example, "Bold Italic", "Bold", "Italic" or "Normal". An empty string may be returned.</p>
<h3 class="fn"><a name="weight" />int QFontDatabase.weight (<i>self</i>, <a href="qstring.html">QString</a> <i>family</i>, <a href="qstring.html">QString</a> <i>style</i>)</h3><p>Returns the weight of the font that has family <i>family</i> and style <i>style</i>. If there is no such family and style combination, returns -1.</p>
<p>See also <a href="qfontdatabase.html#italic">italic</a>() and <a href="qfontdatabase.html#bold">bold</a>().</p>
<h3 class="fn"><a name="writingSystemName" /><a href="qstring.html">QString</a> QFontDatabase.writingSystemName (<a href="qfontdatabase.html#WritingSystem-enum">WritingSystem</a> <i>writingSystem</i>)</h3><p>Returns the names the <i>writingSystem</i> (e.g. for displaying to the user in a dialog).</p>
<h3 class="fn"><a name="writingSystems" />QFontDatabase.WritingSystem-list QFontDatabase.writingSystems (<i>self</i>)</h3><p>Returns a sorted list of the available writing systems. This is list generated from information about all installed fonts on the system.</p>
<p>See also <a href="qfontdatabase.html#families">families</a>().</p>
<h3 class="fn"><a name="writingSystemSample" /><a href="qstring.html">QString</a> QFontDatabase.writingSystemSample (<a href="qfontdatabase.html#WritingSystem-enum">WritingSystem</a> <i>writingSystem</i>)</h3><p>Returns a string with sample characters from <i>writingSystem</i>.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|