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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QFont Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QFont Class Reference</h1><br clear="all">
<p>
The QFont class specifies a font used for drawing text.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qfont-h.html">qfont.h</a>></code>
<p><a href="qfont-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn">enum<a href="#CharSet"><b>CharSet</b></a>{ISO_8859_1, Latin1=ISO_8859_1, AnyCharSet, ISO_8859_2, Latin2=ISO_8859_2, ISO_8859_3, Latin3=ISO_8859_3, ISO_8859_4, Latin4=ISO_8859_4, ISO_8859_5, ISO_8859_6, ISO_8859_7, ISO_8859_8, ISO_8859_9, Latin5=ISO_8859_9, ISO_8859_10, Latin6=ISO_8859_10, ISO_8859_11, TIS620=ISO_8859_11, ISO_8859_12, ISO_8859_13, Latin7=ISO_8859_13, ISO_8859_14, Latin8=ISO_8859_14, ISO_8859_15, Latin9=ISO_8859_15, KOI8R, Set_Ja, Set_1=Set_Ja, Set_Ko, Set_Th_TH, Set_Zh, Set_Zh_TW, Set_N=Set_Zh_TW, Unicode, Set_GBK, Set_Big5, TSCII, KOI8U, CP1251, PT154, JIS_X_0201=0xa0, JIS_X_0208=0xc0, Enc16=JIS_X_0208, KSC_5601, GB_2312, Big5}</div>
<li><div class="fn">enum<a href="#StyleHint"><b>StyleHint</b></a>{Helvetica, Times, Courier, OldEnglish, System, AnyStyle, SansSerif=Helvetica, Serif=Times, TypeWriter=Courier, Decorative=OldEnglish}</div>
<li><div class="fn">enum<a href="#StyleStrategy"><b>StyleStrategy</b></a>{PreferDefault=0x0001, PreferBitmap=0x0002, PreferDevice=0x0004, PreferOutline=0x0008, ForceOutline=0x0010, PreferMatch=0x0020, PreferQuality=0x0040}</div>
<li><div class="fn">enum<a href="#Weight"><b>Weight</b></a>{Light=25, Normal=50, DemiBold=63, Bold=75, Black=87}</div>
<li><div class="fn"><a href="#166b44"><b>QFont</b></a>()</div>
<li><div class="fn"><a href="#1f53d7"><b>QFont</b></a>(constQString&family, intpointSize=12, intweight=Normal, boolitalic=FALSE)</div>
<li><div class="fn"><a href="#c16381"><b>QFont</b></a>(constQString&family, intpointSize, intweight, boolitalic, CharSetcharSet)</div>
<li><div class="fn"><a href="#da97b1"><b>QFont</b></a>(constQFont&)</div>
<li><div class="fn"><a href="#d2eb71"><b>~QFont</b></a>()</div>
<li><div class="fn">QFont&<a href="#256d8f"><b>operator=</b></a>(constQFont&)</div>
<li><div class="fn">QString<a href="#cb6c0d"><b>family</b></a>()const</div>
<li><div class="fn">void<a href="#0e588e"><b>setFamily</b></a>(constQString&)</div>
<li><div class="fn">int<a href="#46f238"><b>pointSize</b></a>()const</div>
<li><div class="fn">float<a href="#47a8a2"><b>pointSizeFloat</b></a>()const</div>
<li><div class="fn">void<a href="#fd77c1"><b>setPointSize</b></a>(int)</div>
<li><div class="fn">void<a href="#05a74f"><b>setPointSizeFloat</b></a>(float)</div>
<li><div class="fn">int<a href="#f82f15"><b>pixelSize</b></a>()const</div>
<li><div class="fn">void<a href="#9d3b04"><b>setPixelSize</b></a>(int)</div>
<li><div class="fn">void<a href="#7641e4"><b>setPixelSizeFloat</b></a>(float)</div>
<li><div class="fn">int<a href="#41db89"><b>weight</b></a>()const</div>
<li><div class="fn">void<a href="#5d7ef1"><b>setWeight</b></a>(int)</div>
<li><div class="fn">bool<a href="#30083e"><b>bold</b></a>()const</div>
<li><div class="fn">void<a href="#ec241e"><b>setBold</b></a>(bool)</div>
<li><div class="fn">bool<a href="#b38bfa"><b>italic</b></a>()const</div>
<li><div class="fn">void<a href="#b6af25"><b>setItalic</b></a>(bool)</div>
<li><div class="fn">bool<a href="#34e94b"><b>underline</b></a>()const</div>
<li><div class="fn">void<a href="#c11804"><b>setUnderline</b></a>(bool)</div>
<li><div class="fn">bool<a href="#d8d538"><b>strikeOut</b></a>()const</div>
<li><div class="fn">void<a href="#1caefc"><b>setStrikeOut</b></a>(bool)</div>
<li><div class="fn">bool<a href="#f13eeb"><b>fixedPitch</b></a>()const</div>
<li><div class="fn">void<a href="#b238aa"><b>setFixedPitch</b></a>(bool)</div>
<li><div class="fn">StyleHint<a href="#634c0c"><b>styleHint</b></a>()const</div>
<li><div class="fn">void<a href="#7beece"><b>setStyleHint</b></a>(StyleHint)</div>
<li><div class="fn">StyleStrategy<a href="#a2c708"><b>styleStrategy</b></a>()const</div>
<li><div class="fn">void<a href="#b6f3c6"><b>setStyleHint</b></a>(StyleHint, StyleStrategy)</div>
<li><div class="fn">CharSet<a href="#dec730"><b>charSet</b></a>()const</div>
<li><div class="fn">void<a href="#50bb8c"><b>setCharSet</b></a>(CharSet)</div>
<li><div class="fn">bool<a href="#95a609"><b>rawMode</b></a>()const</div>
<li><div class="fn">void<a href="#ed26f0"><b>setRawMode</b></a>(bool)</div>
<li><div class="fn">bool<a href="#5423b2"><b>exactMatch</b></a>()const</div>
<li><div class="fn">bool<a href="#ce5bfb"><b>operator==</b></a>(constQFont&)const</div>
<li><div class="fn">bool<a href="#7348ad"><b>operator!=</b></a>(constQFont&)const</div>
<li><div class="fn">bool<a href="#d2f2bc"><b>isCopyOf</b></a>(constQFont&)const</div>
<li><div class="fn">void<a href="#d8a345"><b>setRawName</b></a>(constQString&)</div>
<li><div class="fn">QString<a href="#7ab1bb"><b>rawName</b></a>()const</div>
<li><div class="fn">QString<a href="#c8326c"><b>key</b></a>()const</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">CharSet<a href="#363f71"><b>charSetForLocale</b></a>()</div>
<li><div class="fn">QString<a href="#29cca8"><b>encodingName</b></a>(CharSet)</div>
<li><div class="fn">QFont<a href="#600c69"><b>defaultFont</b></a>()</div>
<li><div class="fn">voidsetDefaultFont(constQFont&)<em>(obsolete)</em></div>
<li><div class="fn">QString<a href="#d37712"><b>substitute</b></a>(constQString&familyName)</div>
<li><div class="fn">void<a href="#785f7e"><b>insertSubstitution</b></a>(constQString&, constQString&)</div>
<li><div class="fn">void<a href="#42b145"><b>removeSubstitution</b></a>(constQString&)</div>
<li><div class="fn">QStringList<a href="#b4855d"><b>substitutions</b></a>()</div>
<li><div class="fn">void<a href="#6aabdc"><b>initialize</b></a>()</div>
<li><div class="fn">void<a href="#961298"><b>locale_init</b></a>()</div>
<li><div class="fn">void<a href="#1f684f"><b>cleanup</b></a>()</div>
<li><div class="fn">void<a href="#fab5c0"><b>cacheStatistics</b></a>()</div>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class="fn">bool<a href="#24341b"><b>dirty</b></a>()const</div>
<li><div class="fn">QString<a href="#177b67"><b>defaultFamily</b></a>()const</div>
<li><div class="fn">QString<a href="#463f65"><b>lastResortFamily</b></a>()const</div>
<li><div class="fn">QString<a href="#52d1a5"><b>lastResortFont</b></a>()const</div>
<li><div class="fn">int<a href="#1853fc"><b>deciPointSize</b></a>()const</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QDataStream & <a href="qfont.html#43d253"><b>operator<<</b></a> (QDataStream & s, const QFont & f)
<li>QDataStream & <a href="qfont.html#6848d3"><b>operator>></b></a> (QDataStream & s, QFont & f)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QFont class specifies a font used for drawing text.
<p>
QFont, more precisely, is a collection of attributes of a font.
When Qt needs to draw text, it will look up and load the closest
matching installed font and draw using that.
<p>The most important attributes of a QFont are its <a href="#cb6c0d">family</a>(),
<a href="#46f238">pointSize</a>(), <a href="#41db89">weight</a>() and whether it is <a href="#b38bfa">italic</a>() or not. There are
QFont constructors that take these attributes as arguments, as shown
in this example:
<p><pre> void MyWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * )
{
<a href="qpainter.html">QPainter</a> p( this );
// times, 12pt, normal
p.<a href="qpainter.html#998df2">setFont</a>( <a href="qfont.html">QFont</a>( "times" ) );
p.<a href="qpainter.html#0f088f">drawText</a>( 10, 20, "Text1" );
// helvetica, 18pt, normal
p.<a href="qpainter.html#998df2">setFont</a>( <a href="qfont.html">QFont</a>( "helvetica", 18 ) );
p.<a href="qpainter.html#0f088f">drawText</a>( 10, 120, "Text2" );
// courier, 24pt, bold
p.<a href="qpainter.html#998df2">setFont</a>( <a href="qfont.html">QFont</a>( "courier", 24, QFont::Bold ) );
p.<a href="qpainter.html#0f088f">drawText</a>( 10, 220, "Text3" );
// lucida, 36pt, bold, italic
p.<a href="qpainter.html#998df2">setFont</a>( <a href="qfont.html">QFont</a>( "lucida", 36, QFont::Bold, TRUE ) );
p.<a href="qpainter.html#0f088f">drawText</a>( 10, 320, "Text4" );
}
</pre>
<p>The default QFont constructor makes a copy of application's default
font, <a href="qapplication.html#f31495">QApplication::font</a>().
<p>You can also change these attributes of an existing QFont object
using functions such as <a href="#0e588e">setFamily</a>(), <a href="#fd77c1">setPointSize</a>(), <a href="#5d7ef1">setWeight</a>() and
<a href="#b6af25">setItalic</a>().
<p>There are also some less-used attributes. <a href="#c11804">setUnderline</a>() decides
whether the font is underlined or not; <a href="#1caefc">setStrikeOut</a>() can be used to get
overstrike (a horizontal line through the middle of the characters);
<a href="#b238aa">setFixedPitch</a>() determines whether Qt should give preference to
fixed-pitch (also known as fixed-width) or variable-pitch fonts when it
needs to choose an installed font; <a href="#7beece">setStyleHint</a>() can be used to offer
more general help to the font matching algorithm, and on X11
<a href="#d8a345">setRawName</a>() can be used to bypass the entire font matching and use an
X11 XLFD.
<p>Of course there is also a reader function for each of these set*()
functions. Note that the reader functions return the values
previously set, <em>not</em> the attributes of the actual window system
font that will be used for drawing. You can get information about
the font that will be used for drawing by using <a href="qfontinfo.html">QFontInfo</a>, but be
aware that QFontInfo may be slow and that its results depend on what
fonts are installed.
<p>In general font handling and loading are costly operations,
especially on X11. The QFont class contains extensive optimizations
to make copying of QFont objects fast, and to cache the results of
the slow window system functions it uses.
<p>QFont also offers a few static functions, mostly to tune the font
matching algorithm: You can control what happens if a font's family
isn't installed using <a href="#785f7e">insertSubstitution</a>() and <a href="#42b145">removeSubstitution</a>(),
ask what happens for a single family using <a href="#d37712">substitute</a>() and you can
get a complete list of the fallback families using <a href="#b4855d">substitutions</a>().
<p><a href="#fab5c0">cacheStatistics</a>() offers cache effectiveness information; this is
useful mostly for debugging.
<p>Finally, <a href="qapplication.html#3d926a">QApplication::setFont</a>() allows you to set the default font.
The default default font is chosen at application startup from a set
of common installed fonts that support the correct character set for
the current locale. Of course, the initialization algorithm has a
default, too: The default default default font!
<p>The font matching algorithm works as follows:
<p>First an available font family is found. If the requested is not
available the <a href="#634c0c">styleHint</a>() is used to select a replacement family. If
the style hint has not been set, "helvetica" will be used.
<p>If even the replacement family is not found, "helvetica" is searched
for, if that too is not found Qt will search for a last resort font,
i.e. a specific font to match to, ignoring the attribute
settings. Qt searches through a built-in list of very common
fonts. If none of these are available, Qt gives you an error message
and aborts (of course this only happens if you are using fonts and
Qt <em>has</em> to load a font). We have not been able to find a case
where this happens. Please <a href="bughowto.html">report it as a
bug</a> if it does, preferably with a list of the fonts you have
installed.
<p>The following attributes are then matched, in order of priority: <ol>
<li> <a href="#dec730">charSet</a>()
<li> <a href="#f13eeb">fixedPitch</a>()
<li> pointSize() (see below)
<li> weight()
<li> italic()
</ol>
<p>If, for example, a font with the correct character set is found, but
with all other attributes in the list unmatched, it will be chosen
before a font with the wrong character set but with all other
attributes correct.
<p>The point size is defined to match if it is within 20% of the
requested point size. Of course, when several fonts match and only
point size differs the closest point size to the one requested will
be chosen.
<p>For more general information on fonts, see the
<a href="http://www.nwalsh.com/comp.fonts/FAQ/">comp.fonts FAQ</a>
and for more general information on encodings, see
<a href="http://czyborra.com/charsets/">Roman Czyborra's page</a>
about that.
<p>See also <a href="qfontmetrics.html">QFontMetrics</a>, <a href="qfontinfo.html">QFontInfo</a>, <a href="qapplication.html#3d926a">QApplication::setFont</a>(), <a href="qwidget.html#090d60">QWidget::setFont</a>(), <a href="qpainter.html#998df2">QPainter::setFont</a>(), <a href="#StyleHint">QFont::StyleHint</a>, <a href="#CharSet">QFont::CharSet</a> and <a href="#Weight">QFont::Weight</a>.
<p>Examples:
<a href="showimg-main-cpp.html#QFont">showimg/main.cpp</a>
<a href="grapher-grapher-cpp.html#QFont">grapher/grapher.cpp</a>
<a href="xform-xform-cpp.html#QFont">xform/xform.cpp</a>
<a href="i18n-main-cpp.html#QFont">i18n/main.cpp</a>
<a href="drawdemo-drawdemo-cpp.html#QFont">drawdemo/drawdemo.cpp</a>
<a href="menu-menu-cpp.html#QFont">menu/menu.cpp</a>
<a href="desktop-desktop-cpp.html#QFont">desktop/desktop.cpp</a>
<a href="scrollview-scrollview-cpp.html#QFont">scrollview/scrollview.cpp</a>
<a href="qfd-qfd-cpp.html#QFont">qfd/qfd.cpp</a>
<a href="movies-main-cpp.html#QFont">movies/main.cpp</a>
<a href="picture-picture-cpp.html#QFont">picture/picture.cpp</a>
<a href="hello-main-cpp.html#QFont">hello/main.cpp</a>
<hr><h2>Member Type Documentation</h2>
<h3 class="fn"><a name="CharSet">QFont::CharSet</a></h3>
The following character set encodings are available: <ul>
<li> <code>QFont::ISO_8859_1</code> - Latin1 , common in much of Europe
<li> <code>QFont::ISO_8859_2</code> - Latin2, Central and Eastern European character set
<li> <code>QFont::ISO_8859_3</code> - Latin3, less common European character set
<li> <code>QFont::ISO_8859_4</code> - Latin4, less common European character set
<li> <code>QFont::ISO_8859_5,</code> Cyrillic
<li> <code>QFont::ISO_8859_6,</code> Arabic
<li> <code>QFont::ISO_8859_7,</code> Greek
<li> <code>QFont::ISO_8859_8,</code> Hebrew
<li> <code>QFont::ISO_8859_9,</code> Turkish
<li> <code>QFont::ISO_8859_10..15,</code> other ISO 8859 characters sets
<li> <code>QFont::KOI8R</code> - KOI8-R, Cyrillic, defined in
<a href="ftp://ftp.nordu.net/rfc/rfc1489.txt">RFC 1489.</a>
<li> <code>QFont::KOI8U</code> - KOI8-U, Cyrillic/Ukrainian, defined in
<a href="ftp://ftp.nordu.net/rfc/rfc2319.txt">RFC 2319.</a>
<li> <code>QFont::CP1251,</code> Microsoft Cyrillic encoding
<li> <code>QFont::PT154,</code> Paratype Asian Cyrillic encoding
<li> <code>QFont::AnyCharSet</code> - whatever is handiest.
<li> <code>QFont::Set_Ja,</code> Japanese
<li> <code>QFont::Set_Ko,</code> Korean
<li> <code>QFont::Set_Th_TH</code>
<li> <code>QFont::Set_Zh</code>
<li> <code>QFont::Set_Zh_TW</code>
<li> <code>QFont::Unicode,</code> Unicode character set
<li> <code>QFont::Set_GBK</code>
<li> <code>QFont::Set_Big5</code>
</ul>
<h3 class="fn"><a name="StyleHint">QFont::StyleHint</a></h3>
Style hints are used by the font matching algorithm when a selected
font family cannot be found and is used to find an appropriate
default family.
<p>The style hint value of <code>AnyStyle</code> leaves the task of finding a
good default family to the font matching algorithm.
<p>The other available style hints are <code>QFont::SansSerif, QFont::TypeWriter, QFont::OldEnglish, QFont::System</code>
<h3 class="fn"><a name="StyleStrategy">QFont::StyleStrategy</a></h3>
The style strategy tells the font matching algorithm what type
of fonts should be used to find an appropriate default family.
<p>The algorithm won't prefer any type of font if <code>NoStratgie</code> is
provided.
<p>The other available strategys are <code>QFont::PreferBitmap, QFont::PreferDevice, QFont::PreferOutline, QFont::ForceOutline</code>
<p>Any of these may be ORed with a indicator whether exact matching or
good quality should be preferred.
<p><code>QFont::PreferMatch, QFont::PreferQuality</code>
<h3 class="fn"><a name="Weight">QFont::Weight</a></h3>
Contains the predefined font weights:<ul>
<li> <code>QFont::Light</code> (25)
<li> <code>QFont::Normal</code> (50)
<li> <code>QFont::DemiBold</code> (63)
<li> <code>QFont::Bold</code> (75)
<li> <code>QFont::Black</code> (87)
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="166b44"></a>QFont::QFont()</h3>
<p>Constructs a font object that refers to the default font.
<p>See also <a href="qapplication.html#3d926a">QApplication::setFont</a>() and <a href="qapplication.html#f31495">QApplication::font</a>().
<h3 class="fn"><a name="1f53d7"></a>QFont::QFont(const<a href="qstring.html">QString</a>&family, intpointSize=12, intweight=Normal, boolitalic=FALSE)</h3>
<p>Constructs a font object with the specified <em>family, pointSize, weight</em> and <em>italic</em> settings. The <a href="#dec730">charSet</a>() is copied from the
<a href="qapplication.html#f31495">default font</a> and the rest of the
settings are set reasonably.
<p>If <em>pointSize</em> is less than or equal to 0 it is set to 1.
<p>See also <a href="#0e588e">setFamily</a>(), <a href="#fd77c1">setPointSize</a>(), <a href="#5d7ef1">setWeight</a>() and <a href="#b6af25">setItalic</a>().
<h3 class="fn"><a name="c16381"></a>QFont::QFont(const<a href="qstring.html">QString</a>&family, intpointSize, intweight, boolitalic, <a href="qfont.html#CharSet">CharSet</a>charSet)</h3>
<p>Constructs a font object with the specified <em>family, pointSize, weight, italic</em> and <em>charSet</em> settings. If <em>pointSize</em> is
less than or equal to 0 it is set to 1.
<p>See also <a href="#0e588e">setFamily</a>(), <a href="#fd77c1">setPointSize</a>(), <a href="#5d7ef1">setWeight</a>() and <a href="#b6af25">setItalic</a>().
<h3 class="fn"><a name="da97b1"></a>QFont::QFont(constQFont&font)</h3>
<p>Constructs a font that is a copy of <em>font.</em>
<h3 class="fn"><a name="d2eb71"></a>QFont::~QFont()</h3>
<p>Destructs the font object.
<h3 class="fn">bool<a name="30083e"></a>QFont::bold()const</h3>
<p>Returns TRUE if <a href="#41db89">weight</a>() is a value greater than <code>QFont::Normal,</code>
otherwise FALSE.
<p>See also <a href="#41db89">weight</a>(), <a href="#ec241e">setBold</a>() and <a href="qfontinfo.html#85b956">QFontInfo::bold</a>().
<h3 class="fn">void<a name="fab5c0"></a>QFont::cacheStatistics() <code>[static]</code></h3>
<p>Internal function that dumps font cache statistics.
<h3 class="fn">QFont::CharSet<a name="dec730"></a>QFont::charSet()const</h3>
<p>Returns the character set by <a href="#50bb8c">setCharSet</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the <a href="#CharSet">CharSet</a> of the window system font actually used.
<p>See also <a href="#50bb8c">setCharSet</a>().
<h3 class="fn">QFont::CharSet<a name="363f71"></a>QFont::charSetForLocale() <code>[static]</code></h3>
<p>Returns a guess at the character set most likely to be
appropriate for the locale the application is running in. This is
the character sets fonts will use by default.
<h3 class="fn">void<a name="1f684f"></a>QFont::cleanup() <code>[static]</code></h3>
<p>Internal function that cleans up the font system.
<h3 class="fn">int<a name="1853fc"></a>QFont::deciPointSize()const <code>[protected]</code></h3>
<p>Returns the point size in 1/10ths of a point.
<p>See also <a href="#46f238">pointSize</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="177b67"></a>QFont::defaultFamily()const <code>[protected]</code></h3>
<p>Returns the family name that corresponds to the current style hint.
<h3 class="fn">QFont<a name="600c69"></a>QFont::defaultFont() <code>[static]</code></h3>
<p>Returns the <a href="qapplication.html">QApplication</a> default font.
<p>This function will be removed in a future version of Qt. Please use
<a href="qapplication.html#f31495">QApplication::font</a>() instead.
<h3 class="fn">bool<a name="24341b"></a>QFont::dirty()const <code>[protected]</code></h3>
<p>Returns TRUE if the font attributes have been changed and the font has to
be (re)loaded, or FALSE if no changes have been made.
<h3 class="fn"><a href="qstring.html">QString</a><a name="29cca8"></a>QFont::encodingName(<a href="qfont.html#CharSet">CharSet</a>cs) <code>[static]</code></h3>
<p>Returns the encoding name of a character set, e.g. QFont::ISO_8859_1
returns "iso8859-1" and QFont::Unicode returns "iso10646".
<h3 class="fn">bool<a name="5423b2"></a>QFont::exactMatch()const</h3>
<p>Returns TRUE if a window system font exactly matching the settings
of this font is available.
<p>See also <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn"><a href="qstring.html">QString</a><a name="cb6c0d"></a>QFont::family()const</h3>
<p>Returns the family name set by <a href="#0e588e">setFamily</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the family name of the window system font that
is actually used for drawing.
<p>Example:
<pre> <a href="qfont.html">QFont</a> font( "Nairobi" );
<a href="qfontinfo.html">QFontInfo</a> info( font );
<a href="qapplication.html#72e78c">qDebug</a>( "Font family requested is : \"%s\"", font.<a href="#cb6c0d">family</a>() );
<a href="qapplication.html#72e78c">qDebug</a>( "Font family actually used is: \"%s\"", info.<a href="qfontinfo.html#643714">family</a>() );
</pre>
<p>See also <a href="#0e588e">setFamily</a>() and <a href="#d37712">substitute</a>().
<h3 class="fn">bool<a name="f13eeb"></a>QFont::fixedPitch()const</h3>
<p>Returns the value set by <a href="#b238aa">setFixedPitch</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the fixed pitch value of the window system font
actually used.
<p>See also <a href="#b238aa">setFixedPitch</a>() and <a href="qfontinfo.html#b0ce63">QFontInfo::fixedPitch</a>().
<h3 class="fn">void<a name="6aabdc"></a>QFont::initialize() <code>[static]</code></h3>
<p>Internal function that initializes the font system.
<h3 class="fn">void<a name="785f7e"></a>QFont::insertSubstitution(const<a href="qstring.html">QString</a>&familyName, const<a href="qstring.html">QString</a>&replacementName) <code>[static]</code></h3>
<p>Inserts a new font family name substitution in the family substitution
table.
<p>If <em>familyName</em> already exists in the substitution table, it will
be replaced with this new substitution.
<p>See also <a href="#42b145">removeSubstitution</a>(), <a href="#b4855d">substitutions</a>() and <a href="#d37712">substitute</a>().
<h3 class="fn">bool<a name="d2f2bc"></a>QFont::isCopyOf(constQFont&f)const</h3>
<p>Returns TRUE if this font and <em>f</em> are copies of each other,
i.e. one of them was created as a copy of the other and neither was
subsequently modified. This is much stricter than equality.
<p>See also operator= and operator==.
<h3 class="fn">bool<a name="b38bfa"></a>QFont::italic()const</h3>
<p>Returns the value set by <a href="#b6af25">setItalic</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the italic value of the window system font actually
used.
<p>See also <a href="#b6af25">setItalic</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="c8326c"></a>QFont::key()const</h3>
<p>Returns the font's key, which is a textual representation of the font
settings. It is typically used to insert and find fonts in a
dictionary or a cache.
<p>See also <a href="qmap.html">QMap</a>.
<h3 class="fn"><a href="qstring.html">QString</a><a name="463f65"></a>QFont::lastResortFamily()const <code>[protected]</code></h3>
<p>Returns a last resort family name for the font matching algorithm.
<p>See also <a href="#52d1a5">lastResortFont</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="52d1a5"></a>QFont::lastResortFont()const <code>[protected]</code></h3>
<p>Returns a last resort raw font name for the font matching algorithm.
This is used if even the last resort family is not available. It
returns <em>something,</em> almost no matter what.
<p>The current implementation tries a wide variety of common fonts,
returning the first one it finds. The implementation may change at
any time.
<p>See also <a href="#463f65">lastResortFamily</a>().
<h3 class="fn">void<a name="961298"></a>QFont::locale_init() <code>[static]</code></h3>
<p>Internal function that uses locale information to find the preferred
character set of loaded fonts.
<h3 class="fn">bool<a name="7348ad"></a>QFont::operator!=(constQFont&f)const</h3>
<p>Returns TRUE if the this font is different from <em>f,</em> or FALSE if they are
equal.
<p>Two QFonts are different if their font attributes are different. If
<a href="#95a609">rawMode</a>() is enabled for both fonts, then only the family fields are
compared.
<p>See also <a href="#ce5bfb">operator==</a>().
<h3 class="fn">QFont&<a name="256d8f"></a>QFont::operator=(constQFont&font)</h3>
<p>Assigns <em>font</em> to this font and returns a reference to this font.
<h3 class="fn">bool<a name="ce5bfb"></a>QFont::operator==(constQFont&f)const</h3>
<p>Returns TRUE if the this font is equal to <em>f,</em> or FALSE if they are
different.
<p>Two QFonts are equal if their font attributes are equal. If
<a href="#95a609">rawMode</a>() is enabled for both fonts, then only the family fields are
compared.
<p>See also <a href="#7348ad">operator!=</a>().
<h3 class="fn">int<a name="f82f15"></a>QFont::pixelSize()const</h3>
<p>Returns the logical pixel height of characters in the font if shown on
the screen.
<h3 class="fn">int<a name="46f238"></a>QFont::pointSize()const</h3>
<p>Returns the point size set by <a href="#fd77c1">setPointSize</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the point size of the window system font
actually used.
<p>Example of use:
<pre> <a href="qfont.html">QFont</a> font( "helvetica" );
<a href="qfontinfo.html">QFontInfo</a> info( font );
font.<a href="#fd77c1">setPointSize</a>( 53 );
<a href="qapplication.html#72e78c">qDebug</a>( "Font size requested is : %d", font.<a href="#46f238">pointSize</a>() );
<a href="qapplication.html#72e78c">qDebug</a>( "Font size actually used is: %d", info.<a href="qfontinfo.html#391046">pointSize</a>() );
</pre>
<p>See also <a href="#fd77c1">setPointSize</a>() and <a href="#1853fc">deciPointSize</a>().
<h3 class="fn">float<a name="47a8a2"></a>QFont::pointSizeFloat()const</h3>
<p>Returns the height of characters in the font in points (1/72 inch).
<p>See also <a href="#46f238">pointSize</a>().
<h3 class="fn">bool<a name="95a609"></a>QFont::rawMode()const</h3>
<p>Returns the value set by <a href="#ed26f0">setRawMode</a>().
<p>See also <a href="#ed26f0">setRawMode</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="7ab1bb"></a>QFont::rawName()const</h3>
<p>Returns the name of the font within the underlying window system.
On Windows, this is usually just the family name of a true type
font. Under X, it is a rather complex XLFD (X Logical Font
Description). Using the return value of this function is usually <em>not portable.</em>
<p>See also <a href="#d8a345">setRawName</a>().
<h3 class="fn">void<a name="42b145"></a>QFont::removeSubstitution(const<a href="qstring.html">QString</a>&familyName) <code>[static]</code></h3>
<p>Removes a font family name substitution from the family substitution
table.
<p>See also <a href="#785f7e">insertSubstitution</a>(), <a href="#b4855d">substitutions</a>() and <a href="#d37712">substitute</a>().
<h3 class="fn">void<a name="ec241e"></a>QFont::setBold(boolenable)</h3>
<p>Sets the weight to <code>QFont::Bold</code> if <em>enable</em> is TRUE, or to
<code>QFont::Normal</code> if <em>enable</em> is FALSE.
<p>Use <a href="#5d7ef1">setWeight</a>() to set the weight to other values.
<p>See also <a href="#30083e">bold</a>() and <a href="#5d7ef1">setWeight</a>().
<p>Examples:
<a href="menu-menu-cpp.html#setBold">menu/menu.cpp</a>
<h3 class="fn">void<a name="50bb8c"></a>QFont::setCharSet(<a href="qfont.html#CharSet">CharSet</a>charset)</h3>
<p>Sets the character set encoding (e.g. <code>Latin1).</code>
<p>If the character set encoding is not available another will be used
for drawing. For most non-trivial applications you will probably
not want this to happen since it can totally obscure the text shown
to the user. This is why the font matching algorithm gives high
priority to finding the correct character set.
<p>You can test that the character set is correct using the <a href="qfontinfo.html">QFontInfo</a>
class.
<p>See also <a href="#dec730">charSet</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">void<a name="e044ef"></a>QFont::setDefaultFont(constQFont&f) <code>[static]</code></h3>
<p><b>This function is obsolete.</b> It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.<p>
<p>Please use <a href="qapplication.html#3d926a">QApplication::setFont</a>() instead.
<h3 class="fn">void<a name="0e588e"></a>QFont::setFamily(const<a href="qstring.html">QString</a>&family)</h3>
<p>Sets the family name of the font (e.g. "Helvetica" or "times").
<p>The family name is case insensitive.
<p>If the family is not available a default family is used.
<p>See also <a href="#cb6c0d">family</a>(), <a href="#7beece">setStyleHint</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">void<a name="b238aa"></a>QFont::setFixedPitch(boolenable)</h3>
<p>Sets fixed pitch on or off.
<p>A fixed pitch font is a font where all characters have the same width.
<p>See also <a href="#f13eeb">fixedPitch</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">void<a name="b6af25"></a>QFont::setItalic(boolenable)</h3>
<p>Sets italic on or off.
<p>See also <a href="#b38bfa">italic</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">void<a name="9d3b04"></a>QFont::setPixelSize(intpixelSize)</h3>
<p>Sets the logical height of characters in the font if shown on
the screen.
<h3 class="fn">void<a name="7641e4"></a>QFont::setPixelSizeFloat(floatpixelSize)</h3>
<p>Sets the logical pixel height of characters in the font if shown on
the screen.
<h3 class="fn">void<a name="fd77c1"></a>QFont::setPointSize(intpointSize)</h3>
<p>Sets the point size to <em>pointSize.</em> The point size must be greater
than zero.
<p>Example:
<pre> <a href="qfont.html">QFont</a> font( "courier" );
font.<a href="#fd77c1">setPointSize</a>( 18 );
</pre>
<p>See also <a href="#46f238">pointSize</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">void<a name="05a74f"></a>QFont::setPointSizeFloat(floatpointSize)</h3>
<p>Sets the point size to <em>pointSize.</em> The point size must be greater
than zero. The requested precision may not be achieved on all platforms.
<h3 class="fn">void<a name="ed26f0"></a>QFont::setRawMode(boolenable)</h3>
<p>Turns raw mode on if <em>enable</em> is TRUE, or turns it off if <em>enable</em> is FALSE.
<p>Calling this function only has effect under X windows. If raw mode
is enabled, Qt will search for an X font with a complete font name
matching the family name, ignoring all other values set for the
QFont. If the font name matches several fonts, Qt will use the
first font returned by X. <a href="qfontinfo.html">QFontInfo</a> <em>cannot</em> be used to fetch
information about a QFont using raw mode (it will return the values
set in the QFont for all parameters, including the family name).<p><b>Warning:</b> Do not use raw mode unless you really, really need it! In
most (if not all) cases, <a href="#d8a345">setRawName</a>() is a much better choise.
<p>See also <a href="#95a609">rawMode</a>() and <a href="#d8a345">setRawName</a>().
<h3 class="fn">void<a name="d8a345"></a>QFont::setRawName(const<a href="qstring.html">QString</a>&name)</h3>
<p>Sets a font by its system specific name. The function is in
particular useful under X, where system font settings ( for example
X resources) are usually available as XLFD (X Logical Font
Description) only. You can pass an XLFD as <em>name</em> to this function.
<p>In Qt 2.0 and later, a font set with setRawName() is still a
full-featured QFont. It can be queried (for example with <a href="#b38bfa">italic</a>())
or modified (for example with <a href="#b6af25">setItalic</a>() ) and is therefore also
suitable as a basis font for rendering rich text.
<p>If Qt's internal font database cannot resolve the raw name, the font
becomes a raw font with <em>name</em> as family.
<p>Note that the present implementation does not handle handle
wildcards in XLFDs well, and that font aliases (file <code>fonts.alias</code>
in the font directory on X11) are not supported.
<p>See also <a href="#7ab1bb">rawName</a>(), <a href="#ed26f0">setRawMode</a>() and <a href="#0e588e">setFamily</a>().
<h3 class="fn">void<a name="1caefc"></a>QFont::setStrikeOut(boolenable)</h3>
<p>Sets strike out on or off.
<p>See also <a href="#d8d538">strikeOut</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">void<a name="7beece"></a>QFont::setStyleHint(<a href="qfont.html#StyleHint">StyleHint</a>hint)</h3>
<p>Sets the style hint.
<p>See also setStyleHint().
<p>Examples:
<a href="desktop-desktop-cpp.html#setStyleHint">desktop/desktop.cpp</a>
<h3 class="fn">void<a name="b6f3c6"></a>QFont::setStyleHint(<a href="qfont.html#StyleHint">StyleHint</a>hint, <a href="qfont.html#StyleStrategy">StyleStrategy</a>strategy)</h3>
<p>Sets the style hint and strategy.
<p>The style hint has a default value of <code>AnyStyle</code> which leaves the
task of finding a good default family to the font matching
algorithm.
<p>The style strategy has a default value of <code>PreferDefault</code> which tells
the algorithm not to prefer any type of font.
<p>In the example below the push button will
display its text label with the Bavaria font family if this family
is available, if not it will display its text label with another
serif font:
<pre> #include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
int main( int argc, char **argv )
{
<a href="qapplication.html">QApplication</a> app( argc, argv );
<a href="qpushbutton.html">QPushButton</a> push("Push me");
<a href="qfont.html">QFont</a> font( "Bavaria", 18 ); // preferred family is Bavaria
font.<a href="#7beece">setStyleHint</a>( QFont::Serif ) // can also use any serif font
push.<a href="qwidget.html#c52788">setFont</a>( font );
return app.<a href="qapplication.html#84c7bf">exec</a>( &push );
}
</pre>
<p>See also <a href="#StyleHint">QFont::StyleHint</a>, <a href="#634c0c">styleHint</a>(), <a href="#StyleStrategy">QFont::StyleStrategy</a>, <a href="#a2c708">styleStrategy</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">void<a name="c11804"></a>QFont::setUnderline(boolenable)</h3>
<p>Sets underline on or off.
<p>See also <a href="#34e94b">underline</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<p>Examples:
<a href="menu-menu-cpp.html#setUnderline">menu/menu.cpp</a>
<h3 class="fn">void<a name="5d7ef1"></a>QFont::setWeight(intweight)</h3>
<p>Sets the weight (or boldness), which should be a value
from the <a href="#Weight">QFont::Weight</a> enumeration.
<p>Example:
<pre> <a href="qfont.html">QFont</a> font( "courier" );
font.<a href="#5d7ef1">setWeight</a>( QFont::Bold );
</pre>
<p>Strictly speaking you can use all values in the range [0,99] (where
0 is ultralight and 99 is extremely black), but there is perhaps
asking too much of the underlying window system.
<p>If the specified weight is not available the closest available will
be used. Use <a href="qfontinfo.html">QFontInfo</a> to check the actual weight.
<p>See also <a href="#41db89">weight</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<h3 class="fn">bool<a name="d8d538"></a>QFont::strikeOut()const</h3>
<p>Returns the value set by <a href="#1caefc">setStrikeOut</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the strike out value of the window system font
actually used.
<p>See also <a href="#1caefc">setStrikeOut</a>() and <a href="qfontinfo.html#48aaca">QFontInfo::strikeOut</a>().
<h3 class="fn">QFont::StyleHint<a name="634c0c"></a>QFont::styleHint()const</h3>
<p>Returns the <a href="#StyleHint">StyleHint</a> set by <a href="#7beece">setStyleHint</a>().
<p>See also <a href="#7beece">setStyleHint</a>() and <a href="qfontinfo.html#8ae0b9">QFontInfo::styleHint</a>().
<h3 class="fn">QFont::StyleStrategy<a name="a2c708"></a>QFont::styleStrategy()const</h3>
<p>Returns the StyleStratgie set by <a href="#7beece">setStyleHint</a>()
<p>See also <a href="#7beece">setStyleHint</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="d37712"></a>QFont::substitute(const<a href="qstring.html">QString</a>&familyName) <code>[static]</code></h3>
<p>Returns the font family name to be used whenever <em>familyName</em> is
specified. The lookup is case insensitive.
<p>If there is no substitution for <em>familyName,</em> then <em>familyName</em> is
returned.
<p>Example:
<pre> <a href="#785f7e">QFont::insertSubstitution</a>( "NewYork", "London" );
<a href="#785f7e">QFont::insertSubstitution</a>( "Paris", "Texas" );
<a href="#d37712">QFont::substitute</a>( "NewYork" ); // returns "London"
<a href="#d37712">QFont::substitute</a>( "PARIS" ); // returns "Texas"
<a href="#d37712">QFont::substitute</a>( "Rome" ); // returns "Rome"
<a href="#42b145">QFont::removeSubstitution</a>( "newyork" );
<a href="#d37712">QFont::substitute</a>( "NewYork" ); // returns "NewYork"
</pre>
<p>See also <a href="#0e588e">setFamily</a>(), <a href="#785f7e">insertSubstitution</a>() and <a href="#42b145">removeSubstitution</a>().
<h3 class="fn"><a href="qstringlist.html">QStringList</a><a name="b4855d"></a>QFont::substitutions() <code>[static]</code></h3>
<p>Returns a sorted list of substituted family names.
<p>See also <a href="#785f7e">insertSubstitution</a>(), <a href="#42b145">removeSubstitution</a>() and <a href="#d37712">substitute</a>().
<h3 class="fn">bool<a name="34e94b"></a>QFont::underline()const</h3>
<p>Returns the value set by <a href="#c11804">setUnderline</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the underline value of the window system font
actually used for drawing.
<p>See also <a href="#c11804">setUnderline</a>() and <a href="qfontinfo.html#38ad03">QFontInfo::underline</a>().
<h3 class="fn">int<a name="41db89"></a>QFont::weight()const</h3>
<p>Returns the weight set by <a href="#5d7ef1">setWeight</a>().
<p>Use <a href="qfontinfo.html">QFontInfo</a> to find the weight of the window system font actually used.
<p>See also <a href="#5d7ef1">setWeight</a>() and <a href="qfontinfo.html">QFontInfo</a>.
<hr><h2>Related Functions</h2>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="43d253"></a>operator<< (<a href="qdatastream.html">QDataStream</a> & s, const QFont & f)</h3>
<p>Writes a font to the stream.
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="6848d3"></a>operator>> (<a href="qdatastream.html">QDataStream</a> & s, QFont & f)</h3>
<p>Reads a font from the stream.
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|