source: trunk/doc/html/emb-fonts.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 8.8 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qws.doc:185 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Fonts in Qt/Embedded</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Fonts in Qt/Embedded</h1>
33
34
35<p> <h2> Supported Formats
36</h2>
37<a name="1"></a><p> Qt/Embedded supports four font formats:
38<p> <center><table cellpadding="4" cellspacing="2" border="0">
39<tr bgcolor="#f0f0f0">
40<td valign="top"><b>TrueType (TTF)</b>
41<td valign="top">The scalable font technology now standard on MS-Windows and Apple
42Macintosh, and becoming popular on X11.
43<tr bgcolor="#d0d0d0">
44<td valign="top"><b>Postscript Type1 (PFA/PFB)</b>
45<td valign="top">Scalable fonts often used by printers, also popular on X11. These
46are similar in functionality to TTF fonts and are not discussed
47further in this document.
48<tr bgcolor="#f0f0f0">
49<td valign="top"><b>Bitmap Distribution Format<br>fonts (BDF)</b>
50<td valign="top">A standard format for non-scalable fonts. A large number of BDF
51fonts are supplied as part of standard X11 distributions - most of
52these can be used with Qt/Embedded. You should <em>not</em> use these in a
53production system: they are very slow to load and take up a <em>lot</em> of
54storage space. Instead, render the BDF to a QPF.
55<tr bgcolor="#d0d0d0">
56<td valign="top"><b>Qt Prerendered Font (QPF)</b>
57<td valign="top">A light-weight non-scalable font format specific to Qt/Embedded.
58</table></center>
59<p> Support for each of these font formats (except QPF which is always
60enabled) can be enabled or disabled independently by using the <a href="emb-features.html">Qt/Embedded Features Definition</a>. There is
61support in Qt/Embedded for writing a QPF font file from any font, so
62you can initially enable TTF and BDF formats, save QPF files for the
63fonts and sizes you need, then remove TTF and BDF support.
64<p> See <a href="makeqpf.html">tools/makeqpf</a> for a tool that helps
65produce QPF files from the TTF and BDF, or just run your application
66with the <tt>-savefonts</tt> option.
67<p> <h2> Memory Requirements
68</h2>
69<a name="2"></a><p> With TTF fonts, each character in the font at a given point size is
70only rendered when first used in a drawing or metrics operation. With
71BDF fonts all characters are rendered when the font is used.
72With QPF fonts, the characters are stored in the same format that Qt
73uses for drawing.
74<p> For example, a 10-point Times font containing the ASCII characters uses
75around 1300 bytes when stored in QPF format.
76<p> Taking advantage of the way the QPF format is structured, Qt/Embedded
77memory-maps the data rather than reading and parsing it.
78This reduces RAM consumption even further.
79<p> Scalable fonts use a larger amount of memory per font, but
80these fonts provide a memory saving if many different sizes of each
81font are needed.
82<p> <h2> Smooth Fonts
83</h2>
84<a name="3"></a><p> TTF, PFA, and QPF fonts can be rendered as <em>smooth</em> anti-aliased
85fonts to give superior readability, especially on low-resolution
86devices. The difference between smooth and non-smooth fonts is
87illustrated below (you may need to change your display to low
88resolution to see the difference):
89<p> <center><img src="unsmooth.png" alt="unsmooth"></center>
90<p> <center><img src="smooth.png" alt="smooth"></center>
91<p> <h2> Unicode
92</h2>
93<a name="4"></a><p> All fonts used by Qt/Embedded use the Unicode character encoding.
94Most fonts available today use this encoding, but they usually don't
95contain all the Unicode characters. A <em>complete</em> 16-point Unicode
96font uses over 1 MB of memory.
97<p> <h2> The font definition file
98</h2>
99<a name="5"></a><p> When Qt/Embedded applications run, they look for a file called
100<tt>$QTDIR/lib/fonts/fontdir</tt> or
101<tt>/usr/local/qt-embedded/lib/fonts/fontdir</tt>. This file defines the
102fonts available to the application. It has the following format:
103<blockquote>
104<em>name</em> <em>file</em> <em>renderer</em> <em>italic</em> <em>weight</em> <em>size</em> <em>flags</em>
105</blockquote>
106where
107<p> <center><table cellpadding="4" cellspacing="2" border="0">
108<tr bgcolor="#a2c511"> <th valign="top">Field <th valign="top">Value
109<tr bgcolor="#f0f0f0"> <td valign="top"><em>name</em> <td valign="top"><tt>Helvetica</tt>, <tt>Times</tt>, etc.
110<tr bgcolor="#d0d0d0"> <td valign="top"><em>file</em> <td valign="top"><tt>helvR0810.bdf</tt>, <tt>verdana.ttf</tt>, etc.
111<tr bgcolor="#f0f0f0"> <td valign="top"><em>renderer</em> <td valign="top"><tt>BDF</tt> or <tt>FT</tt>
112<tr bgcolor="#d0d0d0"> <td valign="top"><em>italic</em> <td valign="top"><tt>y</tt> or <tt>n</tt>
113<tr bgcolor="#f0f0f0"> <td valign="top"><em>weight</em> <td valign="top"><tt>50</tt> is normal, <tt>75</tt> is bold, etc.
114<tr bgcolor="#d0d0d0"> <td valign="top"><em>size</em> <td valign="top"><tt>0</tt> for scalable or point size * 10 (i.e. <tt>120</tt>
115for 12pt)
116<tr bgcolor="#f0f0f0"> <td valign="top"><em>flags</em> <td valign="top"><ul>
117<li> <tt>s</tt>: smooth (anti-aliased)
118<li> <tt>u</tt>: Unicode range when saving (default is Latin-1)
119<li> <tt>a</tt>: ASCII range when saving (default is Latin-1)
120</ul>
121</table></center>
122<p> The font definition file does not specify QPF fonts; these are loaded
123directly from the directory containing the <tt>fontdir</tt> file, and must
124be named <em>name</em>_<em>size</em>_<em>weight</em><em>italicflag</em>.qpf, where
125<p> <center><table cellpadding="4" cellspacing="2" border="0">
126<tr bgcolor="#a2c511"> <th valign="top">Field <th valign="top">Value
127<tr bgcolor="#d0d0d0"> <td valign="top"><em>name</em> <td valign="top"><tt>helvetica</tt>, <tt>times</tt>, etc. (in lowercase)
128<tr bgcolor="#f0f0f0"> <td valign="top"><em>size</em> <td valign="top">point size * 10 (i.e. <tt>120</tt> for 12pt)
129<tr bgcolor="#d0d0d0"> <td valign="top"><em>italicflag</em> <td valign="top"><tt>i</tt> for italic, otherwise nothing.
130<tr bgcolor="#f0f0f0"> <td valign="top"><em>weight</em> <td valign="top"><tt>50</tt> is normal, <tt>75</tt> is bold, etc.
131</table></center>
132<p> If an application is run with the <tt>-savefonts</tt> command-line option,
133then whenever a font other than a QPF font is used, a corresponding QPF file
134is saved. This allows you to easily find the font usage of your applications
135and to generate QPF files so that you can eventually reduce the memory
136usage of your applications by disabling TTF and BDF support from Qt/Embedded,
137or by modifying the initialization of <tt>qws_savefonts</tt> in
138<tt>kernel/qapplication_qws.cpp</tt> of the Qt/Embedded library source code.
139In extreme cases of memory-saving, it is possible to save partially-rendered
140fonts (i.e. only the characters in "Product Name<sup>TM</sup>") if you are
141certain that these are the only characters you will need from the font.
142See QMemoryManager::savePrerenderedFont() for this functionality.
143<p> <h2> Notes
144</h2>
145<a name="6"></a><p> The font definition file, naming conventions for font files, and the format
146of QPF files may change in versions of Qt/Embedded after 3.
147<p>
148To generate QPF files of different rotations, the program must be re-run with
149an orientation that matches the desired rotation of the QPF output. An example to
150generate all 4 rotations of fonts would be to run the following at a real framebuffer:
151<pre>
152for dpy in LinuxFb Transformed:Rot90 Transformed:Rot180 Transformed:Rot270
153do
154 QWS_DISPLAY=$dpy ./makeqpf "$@"
155done
156</pre><p> If programs are only ever run in one orientation on a device, only the one
157appropriate set of fonts is needed.
158<p>
159When enabled, Qt/Embedded uses the powerful FreeType2 library to implement
160TrueType and Type1 support.
161<p>
162<!-- eof -->
163<p><address><hr><div align=center>
164<table width=100% cellspacing=0 border=0><tr>
165<td>Copyright &copy; 2007
166<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
167<td align=right><div align=right>Qt 3.3.8</div>
168</table></div></address></body>
169</html>
Note: See TracBrowser for help on using the repository browser.