source: trunk/src/gui/text/qabstractfontengine_qws.cpp@ 632

Last change on this file since 632 was 561, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 22.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this 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 have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qabstractfontengine_qws.h"
43#include "qabstractfontengine_p.h"
44
45#include <private/qtextengine_p.h>
46#include <private/qpaintengine_raster_p.h>
47
48#include <qmath.h>
49
50QT_BEGIN_NAMESPACE
51
52class QFontEngineInfoPrivate
53{
54public:
55 inline QFontEngineInfoPrivate()
56 : pixelSize(0), weight(QFont::Normal), style(QFont::StyleNormal)
57 {}
58
59 QString family;
60 qreal pixelSize;
61 int weight;
62 QFont::Style style;
63 QList<QFontDatabase::WritingSystem> writingSystems;
64};
65
66/*!
67 \class QFontEngineInfo
68 \preliminary
69 \brief The QFontEngineInfo class describes a specific font provided by a font engine plugin.
70 \since 4.3
71 \ingroup qws
72
73 \tableofcontents
74
75 QFontEngineInfo is used to describe a request of a font to a font engine plugin as well as to
76 describe the actual fonts a plugin provides.
77
78 \sa QAbstractFontEngine, QFontEnginePlugin
79*/
80
81/*!
82 Constructs a new empty QFontEngineInfo.
83*/
84QFontEngineInfo::QFontEngineInfo()
85{
86 d = new QFontEngineInfoPrivate;
87}
88
89/*!
90 Constructs a new QFontEngineInfo with the specified \a family.
91 The resulting object represents a freely scalable font with normal
92 weight and style.
93*/
94QFontEngineInfo::QFontEngineInfo(const QString &family)
95{
96 d = new QFontEngineInfoPrivate;
97 d->family = family;
98}
99
100/*!
101 Creates a new font engine info object with the same attributes as \a other.
102*/
103QFontEngineInfo::QFontEngineInfo(const QFontEngineInfo &other)
104 : d(new QFontEngineInfoPrivate(*other.d))
105{
106}
107
108/*!
109 Assigns \a other to this font engine info object, and returns a reference
110 to this.
111*/
112QFontEngineInfo &QFontEngineInfo::operator=(const QFontEngineInfo &other)
113{
114 *d = *other.d;
115 return *this;
116}
117
118/*!
119 Destroys this QFontEngineInfo object.
120*/
121QFontEngineInfo::~QFontEngineInfo()
122{
123 delete d;
124}
125
126/*!
127 \property QFontEngineInfo::family
128 the family name of the font
129*/
130
131void QFontEngineInfo::setFamily(const QString &family)
132{
133 d->family = family;
134}
135
136QString QFontEngineInfo::family() const
137{
138 return d->family;
139}
140
141/*!
142 \property QFontEngineInfo::pixelSize
143 the pixel size of the font
144
145 A pixel size of 0 represents a freely scalable font.
146*/
147
148void QFontEngineInfo::setPixelSize(qreal size)
149{
150 d->pixelSize = size;
151}
152
153qreal QFontEngineInfo::pixelSize() const
154{
155 return d->pixelSize;
156}
157
158/*!
159 \property QFontEngineInfo::weight
160 the weight of the font
161
162 The value should be from the \l{QFont::Weight} enumeration.
163*/
164
165void QFontEngineInfo::setWeight(int weight)
166{
167 d->weight = weight;
168}
169
170int QFontEngineInfo::weight() const
171{
172 return d->weight;
173}
174
175/*!
176 \property QFontEngineInfo::style
177 the style of the font
178*/
179
180void QFontEngineInfo::setStyle(QFont::Style style)
181{
182 d->style = style;
183}
184
185QFont::Style QFontEngineInfo::style() const
186{
187 return d->style;
188}
189
190/*!
191 \property QFontEngineInfo::writingSystems
192 the writing systems supported by the font
193
194 An empty list means that any writing system is supported.
195*/
196
197QList<QFontDatabase::WritingSystem> QFontEngineInfo::writingSystems() const
198{
199 return d->writingSystems;
200}
201
202void QFontEngineInfo::setWritingSystems(const QList<QFontDatabase::WritingSystem> &writingSystems)
203{
204 d->writingSystems = writingSystems;
205}
206
207class QFontEnginePluginPrivate : public QObjectPrivate
208{
209 Q_DECLARE_PUBLIC(QFontEnginePlugin)
210
211 QString foundry;
212};
213
214/*!
215 \class QFontEnginePlugin
216 \preliminary
217 \brief The QFontEnginePlugin class is the base class for font engine factory plugins in Qt for Embedded Linux.
218 \since 4.3
219 \ingroup qws
220 \ingroup plugins
221
222 \tableofcontents
223
224 QFontEnginePlugin is provided by font engine plugins to create
225 instances of subclasses of QAbstractFontEngine.
226
227 The member functions create() and availableFontEngines() must be
228 implemented.
229
230 \sa QAbstractFontEngine, QFontEngineInfo
231*/
232
233/*!
234 Creates a font engine plugin that creates font engines with the
235 specified \a foundry and \a parent.
236*/
237QFontEnginePlugin::QFontEnginePlugin(const QString &foundry, QObject *parent)
238 : QObject(*new QFontEnginePluginPrivate, parent)
239{
240 Q_D(QFontEnginePlugin);
241 d->foundry = foundry;
242}
243
244/*!
245 Destroys this font engine plugin.
246*/
247QFontEnginePlugin::~QFontEnginePlugin()
248{
249}
250
251/*!
252 Returns a list of foundries the font engine plugin provides.
253 The default implementation returns the foundry specified with the constructor.
254*/
255QStringList QFontEnginePlugin::keys() const
256{
257 Q_D(const QFontEnginePlugin);
258 return QStringList(d->foundry);
259}
260
261/*!
262 \fn QAbstractFontEngine *QFontEnginePlugin::create(const QFontEngineInfo &info)
263
264 Implemented in subclasses to create a new font engine that provides a font that
265 matches \a info.
266*/
267
268/*!
269 \fn QList<QFontEngineInfo> QFontEnginePlugin::availableFontEngines() const
270
271 Implemented in subclasses to return a list of QFontEngineInfo objects that represents all font
272 engines the plugin can create.
273*/
274
275class QAbstractFontEnginePrivate : public QObjectPrivate
276{
277 Q_DECLARE_PUBLIC(QAbstractFontEngine)
278public:
279};
280
281//The <classname> class is|provides|contains|specifies...
282/*!
283 \class QAbstractFontEngine
284 \preliminary
285 \brief The QAbstractFontEngine class is the base class for font engine plugins in Qt for Embedded Linux.
286 \since 4.3
287 \ingroup qws
288
289 \tableofcontents
290
291 QAbstractFontEngine is implemented by font engine plugins through QFontEnginePlugin.
292
293 \sa QFontEnginePlugin, QFontEngineInfo
294*/
295
296/*!
297 \enum QAbstractFontEngine::Capability
298
299 This enum describes the capabilities of a font engine.
300
301 \value CanRenderGlyphs_Gray The font engine can render individual glyphs into 8 bpp images.
302 \value CanRenderGlyphs_Mono The font engine can render individual glyphs into 1 bpp images.
303 \value CanRenderGlyphs The font engine can render individual glyphs into images.
304 \value CanOutlineGlyphs The font engine can convert glyphs to painter paths.
305*/
306
307/*!
308 \enum QAbstractFontEngine::FontProperty
309
310 This enum describes the properties of a font provided by a font engine.
311
312 \value Ascent The ascent of the font, specified as a 26.6 fixed point value.
313 \value Descent The descent of the font, specified as a 26.6 fixed point value.
314 \value Leading The leading of the font, specified as a 26.6 fixed point value.
315 \value XHeight The 'x' height of the font, specified as a 26.6 fixed point value.
316 \value AverageCharWidth The average character width of the font, specified as a 26.6 fixed point value.
317 \value LineThickness The thickness of the underline and strikeout lines for the font, specified as a 26.6 fixed point value.
318 \value UnderlinePosition The distance from the base line to the underline position for the font, specified as a 26.6 fixed point value.
319 \value MaxCharWidth The width of the widest character in the font, specified as a 26.6 fixed point value.
320 \value MinLeftBearing The minimum left bearing of the font, specified as a 26.6 fixed point value.
321 \value MinRightBearing The maximum right bearing of the font, specified as a 26.6 fixed point value.
322 \value GlyphCount The number of glyphs in the font, specified as an integer value.
323 \value CacheGlyphsHint A boolean value specifying whether rendered glyphs should be cached by Qt.
324 \value OutlineGlyphsHint A boolean value specifying whether the font engine prefers outline drawing over image rendering for uncached glyphs.
325*/
326
327/*!
328 \enum QAbstractFontEngine::TextShapingFlag
329
330 This enum describes flags controlling conversion of characters to glyphs and their metrics.
331
332 \value RightToLeft The text is used in a right-to-left context.
333 \value ReturnDesignMetrics Return font design metrics instead of pixel metrics.
334*/
335
336/*!
337 \typedef QAbstractFontEngine::Fixed
338
339 This type is \c int, interpreted as a 26.6 fixed point value.
340*/
341
342/*!
343 \class QAbstractFontEngine::GlyphMetrics
344 \brief QAbstractFontEngine::GlyphMetrics defines the metrics of a single glyph.
345 \preliminary
346 \since 4.3
347*/
348
349/*!
350 \variable QAbstractFontEngine::GlyphMetrics::x
351
352 The horizontal offset from the origin.
353*/
354
355/*!
356 \fn QAbstractFontEngine::GlyphMetrics::GlyphMetrics()
357
358 Constructs an empty glyph metrics object with all values
359 set to zero.
360*/
361
362/*!
363 \variable QAbstractFontEngine::GlyphMetrics::y
364
365 The vertical offset from the origin (baseline).
366*/
367
368/*!
369 \variable QAbstractFontEngine::GlyphMetrics::width
370
371 The width of the glyph.
372*/
373
374/*!
375 \variable QAbstractFontEngine::GlyphMetrics::height
376
377 The height of the glyph.
378*/
379
380/*!
381 \variable QAbstractFontEngine::GlyphMetrics::advance
382
383 The advance of the glyph.
384*/
385
386/*!
387 \class QAbstractFontEngine::FixedPoint
388 \brief QAbstractFontEngine::FixedPoint defines a point in the place using 26.6 fixed point precision.
389 \preliminary
390 \since 4.3
391*/
392
393/*!
394 \variable QAbstractFontEngine::FixedPoint::x
395
396 The x coordinate of this point.
397*/
398
399/*!
400 \variable QAbstractFontEngine::FixedPoint::y
401
402 The y coordinate of this point.
403*/
404
405/*!
406 Constructs a new QAbstractFontEngine with the given \a parent.
407*/
408QAbstractFontEngine::QAbstractFontEngine(QObject *parent)
409 : QObject(*new QAbstractFontEnginePrivate, parent)
410{
411}
412
413/*!
414 Destroys this QAbstractFontEngine object.
415*/
416QAbstractFontEngine::~QAbstractFontEngine()
417{
418}
419
420/*!