[cairo-commit] 2 commits - .gitlab-ci.yml test/ft-color-font.c test/Makefile.sources test/meson.build test/reference

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 31 05:58:35 UTC 2021


 .gitlab-ci.yml                                |    3 
 test/Makefile.sources                         |    1 
 test/ft-color-font.c                          |  108 ++++++++++++++++++++++++++
 test/meson.build                              |    1 
 test/reference/ft-color-font.image16.ref.png  |binary
 test/reference/ft-color-font.ref.png          |binary
 test/reference/ft-color-font.script.xfail.png |binary
 7 files changed, 112 insertions(+), 1 deletion(-)

New commits:
commit d88dd1794e17c1ef9c63dd8c1adf54c7f7c89811
Merge: 814162d97 7c6f2d4f2
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Jul 31 05:58:33 2021 +0000

    Merge branch 'color-font-test' into 'master'
    
    Add ft-color-font test
    
    See merge request cairo/cairo!221

commit 7c6f2d4f24f89ea6a46fb54e838f986c0aeeccdf
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Jul 30 10:36:08 2021 +0930

    Add ft-color-font test

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ddfdeb773..cf065fe9f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,7 +8,7 @@ include:
 variables:
   FDO_UPSTREAM_REPO: 'cairo/cairo'
   FDO_DISTRIBUTION_VERSION: '34'
-  FDO_DISTRIBUTION_TAG: '2021-05-04.2'
+  FDO_DISTRIBUTION_TAG: '2021-07-31.0'
 
   # TODO: should probably get its own image at some point instead of reusing the GStreamer one.
   WINDOWS_IMAGE:             "registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:v16-master"
@@ -94,6 +94,7 @@ fedora image:
       dejavu-sans-fonts
       dejavu-sans-mono-fonts
       dejavu-serif-fonts
+      google-noto-emoji-color-fonts
 
 fedora autotools build:
   extends:
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 0c8d4923d..b887b054d 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -411,6 +411,7 @@ ft_font_test_sources = \
 
 fc_font_test_sources = \
 	bitmap-font.c \
+	ft-color-font.c \
 	ft-font-create-for-ft-face.c \
 	ft-show-glyphs-positioning.c \
 	ft-show-glyphs-table.c \
diff --git a/test/ft-color-font.c b/test/ft-color-font.c
new file mode 100644
index 000000000..58a1dc3ca
--- /dev/null
+++ b/test/ft-color-font.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright © 2021 Adrian Johnson
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Adrian Johnson <ajohnson at redneon.com>
+ */
+
+#include "cairo-test.h"
+#include <cairo-ft.h>
+
+#define WIDTH  50
+#define HEIGHT WIDTH
+
+#define FONT "Noto Color Emoji"
+
+static const char smiley_face_utf8[] = { 0xf0, 0x9f, 0x99, 0x82, 0x00 }; /* U+1F642 */
+
+static cairo_test_status_t
+set_color_emoji_font (cairo_t *cr)
+{
+    cairo_font_options_t *font_options;
+    cairo_font_face_t *font_face;
+    FcPattern *pattern;
+    FcPattern *resolved;
+    FcChar8 *font_name;
+    FcResult result;
+
+    pattern = FcPatternCreate ();
+    if (pattern == NULL)
+	return CAIRO_TEST_NO_MEMORY;
+
+    FcPatternAddString (pattern, FC_FAMILY, (FcChar8 *) FONT);
+    FcConfigSubstitute (NULL, pattern, FcMatchPattern);
+
+    font_options = cairo_font_options_create ();
+    cairo_get_font_options (cr, font_options);
+    cairo_ft_font_options_substitute (font_options, pattern);
+
+    FcDefaultSubstitute (pattern);
+    resolved = FcFontMatch (NULL, pattern, &result);
+    if (resolved == NULL) {
+	FcPatternDestroy (pattern);
+	return CAIRO_TEST_NO_MEMORY;
+    }
+
+    if (FcPatternGetString (resolved, FC_FAMILY, 0, &font_name) == FcResultMatch) {
+        if (strcmp((char*)font_name, FONT) != 0) {
+            const cairo_test_context_t *ctx = cairo_test_get_context (cr);
+            cairo_test_log (ctx, "Could not find %s font\n", FONT);
+            return CAIRO_TEST_UNTESTED;
+        }
+    } else {
+        return CAIRO_TEST_FAILURE;
+    }
+
+    font_face = cairo_ft_font_face_create_for_pattern (resolved);
+    cairo_set_font_face (cr, font_face);
+
+    cairo_font_options_destroy (font_options);
+    cairo_font_face_destroy (font_face);
+    FcPatternDestroy (pattern);
+    FcPatternDestroy (resolved);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_test_status_t result;
+
+    result = set_color_emoji_font (cr);
+    if (result != CAIRO_TEST_SUCCESS)
+        return result;
+
+    cairo_set_font_size (cr, HEIGHT/2);
+    cairo_move_to (cr, width/4, 3*height/4);
+
+    cairo_show_text(cr, smiley_face_utf8);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (ft_color_font,
+	    "Test color font",
+	    "ft, font", /* keywords */
+	    NULL, /* requirements */
+	    WIDTH, HEIGHT,
+	    NULL, draw)
diff --git a/test/meson.build b/test/meson.build
index 6b5eba754..9d84d048d 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -412,6 +412,7 @@ test_pthread_sources = [
 test_ft_font_sources = [
   'font-variations.c',
   'bitmap-font.c',
+  'ft-color-font.c',
   'ft-font-create-for-ft-face.c',
   'ft-show-glyphs-positioning.c',
   'ft-show-glyphs-table.c',
diff --git a/test/reference/ft-color-font.image16.ref.png b/test/reference/ft-color-font.image16.ref.png
new file mode 100644
index 000000000..579cd69c9
Binary files /dev/null and b/test/reference/ft-color-font.image16.ref.png differ
diff --git a/test/reference/ft-color-font.ref.png b/test/reference/ft-color-font.ref.png
new file mode 100644
index 000000000..020a1a501
Binary files /dev/null and b/test/reference/ft-color-font.ref.png differ
diff --git a/test/reference/ft-color-font.script.xfail.png b/test/reference/ft-color-font.script.xfail.png
new file mode 100644
index 000000000..c818f36aa
Binary files /dev/null and b/test/reference/ft-color-font.script.xfail.png differ


More information about the cairo-commit mailing list