| 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/include/qfontmanager_qws.h:1 -->
 | 
|---|
| 3 | <html>
 | 
|---|
| 4 | <head>
 | 
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 | 
|---|
| 6 | <title>qfontmanager_qws.h Include File</title>
 | 
|---|
| 7 | <style type="text/css"><!--
 | 
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
 | 
|---|
| 9 | a:link { color: #004faf; text-decoration: none }
 | 
|---|
| 10 | a:visited { color: #672967; text-decoration: none }
 | 
|---|
| 11 | body { 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 Classes</font></a>
 | 
|---|
| 23 |  | <a href="mainclasses.html">
 | 
|---|
| 24 | <font color="#004faf">Main 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 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>qfontmanager_qws.h</h1>
 | 
|---|
| 33 | 
 | 
|---|
| 34 | <p>This is the verbatim text of the qfontmanager_qws.h include file. It is provided only for illustration; the copyright remains with Trolltech.
 | 
|---|
| 35 | <hr>
 | 
|---|
| 36 | <pre>
 | 
|---|
| 37 | /****************************************************************************
 | 
|---|
| 38 | ** $Id: qfontmanager_qws-h.html 2051 2007-02-21 10:04:20Z chehrlic $
 | 
|---|
| 39 | **
 | 
|---|
| 40 | ** Definition of font rendering infrastructure for Embedded Qt
 | 
|---|
| 41 | **
 | 
|---|
| 42 | ** Created : 940721
 | 
|---|
| 43 | **
 | 
|---|
| 44 | ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
 | 
|---|
| 45 | **
 | 
|---|
| 46 | ** This file is part of the kernel module of the Qt GUI Toolkit.
 | 
|---|
| 47 | **
 | 
|---|
| 48 | ** This file may be distributed and/or modified under the terms of the
 | 
|---|
| 49 | ** GNU General Public License version 2 as published by the Free Software
 | 
|---|
| 50 | ** Foundation and appearing in the file LICENSE.GPL included in the
 | 
|---|
| 51 | ** packaging of this file.
 | 
|---|
| 52 | **
 | 
|---|
| 53 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
 | 
|---|
| 54 | ** licenses for Qt/Embedded may use this file in accordance with the
 | 
|---|
| 55 | ** Qt Embedded Commercial License Agreement provided with the Software.
 | 
|---|
| 56 | **
 | 
|---|
| 57 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 | 
|---|
| 58 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 | 
|---|
| 59 | **
 | 
|---|
| 60 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 | 
|---|
| 61 | **   information about Qt Commercial License Agreements.
 | 
|---|
| 62 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
 | 
|---|
| 63 | **
 | 
|---|
| 64 | ** Contact info@trolltech.com if any conditions of this licensing are
 | 
|---|
| 65 | ** not clear to you.
 | 
|---|
| 66 | **
 | 
|---|
| 67 | **********************************************************************/
 | 
|---|
| 68 | 
 | 
|---|
| 69 | #ifndef QFONTMANAGER_QWS_H
 | 
|---|
| 70 | #define QFONTMANAGER_QWS_H
 | 
|---|
| 71 | 
 | 
|---|
| 72 | #ifndef QT_H
 | 
|---|
| 73 | #include "qfont.h"
 | 
|---|
| 74 | #include "qptrlist.h"
 | 
|---|
| 75 | #include <private/qtextengine_p.h>
 | 
|---|
| 76 | #endif // QT_H
 | 
|---|
| 77 | 
 | 
|---|
| 78 | // These are stored in the shared memory segment in front of their
 | 
|---|
| 79 | // data, and indexed at the start of the segment
 | 
|---|
| 80 | 
 | 
|---|
| 81 | // This needs to be a multiple of 64 bits
 | 
|---|
| 82 | 
 | 
|---|
| 83 | class QFontDef;
 | 
|---|
| 84 | 
 | 
|---|
| 85 | class Q_PACKED QGlyphMetrics {
 | 
|---|
| 86 | 
 | 
|---|
| 87 | public:
 | 
|---|
| 88 |     Q_UINT8 linestep;
 | 
|---|
| 89 |     Q_UINT8 width;
 | 
|---|
| 90 |     Q_UINT8 height;
 | 
|---|
| 91 |     Q_UINT8 flags;
 | 
|---|
| 92 | 
 | 
|---|
| 93 |     Q_INT8 bearingx;      // Difference from pen position to glyph's left bbox
 | 
|---|
| 94 |     Q_UINT8 advance;       // Difference between pen positions
 | 
|---|
| 95 |     Q_INT8 bearingy;      // Used for putting characters on baseline
 | 
|---|
| 96 | 
 | 
|---|
| 97 |     Q_INT8 reserved;      // Do not use
 | 
|---|
| 98 | 
 | 
|---|
| 99 |     // Flags:
 | 
|---|
| 100 |     // RendererOwnsData - the renderer is responsible for glyph data
 | 
|---|
| 101 |     //                    memory deletion otherwise QGlyphTree must
 | 
|---|
| 102 |     //                    delete [] the data when the glyph is deleted.
 | 
|---|
| 103 |     enum Flags { RendererOwnsData=0x01 };
 | 
|---|
| 104 | };
 | 
|---|
| 105 | 
 | 
|---|
| 106 | class QGlyph {
 | 
|---|
| 107 | public:
 | 
|---|
| 108 |     QGlyph() { metrics=0; data=0; }
 | 
|---|
| 109 |     QGlyph(QGlyphMetrics* m, uchar* d) :
 | 
|---|
| 110 |         metrics(m), data(d) { }
 | 
|---|
| 111 |     ~QGlyph() {}
 | 
|---|
| 112 | 
 | 
|---|
| 113 |     QGlyphMetrics* metrics;
 | 
|---|
| 114 |     uchar* data;
 | 
|---|
| 115 | };
 | 
|---|
| 116 | 
 | 
|---|
| 117 | 
 | 
|---|
| 118 | 
 | 
|---|
| 119 | class QFontFactory;
 | 
|---|
| 120 | class QDiskFont;
 | 
|---|
| 121 | 
 | 
|---|
| 122 | // This is a particular font instance at a particular resolution
 | 
|---|
| 123 | // e.g. Truetype Times, 10 point. There's only one of these though;
 | 
|---|
| 124 | // we want to share generated glyphs
 | 
|---|
| 125 | 
 | 
|---|
| 126 | class QRenderedFont {
 | 
|---|
| 127 | 
 | 
|---|
| 128 | public:
 | 
|---|
| 129 | 
 | 
|---|
| 130 |     // Normal font-type is monochrome; glyph data is a
 | 
|---|
| 131 |     //   bitmap, which doesn't use much memory
 | 
|---|
| 132 | 
 | 
|---|
| 133 |     // Initialise for name A, renderer B, font type C, D glyphs
 | 
|---|
| 134 | 
 | 
|---|
| 135 |     QRenderedFont(QDiskFont *,const QFontDef&);
 | 
|---|
| 136 |     virtual ~QRenderedFont();
 | 
|---|
| 137 | 
 | 
|---|
| 138 |     QFontDef fontDef() const;
 | 
|---|
| 139 | 
 | 
|---|
| 140 |     int refcount;
 | 
|---|
| 141 | 
 | 
|---|
| 142 |     int ptsize;
 | 
|---|
| 143 | 
 | 
|---|
| 144 |     bool italic;
 | 
|---|
| 145 |     unsigned int weight;
 | 
|---|
| 146 | 
 | 
|---|
| 147 |     void ref() { refcount++; }
 | 
|---|
| 148 |     bool deref() { refcount--; return refcount==0; }
 | 
|---|
| 149 | 
 | 
|---|
| 150 |     bool match(const QFontDef &);
 | 
|---|
| 151 | 
 | 
|---|
| 152 |     QDiskFont* diskfont;
 | 
|---|
| 153 |     int fascent,fdescent;
 | 
|---|
| 154 |     int fleftbearing,frightbearing;
 | 
|---|
| 155 |     int fmaxwidth;
 | 
|---|
| 156 |     int fleading;
 | 
|---|
| 157 |     int funderlinepos;
 | 
|---|
| 158 |     int funderlinewidth;
 | 
|---|
| 159 |     bool smooth;
 | 
|---|
| 160 |     int maxchar;
 | 
|---|
| 161 | 
 | 
|---|
| 162 |     int ascent() { return fascent; }
 | 
|---|
| 163 |     int descent() { return fdescent; }
 | 
|---|
| 164 |     int width(int);
 | 
|---|
| 165 |     int width( const QString&, int =-1 );
 | 
|---|
| 166 |     int leftBearing(int);
 | 
|---|
| 167 |     int rightBearing(int);
 | 
|---|
| 168 | 
 | 
|---|
| 169 |     // Calling any of these can trigger a full-font metrics check
 | 
|---|
| 170 |     // which can be expensive
 | 
|---|
| 171 |     int minLeftBearing();
 | 
|---|
| 172 |     int minRightBearing();
 | 
|---|
| 173 |     int maxWidth();
 | 
|---|
| 174 | 
 | 
|---|
| 175 |     virtual bool inFont(glyph_t g) const=0;
 | 
|---|
| 176 |     virtual QGlyph render(glyph_t g)=0;
 | 
|---|
| 177 | 
 | 
|---|
| 178 | private:
 | 
|---|
| 179 | 
 | 
|---|
| 180 | };
 | 
|---|
| 181 | 
 | 
|---|
| 182 | // Keeps track of available renderers and which font is which
 | 
|---|
| 183 | 
 | 
|---|
| 184 | class QDiskFontPrivate {};
 | 
|---|
| 185 | 
 | 
|---|
| 186 | class QDiskFont {
 | 
|---|
| 187 | 
 | 
|---|
| 188 | public:
 | 
|---|
| 189 |     QDiskFont(QFontFactory *f, const QString& n, bool i, int w, int s,
 | 
|---|
| 190 |               const QString &fl, const QString& fi) :
 | 
|---|
| 191 |         factory(f), name(n), italic(i), weight(w), size(s), flags(fl), file(fi)
 | 
|---|
| 192 |     {
 | 
|---|
| 193 |         loaded=FALSE;
 | 
|---|
| 194 |         p=0;
 | 
|---|
| 195 |     }
 | 
|---|
| 196 | 
 | 
|---|
| 197 |     QRenderedFont* load(const QFontDef &);
 | 
|---|
| 198 | 
 | 
|---|
| 199 |     QFontDef fontDef() const;
 | 
|---|
| 200 | 
 | 
|---|
| 201 |     QFontFactory *factory;
 | 
|---|
| 202 |     QString name;
 | 
|---|
| 203 |     bool italic;
 | 
|---|
| 204 |     int weight;
 | 
|---|
| 205 |     int size;
 | 
|---|
| 206 |     QString flags;
 | 
|---|
| 207 |     QString file;
 | 
|---|
| 208 |     bool loaded;
 | 
|---|
| 209 | 
 | 
|---|
| 210 |     QDiskFontPrivate * p;
 | 
|---|
| 211 | };
 | 
|---|
| 212 | 
 | 
|---|
| 213 | class QCachePolicy {
 | 
|---|
| 214 | 
 | 
|---|
| 215 | public:
 | 
|---|
| 216 | 
 | 
|---|
| 217 |     virtual void cache(QRenderedFont *)=0;
 | 
|---|
| 218 |     virtual void uncache(QRenderedFont *)=0;
 | 
|---|
| 219 | 
 | 
|---|
| 220 | };
 | 
|---|
| 221 | 
 | 
|---|
| 222 | // Exposed here so the default policy can be reset
 | 
|---|
| 223 | 
 | 
|---|
| 224 | class QDefaultCachePolicy : public QCachePolicy {
 | 
|---|
| 225 | 
 | 
|---|
| 226 | public:
 | 
|---|
| 227 | 
 | 
|---|
| 228 |     virtual void cache(QRenderedFont *);
 | 
|---|
| 229 |     virtual void uncache(QRenderedFont *);
 | 
|---|
| 230 | 
 | 
|---|
| 231 | };
 | 
|---|
| 232 | 
 | 
|---|
| 233 | class QFontManager {
 | 
|---|
| 234 | 
 | 
|---|
| 235 | public:
 | 
|---|
| 236 | 
 | 
|---|
| 237 |     QPtrList<QFontFactory> factories;
 | 
|---|
| 238 |     QPtrList<QRenderedFont> cachedfonts;
 | 
|---|
| 239 |     QPtrList<QDiskFont> diskfonts;
 | 
|---|
| 240 | 
 | 
|---|
| 241 |     QFontManager();
 | 
|---|
| 242 |     ~QFontManager();
 | 
|---|
| 243 | 
 | 
|---|
| 244 |     // Font definition, type and color
 | 
|---|
| 245 |     QDiskFont * get(const QFontDef &);
 | 
|---|
| 246 | 
 | 
|---|
| 247 |     static int cmpFontDef(const QFontDef & goal, const QFontDef & choice);
 | 
|---|
| 248 | 
 | 
|---|
| 249 |     static void initialize();
 | 
|---|
| 250 |     static void cleanup();
 | 
|---|
| 251 | 
 | 
|---|
| 252 |     void setPolicy(QCachePolicy *);
 | 
|---|
| 253 | 
 | 
|---|
| 254 |     void cache(QRenderedFont * f) { policy->cache(f); }
 | 
|---|
| 255 |     void uncache(QRenderedFont * f) { policy->uncache(f); }
 | 
|---|
| 256 |     QRenderedFont * getCached(const QFontDef &);
 | 
|---|
| 257 | 
 | 
|---|
| 258 | private:
 | 
|---|
| 259 | 
 | 
|---|
| 260 |     QCachePolicy * policy;
 | 
|---|
| 261 | 
 | 
|---|
| 262 | };
 | 
|---|
| 263 | 
 | 
|---|
| 264 | class QFontFactory {
 | 
|---|
| 265 | 
 | 
|---|
| 266 | public:
 | 
|---|
| 267 | 
 | 
|---|
| 268 |     QFontFactory() {}
 | 
|---|
| 269 |     virtual ~QFontFactory() {}
 | 
|---|
| 270 | 
 | 
|---|
| 271 |     virtual QRenderedFont * get(const QFontDef &,QDiskFont *)=0;
 | 
|---|
| 272 |     virtual void load(QDiskFont *) const=0;
 | 
|---|
| 273 |     virtual void unload(QDiskFont *) {}
 | 
|---|
| 274 |     virtual QString name()=0;
 | 
|---|
| 275 | };
 | 
|---|
| 276 | 
 | 
|---|
| 277 | void qt_init_fonts();
 | 
|---|
| 278 | 
 | 
|---|
| 279 | extern QFontManager * qt_fontmanager;
 | 
|---|
| 280 | 
 | 
|---|
| 281 | #endif
 | 
|---|
| 282 | </pre>
 | 
|---|
| 283 | <!-- eof -->
 | 
|---|
| 284 | <p><address><hr><div align=center>
 | 
|---|
| 285 | <table width=100% cellspacing=0 border=0><tr>
 | 
|---|
| 286 | <td>Copyright © 2007
 | 
|---|
| 287 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
 | 
|---|
| 288 | <td align=right><div align=right>Qt 3.3.8</div>
 | 
|---|
| 289 | </table></div></address></body>
 | 
|---|
| 290 | </html>
 | 
|---|