summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfontengine_s60.cpp98
-rw-r--r--src/gui/text/qfontengine_s60_p.h7
2 files changed, 103 insertions, 2 deletions
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp
index 52a2c3c4ce..925b3bf5fd 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -50,9 +50,9 @@
#include <e32std.h>
#include <eikenv.h>
#include <gdi.h>
-#ifdef Q_SYMBIAN_HAS_FONTTABLE_API
+#if defined(Q_SYMBIAN_HAS_FONTTABLE_API) || defined(Q_SYMBIAN_HAS_GLYPHOUTLINE_API)
#include <graphics/gdi/gdiplatapi.h>
-#endif // Q_SYMBIAN_HAS_FONTTABLE_API
+#endif // Q_SYMBIAN_HAS_FONTTABLE_API || Q_SYMBIAN_HAS_GLYPHOUTLINE_API
QT_BEGIN_NAMESPACE
@@ -279,6 +279,35 @@ void QFontEngineS60::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
}
}
+#ifdef Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+static bool parseGlyphPathData(const char *dataStr, const char *dataEnd, QPainterPath &path,
+ qreal fontPixelSize, const QPointF &offset, bool hinted);
+#endif //Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+
+void QFontEngineS60::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions,
+ int nglyphs, QPainterPath *path,
+ QTextItem::RenderFlags flags)
+{
+#ifdef Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+ Q_UNUSED(flags)
+ RGlyphOutlineIterator iterator;
+ const TInt error = iterator.Open(*m_activeFont, glyphs, nglyphs);
+ if (KErrNone != error)
+ return;
+ const qreal fontSizeInPixels = qreal(m_activeFont->HeightInPixels());
+ int count = 0;
+ do {
+ const TUint8* outlineUint8 = iterator.Outline();
+ const char* const outlineChar = reinterpret_cast<const char*>(outlineUint8);
+ const char* const outlineEnd = outlineChar + iterator.OutlineLength();
+ parseGlyphPathData(outlineChar, outlineEnd, *path, fontSizeInPixels,
+ positions[count++].toPointF(), false);
+ } while(KErrNone == iterator.Next() && count <= nglyphs);
+#else // Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+ QFontEngine::addGlyphsToPath(glyphs, positions, nglyphs, path, flags);
+#endif //Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+}
+
QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph)
{
TOpenFontCharMetrics metrics;
@@ -410,4 +439,69 @@ void QFontEngineS60::getCharacterData(glyph_t glyph, TOpenFontCharMetrics& metri
}
}
+#ifdef Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+static inline void skipSpacesAndComma(const char* &str, const char* const strEnd)
+{
+ while (str <= strEnd && (*str == ' ' || *str == ','))
+ ++str;
+}
+
+static bool parseGlyphPathData(const char *svgPath, const char *svgPathEnd, QPainterPath &path,
+ qreal fontPixelSize, const QPointF &offset, bool hinted)
+{
+ Q_UNUSED(hinted)
+ QPointF p1, p2, firstSubPathPoint;
+ qreal *elementValues[] =
+ {&p1.rx(), &p1.ry(), &p2.rx(), &p2.ry()};
+ const int unitsPerEm = 2048; // See: http://en.wikipedia.org/wiki/Em_%28typography%29
+ const qreal resizeFactor = fontPixelSize / unitsPerEm;
+
+ while (svgPath < svgPathEnd) {
+ skipSpacesAndComma(svgPath, svgPathEnd);
+ const char pathElem = *svgPath++;
+ skipSpacesAndComma(svgPath, svgPathEnd);
+
+ if (pathElem != 'Z') {
+ char *endStr = 0;
+ int elementValuesCount = 0;
+ for (int i = 0; i < 4; ++i) { // 4 = size of elementValues[]
+ qreal coordinateValue = strtod(svgPath, &endStr);
+ if (svgPath == endStr)
+ break;
+ if (i % 2) // Flip vertically
+ coordinateValue = -coordinateValue;
+ *elementValues[i] = coordinateValue * resizeFactor;
+ elementValuesCount++;
+ svgPath = endStr;
+ skipSpacesAndComma(svgPath, svgPathEnd);
+ }
+ p1 += offset;
+ if (elementValuesCount == 2)
+ p2 = firstSubPathPoint;
+ else
+ p2 += offset;
+ }
+
+ switch (pathElem) {
+ case 'M':
+ firstSubPathPoint = p1;
+ path.moveTo(p1);
+ break;
+ case 'Z':
+ path.closeSubpath();
+ break;
+ case 'L':
+ path.lineTo(p1);
+ break;
+ case 'Q':
+ path.quadTo(p1, p2);
+ break;
+ default:
+ return false;
+ }
+ }
+ return true;
+}
+#endif // Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
index dea32c489f..beeb4cc252 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -62,6 +62,10 @@
#define Q_SYMBIAN_HAS_FONTTABLE_API
#endif
+#ifdef Q_SYMBIAN_HAS_FONTTABLE_API
+#define Q_SYMBIAN_HAS_GLYPHOUTLINE_API
+#endif // Q_SYMBIAN_HAS_FONTTABLE_API
+
class CFont;
QT_BEGIN_NAMESPACE
@@ -97,6 +101,9 @@ public:
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;
+ void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
+ QPainterPath *path, QTextItem::RenderFlags flags);
+
QImage alphaMapForGlyph(glyph_t glyph);
glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);