summaryrefslogtreecommitdiff
path: root/x11-libs/cairo/files/cairo-1.10.2-qt-surface.patch
blob: cf0b57a1c2522fd302f5b065ab9c4632678ec7a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
diff -ruN cairo-1.10.2-0-vanilla/src/cairo-qt-surface.cpp cairo-1.10.2/src/cairo-qt-surface.cpp
--- cairo-1.10.2-0-vanilla/src/cairo-qt-surface.cpp	2010-12-25 15:21:34.000000000 +0100
+++ cairo-1.10.2/src/cairo-qt-surface.cpp	2011-12-20 22:59:30.000000000 +0100
@@ -61,7 +61,9 @@
 #include <QtGui/QX11Info>
 #include <QtCore/QVarLengthArray>
 
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0))
+#include <QtGui/QGlyphRun>
+#elif (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
 
@@ -1370,7 +1372,39 @@
 			       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;
+    // 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);
+    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);
+    font.setStyleStrategy(QFont::NoFontMerging);
+    font.setBold(face->style_flags & FT_STYLE_FLAG_BOLD);
+    font.setItalic(face->style_flags & FT_STYLE_FLAG_ITALIC);
+    font.setKerning(face->face_flags & FT_FACE_FLAG_KERNING);
+    font.setPixelSize(ftMetrics.y_ppem);
+    cairo_ft_scaled_font_unlock_face(scaled_font);
+    qs->p->setFont(font);
+    qs->p->setPen(tempColour);
+    for (int currentGlyph = 0; currentGlyph < num_glyphs; currentGlyph++) {
+        positions.append(QPointF(glyphs[currentGlyph].x, glyphs[currentGlyph].y));
+        glyphss.append(glyphs[currentGlyph].index);
+    }
+    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;
+#elif (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
     cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
 
     // pick out the colour to use from the cairo source