1 | /****************************************************************************
|
---|
2 | ** $Id: qfontengine_p.h 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** ???
|
---|
5 | **
|
---|
6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
|
---|
7 | **
|
---|
8 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
9 | **
|
---|
10 | ** This file may be distributed and/or modified under the terms of the
|
---|
11 | ** GNU General Public License version 2 as published by the Free Software
|
---|
12 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
13 | ** packaging of this file.
|
---|
14 | **
|
---|
15 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
16 | ** licenses for Qt/Embedded may use this file in accordance with the
|
---|
17 | ** Qt Embedded Commercial License Agreement provided with the Software.
|
---|
18 | **
|
---|
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
21 | **
|
---|
22 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
23 | ** information about Qt Commercial License Agreements.
|
---|
24 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
25 | **
|
---|
26 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
27 | ** not clear to you.
|
---|
28 | **
|
---|
29 | **********************************************************************/
|
---|
30 |
|
---|
31 | #ifndef QFONTENGINE_P_H
|
---|
32 | #define QFONTENGINE_P_H
|
---|
33 |
|
---|
34 | #ifndef QT_H
|
---|
35 | #include "qglobal.h"
|
---|
36 | #endif // QT_H
|
---|
37 |
|
---|
38 | #ifdef Q_WS_WIN
|
---|
39 | #include "qt_windows.h"
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #ifdef Q_WS_PM
|
---|
43 | #include "qt_os2.h"
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #include "qtextengine_p.h"
|
---|
47 |
|
---|
48 | class QPaintDevice;
|
---|
49 |
|
---|
50 | //@@TODO (dmik): these all are defined in the included "qtextengine_p.h",
|
---|
51 | // what do we need it here for?
|
---|
52 | //struct glyph_metrics_t;
|
---|
53 | //class QChar;
|
---|
54 | //typedef unsigned short glyph_t;
|
---|
55 | //struct qoffset_t;
|
---|
56 | //typedef int advance_t;
|
---|
57 | //class QOpenType;
|
---|
58 | struct TransformedFont;
|
---|
59 |
|
---|
60 | #if defined( Q_WS_X11 ) || defined( Q_WS_WIN) || defined( Q_WS_PM) || defined( Q_WS_MAC )
|
---|
61 | class QFontEngine : public QShared
|
---|
62 | {
|
---|
63 | public:
|
---|
64 | enum Error {
|
---|
65 | NoError,
|
---|
66 | OutOfMemory
|
---|
67 | };
|
---|
68 |
|
---|
69 | enum Type {
|
---|
70 | // X11 types
|
---|
71 | Box,
|
---|
72 | XLFD,
|
---|
73 | LatinXLFD,
|
---|
74 | Xft,
|
---|
75 |
|
---|
76 | // MS Windows types
|
---|
77 | Win,
|
---|
78 | Uniscribe,
|
---|
79 |
|
---|
80 | // OS/2 types
|
---|
81 | PM,
|
---|
82 |
|
---|
83 | // Apple MacOS types
|
---|
84 | Mac,
|
---|
85 |
|
---|
86 | // Trolltech QWS types
|
---|
87 | QWS
|
---|
88 | };
|
---|
89 |
|
---|
90 | QFontEngine() {
|
---|
91 | count = 0; cache_count = 0;
|
---|
92 | #ifdef Q_WS_X11
|
---|
93 | transformed_fonts = 0;
|
---|
94 | #endif
|
---|
95 | }
|
---|
96 | virtual ~QFontEngine();
|
---|
97 |
|
---|
98 | /* returns 0 as glyph index for non existant glyphs */
|
---|
99 | virtual Error stringToCMap( const QChar *str, int len, glyph_t *glyphs,
|
---|
100 | advance_t *advances, int *nglyphs, bool mirrored ) const = 0;
|
---|
101 |
|
---|
102 | #ifdef Q_WS_X11
|
---|
103 | virtual int cmap() const { return -1; }
|
---|
104 | virtual QOpenType *openType() const { return 0; }
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | virtual void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags ) = 0;
|
---|
108 |
|
---|
109 | virtual glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
110 | const advance_t *advances,
|
---|
111 | const qoffset_t *offsets, int numGlyphs ) = 0;
|
---|
112 | virtual glyph_metrics_t boundingBox( glyph_t glyph ) = 0;
|
---|
113 |
|
---|
114 | virtual int ascent() const = 0;
|
---|
115 | virtual int descent() const = 0;
|
---|
116 | virtual int leading() const = 0;
|
---|
117 |
|
---|
118 | virtual int lineThickness() const;
|
---|
119 | virtual int underlinePosition() const;
|
---|
120 |
|
---|
121 | virtual int maxCharWidth() const = 0;
|
---|
122 | virtual int minLeftBearing() const { return 0; }
|
---|
123 | virtual int minRightBearing() const { return 0; }
|
---|
124 |
|
---|
125 | virtual const char *name() const = 0;
|
---|
126 |
|
---|
127 | virtual bool canRender( const QChar *string, int len ) = 0;
|
---|
128 |
|
---|
129 | virtual void setScale( double ) {}
|
---|
130 | virtual double scale() const { return 1.; }
|
---|
131 |
|
---|
132 | virtual Type type() const = 0;
|
---|
133 |
|
---|
134 | QFontDef fontDef;
|
---|
135 | uint cache_cost; // amount of mem used in kb by the font
|
---|
136 | int cache_count;
|
---|
137 |
|
---|
138 | #ifdef Q_WS_WIN
|
---|
139 | HDC dc() const;
|
---|
140 | void getGlyphIndexes( const QChar *ch, int numChars, glyph_t *glyphs, bool mirrored ) const;
|
---|
141 | void getCMap();
|
---|
142 |
|
---|
143 | QCString _name;
|
---|
144 | HDC hdc;
|
---|
145 | HFONT hfont;
|
---|
146 | LOGFONT logfont;
|
---|
147 | uint stockFont : 1;
|
---|
148 | uint paintDevice : 1;
|
---|
149 | uint useTextOutA : 1;
|
---|
150 | uint ttf : 1;
|
---|
151 | uint symbol : 1;
|
---|
152 | union {
|
---|
153 | TEXTMETRICW w;
|
---|
154 | TEXTMETRICA a;
|
---|
155 | } tm;
|
---|
156 | int lw;
|
---|
157 | unsigned char *cmap;
|
---|
158 | void *script_cache;
|
---|
159 | short lbearing;
|
---|
160 | short rbearing;
|
---|
161 | #endif // Q_WS_WIN
|
---|
162 | #ifdef Q_WS_PM
|
---|
163 | HPS ps() const;
|
---|
164 | void selectTo( HPS ps ) const;
|
---|
165 |
|
---|
166 | HPS hps;
|
---|
167 | FATTRS fa;
|
---|
168 | PFONTMETRICS pfm;
|
---|
169 | #endif
|
---|
170 | #ifdef Q_WS_X11
|
---|
171 | TransformedFont *transformed_fonts;
|
---|
172 | #endif
|
---|
173 | };
|
---|
174 | #elif defined( Q_WS_QWS )
|
---|
175 | class QGfx;
|
---|
176 |
|
---|
177 | class QFontEngine : public QShared
|
---|
178 | {
|
---|
179 | public:
|
---|
180 | QFontEngine( const QFontDef&, const QPaintDevice * = 0 );
|
---|
181 | ~QFontEngine();
|
---|
182 | /*QMemoryManager::FontID*/ void *handle() const;
|
---|
183 |
|
---|
184 | enum Type {
|
---|
185 | // X11 types
|
---|
186 | Box,
|
---|
187 | XLFD,
|
---|
188 | Xft,
|
---|
189 |
|
---|
190 | // MS Windows types
|
---|
191 | Win,
|
---|
192 | Uniscribe,
|
---|
193 |
|
---|
194 | // Apple MacOS types
|
---|
195 | Mac,
|
---|
196 |
|
---|
197 | // Trolltech QWS types
|
---|
198 | Qws
|
---|
199 | };
|
---|
200 |
|
---|
201 | enum TextFlags {
|
---|
202 | Underline = 0x01,
|
---|
203 | Overline = 0x02,
|
---|
204 | StrikeOut = 0x04
|
---|
205 | };
|
---|
206 |
|
---|
207 | enum Error {
|
---|
208 | NoError,
|
---|
209 | OutOfMemory
|
---|
210 | };
|
---|
211 | /* returns 0 as glyph index for non existant glyphs */
|
---|
212 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
213 |
|
---|
214 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
215 |
|
---|
216 | glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
217 | const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
|
---|
218 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
219 |
|
---|
220 | int ascent() const;
|
---|
221 | int descent() const;
|
---|
222 | int leading() const;
|
---|
223 | int maxCharWidth() const;
|
---|
224 | int minLeftBearing() const;
|
---|
225 | int minRightBearing() const;
|
---|
226 | int underlinePosition() const;
|
---|
227 | int lineThickness() const;
|
---|
228 |
|
---|
229 | Type type() { return Qws; }
|
---|
230 |
|
---|
231 | bool canRender( const QChar *string, int len );
|
---|
232 | inline const char *name() const { return 0; }
|
---|
233 | QFontDef fontDef;
|
---|
234 | /*QMemoryManager::FontID*/ void *id;
|
---|
235 | int cache_cost;
|
---|
236 | int cache_count;
|
---|
237 | int scale;
|
---|
238 | };
|
---|
239 | #endif // WIN || X11 || MAC
|
---|
240 |
|
---|
241 |
|
---|
242 |
|
---|
243 | enum IndicFeatures {
|
---|
244 | CcmpFeature,
|
---|
245 | InitFeature,
|
---|
246 | NuktaFeature,
|
---|
247 | AkhantFeature,
|
---|
248 | RephFeature,
|
---|
249 | BelowFormFeature,
|
---|
250 | HalfFormFeature,
|
---|
251 | PostFormFeature,
|
---|
252 | VattuFeature,
|
---|
253 | PreSubstFeature,
|
---|
254 | AboveSubstFeature,
|
---|
255 | BelowSubstFeature,
|
---|
256 | PostSubstFeature,
|
---|
257 | HalantFeature
|
---|
258 | };
|
---|
259 |
|
---|
260 | #if defined(Q_WS_X11) || defined(Q_WS_WIN)
|
---|
261 | class QFontEngineBox : public QFontEngine
|
---|
262 | {
|
---|
263 | public:
|
---|
264 | QFontEngineBox( int size );
|
---|
265 | ~QFontEngineBox();
|
---|
266 |
|
---|
267 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
268 |
|
---|
269 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
270 |
|
---|
271 | virtual glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
272 | const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
|
---|
273 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
274 |
|
---|
275 | int ascent() const;
|
---|
276 | int descent() const;
|
---|
277 | int leading() const;
|
---|
278 | int maxCharWidth() const;
|
---|
279 | int minLeftBearing() const { return 0; }
|
---|
280 | int minRightBearing() const { return 0; }
|
---|
281 |
|
---|
282 | #ifdef Q_WS_X11
|
---|
283 | int cmap() const;
|
---|
284 | #endif
|
---|
285 | const char *name() const;
|
---|
286 |
|
---|
287 | bool canRender( const QChar *string, int len );
|
---|
288 |
|
---|
289 | Type type() const;
|
---|
290 | inline int size() const { return _size; }
|
---|
291 |
|
---|
292 | private:
|
---|
293 | friend class QFontPrivate;
|
---|
294 | int _size;
|
---|
295 | };
|
---|
296 | #endif
|
---|
297 |
|
---|
298 | #ifdef Q_WS_X11
|
---|
299 | #include "qt_x11_p.h"
|
---|
300 |
|
---|
301 |
|
---|
302 | struct TransformedFont
|
---|
303 | {
|
---|
304 | float xx;
|
---|
305 | float xy;
|
---|
306 | float yx;
|
---|
307 | float yy;
|
---|
308 | union {
|
---|
309 | Font xlfd_font;
|
---|
310 | #ifndef QT_NO_XFTFREETYPE
|
---|
311 | XftFont *xft_font;
|
---|
312 | #endif
|
---|
313 | };
|
---|
314 | TransformedFont *next;
|
---|
315 | };
|
---|
316 |
|
---|
317 | #ifndef QT_NO_XFTFREETYPE
|
---|
318 | #include <ft2build.h>
|
---|
319 | #include FT_FREETYPE_H
|
---|
320 | #include "ftxopen.h"
|
---|
321 |
|
---|
322 | class QTextCodec;
|
---|
323 |
|
---|
324 | class QFontEngineXft : public QFontEngine
|
---|
325 | {
|
---|
326 | public:
|
---|
327 | QFontEngineXft( XftFont *font, XftPattern *pattern, int cmap );
|
---|
328 | ~QFontEngineXft();
|
---|
329 |
|
---|
330 | QOpenType *openType() const;
|
---|
331 |
|
---|
332 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
333 |
|
---|
334 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
335 |
|
---|
336 | virtual glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
337 | const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
|
---|
338 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
339 |
|
---|
340 | int ascent() const;
|
---|
341 | int descent() const;
|
---|
342 | int leading() const;
|
---|
343 | int lineThickness() const;
|
---|
344 | int underlinePosition() const;
|
---|
345 | int maxCharWidth() const;
|
---|
346 | int minLeftBearing() const;
|
---|
347 | int minRightBearing() const;
|
---|
348 |
|
---|
349 | int cmap() const;
|
---|
350 | const char *name() const;
|
---|
351 |
|
---|
352 | void setScale( double scale );
|
---|
353 | double scale() const { return _scale; }
|
---|
354 |
|
---|
355 | bool canRender( const QChar *string, int len );
|
---|
356 |
|
---|
357 | Type type() const;
|
---|
358 | XftPattern *pattern() const { return _pattern; }
|
---|
359 |
|
---|
360 | void recalcAdvances( int len, glyph_t *glyphs, advance_t *advances );
|
---|
361 |
|
---|
362 | private:
|
---|
363 | friend class QFontPrivate;
|
---|
364 | XftFont *_font;
|
---|
365 | XftPattern *_pattern;
|
---|
366 | FT_Face _face;
|
---|
367 | QOpenType *_openType;
|
---|
368 | int _cmap;
|
---|
369 | short lbearing;
|
---|
370 | short rbearing;
|
---|
371 | float _scale;
|
---|
372 | enum { widthCacheSize = 0x800, cmapCacheSize = 0x500 };
|
---|
373 | unsigned char widthCache[widthCacheSize];
|
---|
374 | glyph_t cmapCache[cmapCacheSize];
|
---|
375 | };
|
---|
376 | #endif
|
---|
377 |
|
---|
378 | class QFontEngineLatinXLFD;
|
---|
379 |
|
---|
380 | class QFontEngineXLFD : public QFontEngine
|
---|
381 | {
|
---|
382 | public:
|
---|
383 | QFontEngineXLFD( XFontStruct *fs, const char *name, int cmap );
|
---|
384 | ~QFontEngineXLFD();
|
---|
385 |
|
---|
386 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
387 |
|
---|
388 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
389 |
|
---|
390 | virtual glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
391 | const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
|
---|
392 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
393 |
|
---|
394 | int ascent() const;
|
---|
395 | int descent() const;
|
---|
396 | int leading() const;
|
---|
397 | int maxCharWidth() const;
|
---|
398 | int minLeftBearing() const;
|
---|
399 | int minRightBearing() const;
|
---|
400 |
|
---|
401 | int cmap() const;
|
---|
402 | const char *name() const;
|
---|
403 |
|
---|
404 | bool canRender( const QChar *string, int len );
|
---|
405 |
|
---|
406 | void setScale( double scale );
|
---|
407 | double scale() const { return _scale; }
|
---|
408 | Type type() const;
|
---|
409 |
|
---|
410 | Qt::HANDLE handle() const { return (Qt::HANDLE) _fs->fid; }
|
---|
411 |
|
---|
412 | private:
|
---|
413 | friend class QFontPrivate;
|
---|
414 | XFontStruct *_fs;
|
---|
415 | QCString _name;
|
---|
416 | QTextCodec *_codec;
|
---|
417 | float _scale; // needed for printing, to correctly scale font metrics for bitmap fonts
|
---|
418 | int _cmap;
|
---|
419 | short lbearing;
|
---|
420 | short rbearing;
|
---|
421 | enum XlfdTransformations {
|
---|
422 | XlfdTrUnknown,
|
---|
423 | XlfdTrSupported,
|
---|
424 | XlfdTrUnsupported
|
---|
425 | };
|
---|
426 | XlfdTransformations xlfd_transformations;
|
---|
427 |
|
---|
428 | friend class QFontEngineLatinXLFD;
|
---|
429 | };
|
---|
430 |
|
---|
431 | class QFontEngineLatinXLFD : public QFontEngine
|
---|
432 | {
|
---|
433 | public:
|
---|
434 | QFontEngineLatinXLFD( XFontStruct *xfs, const char *name, int cmap );
|
---|
435 | ~QFontEngineLatinXLFD();
|
---|
436 |
|
---|
437 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs,
|
---|
438 | advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
439 |
|
---|
440 | void draw( QPainter *p, int x, int y, const QTextEngine *engine,
|
---|
441 | const QScriptItem *si, int textFlags );
|
---|
442 |
|
---|
443 | virtual glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
444 | const advance_t *advances,
|
---|
445 | const qoffset_t *offsets, int numGlyphs );
|
---|
446 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
447 |
|
---|
448 | int ascent() const;
|
---|
449 | int descent() const;
|
---|
450 | int leading() const;
|
---|
451 | int maxCharWidth() const;
|
---|
452 | int minLeftBearing() const;
|
---|
453 | int minRightBearing() const;
|
---|
454 |
|
---|
455 | int cmap() const { return -1; } // ###
|
---|
456 | const char *name() const;
|
---|
457 |
|
---|
458 | bool canRender( const QChar *string, int len );
|
---|
459 |
|
---|
460 | void setScale( double scale );
|
---|
461 | double scale() const { return _engines[0]->scale(); }
|
---|
462 | Type type() const { return LatinXLFD; }
|
---|
463 |
|
---|
464 | Qt::HANDLE handle() const { return ((QFontEngineXLFD *) _engines[0])->handle(); }
|
---|
465 |
|
---|
466 | private:
|
---|
467 | void findEngine( const QChar &ch );
|
---|
468 |
|
---|
469 | QFontEngine **_engines;
|
---|
470 | int _count;
|
---|
471 |
|
---|
472 | glyph_t glyphIndices [0x200];
|
---|
473 | advance_t glyphAdvances[0x200];
|
---|
474 | glyph_t euroIndex;
|
---|
475 | advance_t euroAdvance;
|
---|
476 | };
|
---|
477 |
|
---|
478 | class QScriptItem;
|
---|
479 | class QTextEngine;
|
---|
480 |
|
---|
481 | #ifndef QT_NO_XFTFREETYPE
|
---|
482 | class QOpenType
|
---|
483 | {
|
---|
484 | public:
|
---|
485 | QOpenType( FT_Face face );
|
---|
486 | ~QOpenType();
|
---|
487 |
|
---|
488 | bool supportsScript( unsigned int script );
|
---|
489 |
|
---|
490 | void applyGSUBFeature(unsigned int feature, bool *where = 0);
|
---|
491 | void applyGPOSFeatures();
|
---|
492 |
|
---|
493 |
|
---|
494 | void init(glyph_t *glyphs, GlyphAttributes *glyphAttributes, int num_glyphs,
|
---|
495 | unsigned short *logClusters, int len, int char_offset = 0);
|
---|
496 | void appendTo(QTextEngine *engine, QScriptItem *si, bool doLogClusters = TRUE);
|
---|
497 |
|
---|
498 | const int *mapping(int &len);
|
---|
499 | inline void setLength(int len) { str->length = len; }
|
---|
500 | unsigned short *glyphs() { return str->string; }
|
---|
501 | private:
|
---|
502 | bool loadTables( FT_ULong script);
|
---|
503 |
|
---|
504 | FT_Face face;
|
---|
505 | TTO_GDEF gdef;
|
---|
506 | TTO_GSUB gsub;
|
---|
507 | TTO_GPOS gpos;
|
---|
508 | FT_UShort script_index;
|
---|
509 | FT_ULong current_script;
|
---|
510 | bool hasGDef : 1;
|
---|
511 | bool hasGSub : 1;
|
---|
512 | bool hasGPos : 1;
|
---|
513 | bool positioned : 1;
|
---|
514 | TTO_GSUB_String *str;
|
---|
515 | TTO_GSUB_String *tmp;
|
---|
516 | TTO_GPOS_Data *positions;
|
---|
517 | GlyphAttributes *tmpAttributes;
|
---|
518 | unsigned short *tmpLogClusters;
|
---|
519 | int length;
|
---|
520 | int orig_nglyphs;
|
---|
521 | };
|
---|
522 | #endif // QT_NO_XFTFREETYPE
|
---|
523 |
|
---|
524 | #elif defined( Q_WS_MAC )
|
---|
525 | #include "qt_mac.h"
|
---|
526 | #include <qmap.h>
|
---|
527 | #include <qcache.h>
|
---|
528 |
|
---|
529 | class QFontEngineMac : public QFontEngine
|
---|
530 | {
|
---|
531 | #if 0
|
---|
532 | ATSFontMetrics *info;
|
---|
533 | #else
|
---|
534 | FontInfo *info;
|
---|
535 | #endif
|
---|
536 | int psize;
|
---|
537 | short fnum;
|
---|
538 | QMacFontInfo *internal_fi;
|
---|
539 | mutable ATSUTextLayout mTextLayout;
|
---|
540 | enum { widthCacheSize = 0x500 };
|
---|
541 | mutable unsigned char widthCache[widthCacheSize];
|
---|
542 | friend class QFont;
|
---|
543 | friend class QGLContext;
|
---|
544 | friend class QFontPrivate;
|
---|
545 | friend class QMacSetFontInfo;
|
---|
546 |
|
---|
547 | public:
|
---|
548 | QFontEngineMac();
|
---|
549 | ~QFontEngineMac();
|
---|
550 |
|
---|
551 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
552 |
|
---|
553 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
554 |
|
---|
555 | glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
556 | const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
|
---|
557 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
558 |
|
---|
559 | int ascent() const { return (int)info->ascent; }
|
---|
560 | int descent() const { return (int)info->descent; }
|
---|
561 | int leading() const { return (int)info->leading; }
|
---|
562 | #if 0
|
---|
563 | int maxCharWidth() const { return (int)info->maxAdvanceWidth; }
|
---|
564 | #else
|
---|
565 | int maxCharWidth() const { return info->widMax; }
|
---|
566 | #endif
|
---|
567 |
|
---|
568 | const char *name() const { return "ATSUI"; }
|
---|
569 |
|
---|
570 | bool canRender( const QChar *string, int len );
|
---|
571 |
|
---|
572 | Type type() const { return QFontEngine::Mac; }
|
---|
573 |
|
---|
574 | void calculateCost();
|
---|
575 |
|
---|
576 | enum { WIDTH=0x01, DRAW=0x02, EXISTS=0x04 };
|
---|
577 | int doTextTask(const QChar *s, int pos, int use_len, int len, uchar task, int =-1, int y=-1,
|
---|
578 | QPaintDevice *dev=NULL, const QRegion *rgn=NULL) const;
|
---|
579 | };
|
---|
580 |
|
---|
581 | #elif defined( Q_WS_WIN )
|
---|
582 |
|
---|
583 | class QFontEngineWin : public QFontEngine
|
---|
584 | {
|
---|
585 | public:
|
---|
586 | QFontEngineWin( const char *name, HDC, HFONT, bool, LOGFONT );
|
---|
587 |
|
---|
588 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
589 |
|
---|
590 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
591 |
|
---|
592 | glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
593 | const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
|
---|
594 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
595 |
|
---|
596 | int ascent() const;
|
---|
597 | int descent() const;
|
---|
598 | int leading() const;
|
---|
599 | int maxCharWidth() const;
|
---|
600 | int minLeftBearing() const;
|
---|
601 | int minRightBearing() const;
|
---|
602 |
|
---|
603 | const char *name() const;
|
---|
604 |
|
---|
605 | bool canRender( const QChar *string, int len );
|
---|
606 |
|
---|
607 | Type type() const;
|
---|
608 |
|
---|
609 | enum { widthCacheSize = 0x800, cmapCacheSize = 0x500 };
|
---|
610 | unsigned char widthCache[widthCacheSize];
|
---|
611 | };
|
---|
612 |
|
---|
613 | #if 0
|
---|
614 | class QFontEngineUniscribe : public QFontEngineWin
|
---|
615 | {
|
---|
616 | public:
|
---|
617 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
618 | bool canRender( const QChar *string, int len );
|
---|
619 |
|
---|
620 | Type type() const;
|
---|
621 | };
|
---|
622 | #endif
|
---|
623 |
|
---|
624 | #elif defined( Q_WS_PM )
|
---|
625 |
|
---|
626 | class QFontEnginePM : public QFontEngine
|
---|
627 | {
|
---|
628 | public:
|
---|
629 | QFontEnginePM( HPS ps, PFATTRS pfa, int pixelSize, int pointSize );
|
---|
630 | virtual ~QFontEnginePM() { delete[] widthCache; }
|
---|
631 |
|
---|
632 | Error stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const;
|
---|
633 |
|
---|
634 | void draw( QPainter *p, int x, int y, const QTextEngine *engine, const QScriptItem *si, int textFlags );
|
---|
635 |
|
---|
636 | glyph_metrics_t boundingBox( const glyph_t *glyphs,
|
---|
637 | const advance_t *advances, const qoffset_t *offsets, int numGlyphs );
|
---|
638 | glyph_metrics_t boundingBox( glyph_t glyph );
|
---|
639 |
|
---|
640 | int ascent() const;
|
---|
641 | int descent() const;
|
---|
642 | int leading() const;
|
---|
643 | int maxCharWidth() const;
|
---|
644 | int minLeftBearing() const;
|
---|
645 | int minRightBearing() const;
|
---|
646 |
|
---|
647 | //@@TODO (dmik): need other implementation?
|
---|
648 | const char *name() const { return 0; }
|
---|
649 |
|
---|
650 | bool canRender( const QChar *string, int len );
|
---|
651 |
|
---|
652 | Type type() const;
|
---|
653 |
|
---|
654 | //@@TODO (dmik): the current implementation of font-related code does not
|
---|
655 | // support true unicode (chars and strings are converted using
|
---|
656 | // QString::local8bit), so 256 is enough. It will be changed later (when,
|
---|
657 | // for example, ft2lib will be used). See also stringToCMap() implementation.
|
---|
658 | enum { widthCacheSize = 256 };
|
---|
659 | unsigned char *widthCache;
|
---|
660 | };
|
---|
661 |
|
---|
662 | #endif
|
---|
663 |
|
---|
664 | #endif
|
---|