1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qfontengine_s60_p.h"
43 #include "qtextengine_p.h"
44 #include "qendian.h"
45 #include "qglobal.h"
46 #include <private/qapplication_p.h>
47 #include "qimage.h"
48 #include <private/qt_s60_p.h>
49 #include <private/qpixmap_raster_symbian_p.h>
50 
51 #include <e32base.h>
52 #include <e32std.h>
53 #include <eikenv.h>
54 #include <gdi.h>
55 #if defined(Q_SYMBIAN_HAS_GLYPHOUTLINE_API)
56 #include <graphics/gdi/gdiplatapi.h>
57 #endif // Q_SYMBIAN_HAS_GLYPHOUTLINE_API
58 
59 // Replication of TGetFontTableParam & friends.
60 // There is unfortunately no compile time flag like SYMBIAN_FONT_TABLE_API
61 // that would help us to only replicate these things for Symbian versions
62 // that do not yet have the font table Api. Symbian's public SDK does
63 // generally not define any usable macros.
64 class QSymbianTGetFontTableParam
65 {
66 public:
67     TUint32 iTag;
68     TAny *iContent;
69     TInt iLength;
70 };
71 const TUid QSymbianKFontGetFontTable      = {0x102872C1};
72 const TUid QSymbianKFontReleaseFontTable  = {0x2002AC24};
73 
74 QT_BEGIN_NAMESPACE
75 
QSymbianTypeFaceExtras(CFont * cFont,COpenFont * openFont)76 QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* cFont, COpenFont *openFont)
77     : m_cFont(cFont)
78     , m_symbolCMap(false)
79     , m_openFont(openFont)
80     , m_cmapSize(0)
81 {
82     if (!symbianFontTableApiAvailable()) {
83         TAny *trueTypeExtension = NULL;
84         m_openFont->ExtendedInterface(KUidOpenFontTrueTypeExtension, trueTypeExtension);
85         m_trueTypeExtension = static_cast<MOpenFontTrueTypeExtension*>(trueTypeExtension);
86         Q_ASSERT(m_trueTypeExtension);
87     }
88 }
89 
~QSymbianTypeFaceExtras()90 QSymbianTypeFaceExtras::~QSymbianTypeFaceExtras()
91 {
92     if (symbianFontTableApiAvailable())
93         S60->screenDevice()->ReleaseFont(m_cFont);
94 }
95 
getSfntTable(uint tag) const96 QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const
97 {
98     if (symbianFontTableApiAvailable()) {
99         QSymbianTGetFontTableParam fontTableParams = { tag, 0, 0 };
100         if (m_cFont->ExtendedFunction(QSymbianKFontGetFontTable, &fontTableParams) == KErrNone) {
101             const char* const fontTableContent =
102                     static_cast<const char *>(fontTableParams.iContent);
103             const QByteArray fontTable(fontTableContent, fontTableParams.iLength);
104             m_cFont->ExtendedFunction(QSymbianKFontReleaseFontTable, &fontTableParams);
105             return fontTable;
106         }
107         return QByteArray();
108     } else {
109         Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag));
110         TInt error = KErrNone;
111         TInt tableByteLength = 0;
112         TAny *table = m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength);
113         Q_CHECK_PTR(table);
114         const QByteArray result(static_cast<const char*>(table), tableByteLength);
115         m_trueTypeExtension->ReleaseTrueTypeTable(table);
116         return result;
117     }
118 }
119 
getSfntTableData(uint tag,uchar * buffer,uint * length) const120 bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *length) const
121 {
122     bool result = true;
123     if (symbianFontTableApiAvailable()) {
124         QSymbianTGetFontTableParam fontTableParams = { tag, 0, 0 };
125         if (m_cFont->ExtendedFunction(QSymbianKFontGetFontTable, &fontTableParams) == KErrNone) {
126             if (*length > 0 && *length < fontTableParams.iLength) {
127                 result = false; // Caller did not allocate enough memory
128             } else {
129                 *length = fontTableParams.iLength;
130                 if (buffer)
131                     memcpy(buffer, fontTableParams.iContent, fontTableParams.iLength);
132             }
133             m_cFont->ExtendedFunction(QSymbianKFontReleaseFontTable, &fontTableParams);
134         } else {
135             result = false;
136         }
137     } else {
138         if (!m_trueTypeExtension->HasTrueTypeTable(tag))
139             return false;
140 
141         TInt error = KErrNone;
142         TInt tableByteLength;
143         TAny *table = m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength);
144         Q_CHECK_PTR(table);
145 
146         if (error != KErrNone) {
147             return false;
148         } else if (*length > 0 && *length < tableByteLength) {
149             result = false; // Caller did not allocate enough memory
150         } else {
151             *length = tableByteLength;
152             if (buffer)
153                 memcpy(buffer, table, tableByteLength);
154         }
155 
156         m_trueTypeExtension->ReleaseTrueTypeTable(table);
157     }
158     return result;
159 }
160 
cmap() const161 const uchar *QSymbianTypeFaceExtras::cmap() const
162 {
163     if (m_cmapTable.isNull()) {
164         const QByteArray cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p'));
165         const uchar *cmap = QFontEngine::getCMap(reinterpret_cast<const uchar *>
166                 (cmapTable.constData()), cmapTable.size(), &m_symbolCMap, &m_cmapSize);
167         m_cmapTable = QByteArray(reinterpret_cast<const char *>(cmap), m_cmapSize);
168     }
169     return reinterpret_cast<const uchar *>(m_cmapTable.constData());
170 }
171 
isSymbolCMap() const172 bool QSymbianTypeFaceExtras::isSymbolCMap() const
173 {
174     return m_symbolCMap;
175 }
176 
fontOwner() const177 CFont *QSymbianTypeFaceExtras::fontOwner() const
178 {
179     return m_cFont;
180 }
181 
unitsPerEm() const182 QFixed QSymbianTypeFaceExtras::unitsPerEm() const
183 {
184     if (m_unitsPerEm.value() != 0)
185         return m_unitsPerEm;
186     const QByteArray head = getSfntTable(MAKE_TAG('h', 'e', 'a', 'd'));
187     const int unitsPerEmOffset = 18;
188     if (head.size() > unitsPerEmOffset + sizeof(quint16)) {
189         const uchar* tableData = reinterpret_cast<const uchar*>(head.constData());
190         const uchar* unitsPerEm = tableData + unitsPerEmOffset;
191         m_unitsPerEm = qFromBigEndian<quint16>(unitsPerEm);
192     } else {
193         // Bitmap font? Corrupt font?
194         // We return -1 and let the QFontEngineS60 return the pixel size.
195         m_unitsPerEm = -1;
196     }
197     return m_unitsPerEm;
198 }
199 
symbianFontTableApiAvailable()200 bool QSymbianTypeFaceExtras::symbianFontTableApiAvailable()
201 {
202     enum FontTableApiAvailability {
203         Unknown,
204         Available,
205         Unavailable
206     };
207     static FontTableApiAvailability availability =
208             QSysInfo::symbianVersion() < QSysInfo::SV_SF_3 ?
209                 Unavailable : Unknown;
210     if (availability == Unknown) {
211         // Actually, we should ask CFeatureDiscovery::IsFeatureSupportedL()
212         // with FfFontTable here. But since at the time of writing, the
213         // FfFontTable flag check either gave false positives or false
214         // negatives. Here comes an implicit check via CFont::ExtendedFunction.
215         QSymbianTGetFontTableParam fontTableParams = {
216             MAKE_TAG('O', 'S', '/', '2'), 0, 0 };
217         QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
218         CFont *font;
219         const TInt getFontErr = S60->screenDevice()->GetNearestFontInTwips(font, TFontSpec());
220         Q_ASSERT(getFontErr == KErrNone);
221         if (font->ExtendedFunction(QSymbianKFontGetFontTable, &fontTableParams) == KErrNone) {
222             font->ExtendedFunction(QSymbianKFontReleaseFontTable, &fontTableParams);
223             availability = Available;
224         } else {
225             availability = Unavailable;
226         }
227         S60->screenDevice()->ReleaseFont(font);
228         lock.relock();
229     }
230     return availability == Available;
231 }
232 
233 // duplicated from qfontengine_xyz.cpp
getChar(const QChar * str,int & i,const int len)234 static inline unsigned int getChar(const QChar *str, int &i, const int len)
235 {
236     uint ucs4 = str[i].unicode();
237     if (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate()) {
238         ++i;
239         ucs4 = QChar::surrogateToUcs4(ucs4, str[i].unicode());
240     }
241     return ucs4;
242 }
243 
244 extern QString qt_symbian_fontNameWithAppFontMarker(const QString &fontName); // qfontdatabase_s60.cpp
245 
fontWithSize(qreal size) const246 CFont *QFontEngineS60::fontWithSize(qreal size) const
247 {
248     CFont *result = 0;
249     const QString family = qt_symbian_fontNameWithAppFontMarker(QFontEngine::fontDef.family);
250     TFontSpec fontSpec(qt_QString2TPtrC(family), TInt(size));
251     fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
252     fontSpec.iFontStyle.SetPosture(QFontEngine::fontDef.style == QFont::StyleNormal?EPostureUpright:EPostureItalic);
253     fontSpec.iFontStyle.SetStrokeWeight(QFontEngine::fontDef.weight > QFont::Normal?EStrokeWeightBold:EStrokeWeightNormal);
254     const TInt errorCode = S60->screenDevice()->GetNearestFontToDesignHeightInPixels(result, fontSpec);
255     Q_ASSERT(result && (errorCode == 0));
256     return result;
257 }
258 
setFontScale(qreal scale)259 void QFontEngineS60::setFontScale(qreal scale)
260 {
261     if (qFuzzyCompare(scale, qreal(1))) {
262         if (!m_originalFont)
263             m_originalFont = fontWithSize(m_originalFontSizeInPixels);
264         m_activeFont = m_originalFont;
265     } else {
266         const qreal scaledFontSizeInPixels = m_originalFontSizeInPixels * scale;
267         if (!m_scaledFont ||
268                 (TInt(scaledFontSizeInPixels) != TInt(m_scaledFontSizeInPixels))) {
269             releaseFont(m_scaledFont);
270             m_scaledFontSizeInPixels = scaledFontSizeInPixels;
271             m_scaledFont = fontWithSize(m_scaledFontSizeInPixels);
272         }
273         m_activeFont = m_scaledFont;
274     }
275 }
276 
releaseFont(CFont * & font)277 void QFontEngineS60::releaseFont(CFont *&font)
278 {
279     if (font) {
280         S60->screenDevice()->ReleaseFont(font);
281         font = 0;
282     }
283 }
284 
QFontEngineS60(const QFontDef & request,const QSymbianTypeFaceExtras * extras)285 QFontEngineS60::QFontEngineS60(const QFontDef &request, const QSymbianTypeFaceExtras *extras)
286     : m_extras(extras)
287     , m_originalFont(0)
288     , m_originalFontSizeInPixels((request.pixelSize >= 0)?
289             request.pixelSize:pointsToPixels(request.pointSize))
290     , m_scaledFont(0)
291     , m_scaledFontSizeInPixels(0)
292     , m_activeFont(0)
293 {
294     QFontEngine::fontDef = request;
295     setFontScale(1.0);
296     cache_cost = sizeof(QFontEngineS60);
297 }
298 
~QFontEngineS60()299 QFontEngineS60::~QFontEngineS60()
300 {
301     if (QThread::currentThread() == thread()) {
302         releaseFont(m_originalFont);
303         releaseFont(m_scaledFont);
304     }
305 }
306 
emSquareSize() const307 QFixed QFontEngineS60::emSquareSize() const
308 {
309     const QFixed unitsPerEm = m_extras->unitsPerEm();
310     return unitsPerEm.toInt() == -1 ?
311                 QFixed::fromReal(m_originalFontSizeInPixels) : unitsPerEm;
312 }
313 
stringToCMap(const QChar * characters,int len,QGlyphLayout * glyphs,int * nglyphs,QTextEngine::ShaperFlags flags) const314 bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
315 {
316     if (*nglyphs < len) {
317         *nglyphs = len;
318         return false;
319     }
320 
321     HB_Glyph *g = glyphs->glyphs;
322     const unsigned char* cmap = m_extras->cmap();
323     const bool isRtl = (flags & QTextEngine::RightToLeft);
324     for (int i = 0; i < len; ++i) {
325         const unsigned int uc = getChar(characters, i, len);
326         *g++ = QFontEngine::getTrueTypeGlyphIndex(cmap,
327                                                   m_cmapSize,
328                         (isRtl && !m_extras->isSymbolCMap()) ? QChar::mirroredChar(uc) : uc);
329     }
330 
331     glyphs->numGlyphs = g - glyphs->glyphs;
332     *nglyphs = glyphs->numGlyphs;
333 
334     if (flags & QTextEngine::GlyphIndicesOnly)
335         return true;
336 
337     recalcAdvances(glyphs, flags);
338     return true;
339 }
340 
recalcAdvances(QGlyphLayout * glyphs,QTextEngine::ShaperFlags flags) const341 void QFontEngineS60::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
342 {
343     Q_UNUSED(flags);
344     TOpenFontCharMetrics metrics;
345     const TUint8 *glyphBitmapBytes;
346     TSize glyphBitmapSize;
347     for (int i = 0; i < glyphs->numGlyphs; i++) {
348         getCharacterData(glyphs->glyphs[i], metrics, glyphBitmapBytes, glyphBitmapSize);
349         glyphs->advances_x[i] = metrics.HorizAdvance();
350         glyphs->advances_y[i] = 0;
351     }
352 }
353 
354 #ifdef Q_SYMBIAN_HAS_GLYPHOUTLINE_API
355 static bool parseGlyphPathData(const char *dataStr, const char *dataEnd, QPainterPath &path,
356                                qreal fontPixelSize, const QPointF &offset, bool hinted);
357 #endif //Q_SYMBIAN_HAS_GLYPHOUTLINE_API
358 
addGlyphsToPath(glyph_t * glyphs,QFixedPoint * positions,int nglyphs,QPainterPath * path,QTextItem::RenderFlags flags)359 void QFontEngineS60::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions,
360                                      int nglyphs, QPainterPath *path,
361                                      QTextItem::RenderFlags flags)
362 {
363 #ifdef Q_SYMBIAN_HAS_GLYPHOUTLINE_API
364     Q_UNUSED(flags)
365     RGlyphOutlineIterator iterator;
366     const TInt error = iterator.Open(*m_activeFont, glyphs, nglyphs);
367     if (KErrNone != error)
368         return;
369     const qreal fontSizeInPixels = qreal(m_activeFont->HeightInPixels());
370     int count = 0;
371     do {
372         const TUint8* outlineUint8 = iterator.Outline();
373         const char* const outlineChar = reinterpret_cast<const char*>(outlineUint8);
374         const char* const outlineEnd = outlineChar + iterator.OutlineLength();
375         parseGlyphPathData(outlineChar, outlineEnd, *path, fontSizeInPixels,
376                 positions[count++].toPointF(), false);
377     } while(KErrNone == iterator.Next() && count <= nglyphs);
378     iterator.Close();
379 #else // Q_SYMBIAN_HAS_GLYPHOUTLINE_API
380     QFontEngine::addGlyphsToPath(glyphs, positions, nglyphs, path, flags);
381 #endif //Q_SYMBIAN_HAS_GLYPHOUTLINE_API
382 }
383 
alphaMapForGlyph(glyph_t glyph)384 QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph)
385 {
386     // Note: On some Symbian versions (apparently <= Symbian^1), this
387     // function will return gray values 0x00, 0x10 ... 0xe0, 0xf0 due
388     // to a bug. The glyphs are nowhere perfectly opaque.
389     // This has been fixed for Symbian^3.
390 
391     TOpenFontCharMetrics metrics;
392     const TUint8 *glyphBitmapBytes;
393     TSize glyphBitmapSize;
394     getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize);
395     QImage result(glyphBitmapBytes, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight, glyphBitmapSize.iWidth, QImage::Format_Indexed8);
396     result.setColorTable(grayPalette());
397     return result;
398 }
399 
boundingBox(const QGlyphLayout & glyphs)400 glyph_metrics_t QFontEngineS60::boundingBox(const QGlyphLayout &glyphs)
401 {
402    if (glyphs.numGlyphs == 0)
403         return glyph_metrics_t();
404 
405     QFixed w = 0;
406     for (int i = 0; i < glyphs.numGlyphs; ++i)
407         w += glyphs.effectiveAdvance(i);
408 
409     return glyph_metrics_t(0, -ascent(), w - lastRightBearing(glyphs), ascent()+descent()+1, w, 0);
410 }
411 
boundingBox_const(glyph_t glyph) const412 glyph_metrics_t QFontEngineS60::boundingBox_const(glyph_t glyph) const
413 {
414     TOpenFontCharMetrics metrics;
415     const TUint8 *glyphBitmapBytes;
416     TSize glyphBitmapSize;
417     getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize);
418     const glyph_metrics_t result(
419         metrics.HorizBearingX(),
420         -metrics.HorizBearingY(),
421         metrics.Width(),
422         metrics.Height(),
423         metrics.HorizAdvance(),
424         0
425     );
426     return result;
427 }
428 
boundingBox(glyph_t glyph)429 glyph_metrics_t QFontEngineS60::boundingBox(glyph_t glyph)
430 {
431     return boundingBox_const(glyph);
432 }
433 
ascent() const434 QFixed QFontEngineS60::ascent() const
435 {
436     // Workaround for QTBUG-8013
437     // Stroke based fonts may return an incorrect FontMaxAscent of 0.
438     const QFixed ascent = m_originalFont->FontMaxAscent();
439     return (ascent > 0) ? ascent : QFixed::fromReal(m_originalFontSizeInPixels) - descent();
440 }
441 
descent() const442 QFixed QFontEngineS60::descent() const
443 {
444     return m_originalFont->FontMaxDescent();
445 }
446 
leading() const447 QFixed QFontEngineS60::leading() const
448 {
449     return 0;
450 }
451 
maxCharWidth() const452 qreal QFontEngineS60::maxCharWidth() const
453 {
454     return m_originalFont->MaxCharWidthInPixels();
455 }
456 
name() const457 const char *QFontEngineS60::name() const
458 {
459     return "QFontEngineS60";
460 }
461 
canRender(const QChar * string,int len)462 bool QFontEngineS60::canRender(const QChar *string, int len)
463 {
464     const unsigned char *cmap = m_extras->cmap();
465     for (int i = 0; i < len; ++i) {
466         const unsigned int uc = getChar(string, i, len);
467         if (QFontEngine::getTrueTypeGlyphIndex(cmap, m_cmapSize, uc) == 0)
468             return false;
469     }
470     return true;
471 }
472 
getSfntTable(uint tag) const473 QByteArray QFontEngineS60::getSfntTable(uint tag) const
474 {
475     return m_extras->getSfntTable(tag);
476 }
477 
getSfntTableData(uint tag,uchar * buffer,uint * length) const478 bool QFontEngineS60::getSfntTableData(uint tag, uchar *buffer, uint *length) const
479 {
480     return m_extras->getSfntTableData(tag, buffer, length);
481 }
482 
type() const483 QFontEngine::Type QFontEngineS60::type() const
484 {
485     return QFontEngine::S60FontEngine;
486 }
487 
getCharacterData(glyph_t glyph,TOpenFontCharMetrics & metrics,const TUint8 * & bitmap,TSize & bitmapSize) const488 void QFontEngineS60::getCharacterData(glyph_t glyph, TOpenFontCharMetrics& metrics, const TUint8*& bitmap, TSize& bitmapSize) const
489 {
490     // Setting the most significant bit tells GetCharacterData
491     // that 'code' is a Glyph ID, rather than a UTF-16 value
492     const TUint specialCode = (TUint)glyph | 0x80000000;
493 
494     const CFont::TCharacterDataAvailability availability =
495             m_activeFont->GetCharacterData(specialCode, metrics, bitmap, bitmapSize);
496     const glyph_t fallbackGlyph = '?';
497     if (availability != CFont::EAllCharacterData) {
498         const CFont::TCharacterDataAvailability fallbackAvailability =
499                 m_activeFont->GetCharacterData(fallbackGlyph, metrics, bitmap, bitmapSize);
500         Q_ASSERT(fallbackAvailability == CFont::EAllCharacterData);
501     }
502 }
503 
504 #ifdef Q_SYMBIAN_HAS_GLYPHOUTLINE_API
skipSpacesAndComma(const char * & str,const char * const strEnd)505 static inline void skipSpacesAndComma(const char* &str, const char* const strEnd)
506 {
507     while (str <= strEnd && (*str == ' ' || *str == ','))
508         ++str;
509 }
510 
parseGlyphPathData(const char * svgPath,const char * svgPathEnd,QPainterPath & path,qreal fontPixelSize,const QPointF & offset,bool hinted)511 static bool parseGlyphPathData(const char *svgPath, const char *svgPathEnd, QPainterPath &path,
512                                qreal fontPixelSize, const QPointF &offset, bool hinted)
513 {
514     Q_UNUSED(hinted)
515     QPointF p1, p2, firstSubPathPoint;
516     qreal *elementValues[] =
517         {&p1.rx(), &p1.ry(), &p2.rx(), &p2.ry()};
518     const int unitsPerEm = 2048; // See: http://en.wikipedia.org/wiki/Em_%28typography%29
519     const qreal resizeFactor = fontPixelSize / unitsPerEm;
520 
521     while (svgPath < svgPathEnd) {
522         skipSpacesAndComma(svgPath, svgPathEnd);
523         const char pathElem = *svgPath++;
524         skipSpacesAndComma(svgPath, svgPathEnd);
525 
526         if (pathElem != 'Z') {
527             char *endStr = 0;
528             int elementValuesCount = 0;
529             for (int i = 0; i < 4; ++i) { // 4 = size of elementValues[]
530                 qreal coordinateValue = strtod(svgPath, &endStr);
531                 if (svgPath == endStr)
532                     break;
533                 if (i % 2) // Flip vertically
534                     coordinateValue = -coordinateValue;
535                 *elementValues[i] = coordinateValue * resizeFactor;
536                 elementValuesCount++;
537                 svgPath = endStr;
538                 skipSpacesAndComma(svgPath, svgPathEnd);
539             }
540             p1 += offset;
541             if (elementValuesCount == 2)
542                 p2 = firstSubPathPoint;
543             else
544                 p2 += offset;
545         }
546 
547         switch (pathElem) {
548         case 'M':
549             firstSubPathPoint = p1;
550             path.moveTo(p1);
551             break;
552         case 'Z':
553             path.closeSubpath();
554             break;
555         case 'L':
556             path.lineTo(p1);
557             break;
558         case 'Q':
559             path.quadTo(p1, p2);
560             break;
561         default:
562             return false;
563         }
564     }
565     return true;
566 }
567 #endif // Q_SYMBIAN_HAS_GLYPHOUTLINE_API
568 
569 QT_END_NAMESPACE
570