| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the documentation of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | /*! | 
|---|
| 43 | \page qt-embedded-fonts.html | 
|---|
| 44 |  | 
|---|
| 45 | \title Qt for Embedded Linux Fonts | 
|---|
| 46 | \ingroup qt-embedded-linux | 
|---|
| 47 |  | 
|---|
| 48 | \l {Qt for Embedded Linux} uses the | 
|---|
| 49 | \l{http://freetype.sourceforge.net/freetype2/index.html}{FreeType 2} | 
|---|
| 50 | font engine to produce font output. The formats supported depends on | 
|---|
| 51 | the locally installed version of the FreeType library. In addition, | 
|---|
| 52 | \l{Qt for Embedded Linux} supports the Qt Prerendered Font formats (\l QPF and \l QPF2): | 
|---|
| 53 | light-weight non-scalable font formats specific to \l {Qt for Embedded Linux}. | 
|---|
| 54 | QPF2 is the native format of \l{Qt for Embedded Linux}. QPF is the legacy | 
|---|
| 55 | format used by Qt/Embedded 2.x and 3.x. Several of the formats may be rendered | 
|---|
| 56 | using anti-aliasing for improved readability. | 
|---|
| 57 |  | 
|---|
| 58 | When \l{Qt for Embedded Linux} applications run, they look for fonts in | 
|---|
| 59 | Qt's \c lib/fonts/ directory. \l {Qt for Embedded Linux} will automatically detect | 
|---|
| 60 | prerendered fonts and TrueType fonts. For compatibility, it will also read the | 
|---|
| 61 | legacy \c lib/fonts/fontdir file. | 
|---|
| 62 |  | 
|---|
| 63 | Support for other font formats can be added, contact | 
|---|
| 64 | \l{mailto:qt-info@nokia.com}{qt-info@nokia.com} for more | 
|---|
| 65 | information. | 
|---|
| 66 |  | 
|---|
| 67 | \tableofcontents | 
|---|
| 68 |  | 
|---|
| 69 | \table 100% | 
|---|
| 70 | \row | 
|---|
| 71 | \o | 
|---|
| 72 | \bold {Optimization} | 
|---|
| 73 |  | 
|---|
| 74 | The \l FreeType, \l QPF2 and \l QPF formats are features that can be | 
|---|
| 75 | disabled using the | 
|---|
| 76 | \l{Fine-Tuning Features in Qt}{feature definition system}, | 
|---|
| 77 | reducing the size of Qt and saving resources. | 
|---|
| 78 |  | 
|---|
| 79 | Note that at least one font format must be defined. | 
|---|
| 80 |  | 
|---|
| 81 | See the \l {Fine-Tuning Features in Qt} documentation for | 
|---|
| 82 | details. | 
|---|
| 83 |  | 
|---|
| 84 | \o | 
|---|
| 85 | \inlineimage qt-embedded-fontfeatures.png | 
|---|
| 86 | \endtable | 
|---|
| 87 |  | 
|---|
| 88 | All supported fonts use the Unicode character encoding. Most fonts | 
|---|
| 89 | available today do, but they usually don't contain \e all the | 
|---|
| 90 | Unicode characters. A complete 16-point Unicode font uses over 1 | 
|---|
| 91 | MB of memory. | 
|---|
| 92 |  | 
|---|
| 93 | \target FreeType | 
|---|
| 94 | \section1 FreeType Formats | 
|---|
| 95 |  | 
|---|
| 96 | The \l {http://freetype.sourceforge.net/freetype2/index.html}{FreeType 2} | 
|---|
| 97 | library (and therefore \l{Qt for Embedded Linux}) can support the following font formats: | 
|---|
| 98 |  | 
|---|
| 99 | \list | 
|---|
| 100 | \o TrueType (TTF) | 
|---|
| 101 | \o PostScript Type1 (PFA/PFB) | 
|---|
| 102 | \o Bitmap Distribution Format (BDF) | 
|---|
| 103 | \o CID-keyed Type1 | 
|---|
| 104 | \o Compact Font Format (CFF) | 
|---|
| 105 | \o OpenType fonts | 
|---|
| 106 | \o SFNT-based bitmap fonts | 
|---|
| 107 | \o Portable Compiled Format (PCF) | 
|---|
| 108 | \o Microsoft Windows Font File Format (Windows FNT) | 
|---|
| 109 | \o Portable Font Resource (PFR) | 
|---|
| 110 | \o Type 42 (limited support) | 
|---|
| 111 | \endlist | 
|---|
| 112 |  | 
|---|
| 113 | It is possible to add modules to the \l | 
|---|
| 114 | {http://freetype.sourceforge.net/freetype2/index.html}{FreeType 2} | 
|---|
| 115 | font engine to support other types of font files. For more | 
|---|
| 116 | information, see the font engine's own website: \l | 
|---|
| 117 | http://freetype.sourceforge.net/freetype2/index.html. | 
|---|
| 118 |  | 
|---|
| 119 | Glyphs rendered using FreeType are shared efficiently between applications, | 
|---|
| 120 | reducing memory requirements and speeding up text rendering. | 
|---|
| 121 |  | 
|---|
| 122 | \omit | 
|---|
| 123 | \l {Qt for Embedded Linux} will by default use the system FreeType library if it exists. | 
|---|
| 124 | Otherwise it will use a copy of the FreeType library in Qt, which by default only | 
|---|
| 125 | supports TrueType fonts to reduce footprint. | 
|---|
| 126 | \endomit | 
|---|
| 127 |  | 
|---|
| 128 | \target QPF2 | 
|---|
| 129 | \section1 Qt Prerendered Font (QPF2) | 
|---|
| 130 |  | 
|---|
| 131 | The Qt Prerendered Font (QPF2) is an architecture-independent, | 
|---|
| 132 | light-weight and non-scalable font format specific to \l{Qt for Embedded Linux}. | 
|---|
| 133 |  | 
|---|
| 134 | Nokia provides the cross-platform \c makeqpf tool, included in the | 
|---|
| 135 | \c tools directory of both \l {Qt} and \l{Qt for Embedded Linux}, which allows | 
|---|
| 136 | generation of QPF2 files from system fonts. | 
|---|
| 137 |  | 
|---|
| 138 | QPF2 supports anti-aliasing and complex writing systems, using information | 
|---|
| 139 | from the corresponding TrueType font, if present on the system. The format | 
|---|
| 140 | is designed to be mapped directly to memory. The same format is used to | 
|---|
| 141 | share glyphs from non-prerendered fonts between applications. | 
|---|
| 142 |  | 
|---|
| 143 | \target QPF | 
|---|
| 144 | \section1 Legacy Qt Prerendered Font (QPF) | 
|---|
| 145 |  | 
|---|
| 146 | Nokia provides support for the legacy QPF format for compatibility | 
|---|
| 147 | reasons. QPF is based on the internal font engine data structure of Qt/Embedded | 
|---|
| 148 | versions 2 and 3. | 
|---|
| 149 |  | 
|---|
| 150 | Note that the file name describes the font, for example \c helvetica_120_50.qpf | 
|---|
| 151 | is 12 point Helvetica while \c helvetica_120_50i.qpf is 12 point Helvetica \e italic. | 
|---|
| 152 |  | 
|---|
| 153 | \omit | 
|---|
| 154 | \section1 Memory Requirements | 
|---|
| 155 |  | 
|---|
| 156 | Taking advantage of the way the QPF format is structured, Qt for | 
|---|
| 157 | Embedded Linux memory-maps the data rather than reading and parsing it. | 
|---|
| 158 | This reduces RAM consumption even further. | 
|---|
| 159 |  | 
|---|
| 160 | Scalable fonts use a larger amount of memory per font, but | 
|---|
| 161 | these fonts provide a memory saving if many different sizes of each | 
|---|
| 162 | font are needed. | 
|---|
| 163 | \endomit | 
|---|
| 164 |  | 
|---|
| 165 | \section1 The Legacy \c fontdir File | 
|---|
| 166 |  | 
|---|
| 167 | For compatibility reasons \l{Qt for Embedded Linux} supports the \c fontdir | 
|---|
| 168 | file, if present. The file defines additional fonts available to the | 
|---|
| 169 | application, and has the following format: | 
|---|
| 170 |  | 
|---|
| 171 | \snippet doc/src/snippets/code/doc_src_emb-fonts.qdoc 0 | 
|---|
| 172 |  | 
|---|
| 173 | \table 100% | 
|---|
| 174 | \header \o Field \o Description | 
|---|
| 175 | \row \o \bold name | 
|---|
| 176 | \o The name of the font format, e.g.,\c Helvetica, \c Times, etc. | 
|---|
| 177 | \row \o \bold file | 
|---|
| 178 | \o The name of the file containing the font, e.g., \c | 
|---|
| 179 | helvR0810.bdf, \c verdana.ttf, etc. | 
|---|
| 180 | \row \o \bold renderer | 
|---|
| 181 | \o Specifies the font engine that should be used to render the | 
|---|
| 182 | font, currently only the FreeType font engine (\c FT) is | 
|---|
| 183 | supported. | 
|---|
| 184 | \row \o \bold italic | 
|---|
| 185 | \o Specifies whether the font is italic or not; the accepted | 
|---|
| 186 | values are \c y or \c n. | 
|---|
| 187 | \row \o \bold weight | 
|---|
| 188 | \o Specifies the font's weight: \c 50 is normal, \c 75 is bold, | 
|---|
| 189 | etc. | 
|---|
| 190 | \row \o \bold size | 
|---|
| 191 | \o Specifies the font size, i.e., point size * 10. For example, a | 
|---|
| 192 | value of 120 means 12pt. A value of 0 means that the font is | 
|---|
| 193 | scalable. | 
|---|
| 194 | \row \o \bold flags | 
|---|
| 195 | \o The following flag is supported: | 
|---|
| 196 | \list | 
|---|
| 197 | \o \c s: smooth (anti-aliased) | 
|---|
| 198 | \endlist | 
|---|
| 199 | All other flags are ignored. | 
|---|
| 200 | \endtable | 
|---|
| 201 | */ | 
|---|