Bug 29092. Use QGlyphRun API for rendering cairo glyphs in qt backend

Oleg Romashin <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CACCnL17nBvU4SAcum=81pFFStikoz_ypxQ+aenT5bE=rxa7bhg@mail.gmail.com>
Make cairo-qt compatible with Qt  >=4.8.0, and use fallback path for older
versions

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
cairo_fix.diff (text/x-patch, 2.5 KB)
diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
index aaed90c..c7f8973 100644
--- a/src/cairo-qt-surface.cpp
+++ b/src/cairo-qt-surface.cpp
@@ -60,11 +60,7 @@
 #include <QtGui/QPen>
 #include <QtGui/QWidget>
 #include <QtGui/QX11Info>
-#include <QtCore/QVarLengthArray>
-
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
-extern void qt_draw_glyphs(QPainter *, const quint32 *glyphs, const QPointF *positions, int count);
-#endif
+#include <QtGui/QGlyphRun>
 
 #include <sys/time.h>
 
@@ -1364,18 +1360,17 @@ _cairo_qt_surface_show_glyphs (void *abstract_surface,
 			       cairo_clip_t *clip,
 			       int *remaining_glyphs)
 {
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) && !defined(QT_NO_RAWFONT)
     cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
 
     // pick out the colour to use from the cairo source
     cairo_solid_pattern_t *solid = (cairo_solid_pattern_t*) source;
-    cairo_scaled_glyph_t* glyph;
     // documentation says you have to freeze the cache, but I don't believe it
     _cairo_scaled_font_freeze_cache(scaled_font);
 
     QColor tempColour(solid->color.red * 255, solid->color.green * 255, solid->color.blue * 255);
-    QVarLengthArray<QPointF> positions(num_glyphs);
-    QVarLengthArray<unsigned int> glyphss(num_glyphs);
+    QVector<QPointF> positions(num_glyphs);
+    QVector<unsigned int> glyphss(num_glyphs);
     FT_Face face = cairo_ft_scaled_font_lock_face (scaled_font);
     const FT_Size_Metrics& ftMetrics = face->size->metrics;
     QFont font(face->family_name);
@@ -1388,11 +1383,13 @@ _cairo_qt_surface_show_glyphs (void *abstract_surface,
     qs->p->setFont(font);
     qs->p->setPen(tempColour);
     for (int currentGlyph = 0; currentGlyph < num_glyphs; currentGlyph++) {
-        positions[currentGlyph].setX(glyphs[currentGlyph].x);
-        positions[currentGlyph].setY(glyphs[currentGlyph].y);
-        glyphss[currentGlyph] = glyphs[currentGlyph].index;
+        positions.append(QPointF(glyphs[currentGlyph].x, glyphs[currentGlyph].y));
+        glyphss.append(glyphs[currentGlyph].index);
     }
-    qt_draw_glyphs(qs->p, glyphss.data(), positions.data(), num_glyphs);
+    QGlyphRun qglyphs;
+    qglyphs.setGlyphIndexes(glyphss);
+    qglyphs.setPositions(positions);
+    qs->p->drawGlyphRun(QPointF(), qglyphs);
     _cairo_scaled_font_thaw_cache(scaled_font);
     return CAIRO_INT_STATUS_SUCCESS;
 #else
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.