[pango/pango2: 134/178] Allow variant information in face descriptions




commit 1bcf743b9e9aab8e0a085fdb415fb379423861ed
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 16 06:56:15 2022 -0400

    Allow variant information in face descriptions
    
    This is needed to fix small-caps roundtrips on MacOS.

 pango/pango-fontmap.c | 3 +--
 pango/pango-hbface.c  | 5 +----
 tests/testhbfont.c    | 5 +++++
 3 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c
index 99fbae64f..fbcd4c86c 100644
--- a/pango/pango-fontmap.c
+++ b/pango/pango-fontmap.c
@@ -874,8 +874,7 @@ pango_font_map_add_face (PangoFontMap  *self,
 
   description = face->description;
 
-  if (pango_font_description_get_set_fields (description) &
-      (PANGO_FONT_MASK_VARIANT | PANGO_FONT_MASK_GRAVITY))
+  if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_GRAVITY)
     g_warning ("Font description for PangoFontFace includes things that it shouldn't");
 
   if (!self->in_populate)
diff --git a/pango/pango-hbface.c b/pango/pango-hbface.c
index 90459aa3c..adee83f43 100644
--- a/pango/pango-hbface.c
+++ b/pango/pango-hbface.c
@@ -177,7 +177,6 @@ set_name_and_description (PangoHbFace                *self,
        */
       face->description = pango_font_description_from_string (fullname);
       pango_font_description_unset_fields (face->description,
-                                           PANGO_FONT_MASK_VARIANT |
                                            PANGO_FONT_MASK_VARIATIONS |
                                            PANGO_FONT_MASK_GRAVITY);
 
@@ -704,9 +703,7 @@ pango_hb_face_new_from_hb_face (hb_face_t                 *face,
   g_return_val_if_fail (instance_id >= -2, NULL);
   g_return_val_if_fail (description == NULL ||
                         (pango_font_description_get_set_fields (description) &
-                         (PANGO_FONT_MASK_VARIANT|
-                          PANGO_FONT_MASK_SIZE|
-                          PANGO_FONT_MASK_GRAVITY)) == 0, NULL);
+                         (PANGO_FONT_MASK_SIZE|PANGO_FONT_MASK_GRAVITY)) == 0, NULL);
 
   self = g_object_new (PANGO_TYPE_HB_FACE, NULL);
 
diff --git a/tests/testhbfont.c b/tests/testhbfont.c
index ece945619..626877c28 100644
--- a/tests/testhbfont.c
+++ b/tests/testhbfont.c
@@ -82,6 +82,7 @@ test_hbface_roundtrip (void)
   desc = pango_font_face_describe (PANGO_FONT_FACE (face));
   g_assert_cmpint (pango_font_description_get_set_fields (desc) & NO_FACEID, ==, PANGO_FONT_MASK_FAMILY |
                                                                                  PANGO_FONT_MASK_STYLE |
+                                                                                 PANGO_FONT_MASK_VARIANT |
                                                                                  PANGO_FONT_MASK_WEIGHT |
                                                                                  PANGO_FONT_MASK_STRETCH);
   g_assert_cmpstr (pango_font_description_get_family (desc), ==, "Cantarell");
@@ -100,6 +101,7 @@ test_hbface_roundtrip (void)
   desc = pango_font_face_describe (PANGO_FONT_FACE (face2));
   g_assert_cmpint (pango_font_description_get_set_fields (desc) & NO_FACEID, ==, PANGO_FONT_MASK_FAMILY |
                                                                                  PANGO_FONT_MASK_STYLE |
+                                                                                 PANGO_FONT_MASK_VARIANT |
                                                                                  PANGO_FONT_MASK_WEIGHT |
                                                                                  PANGO_FONT_MASK_STRETCH);
   g_assert_cmpstr (pango_font_description_get_family (desc), ==, "Cantarell");
@@ -119,6 +121,7 @@ test_hbface_roundtrip (void)
   desc = pango_font_face_describe (PANGO_FONT_FACE (face2));
   g_assert_cmpint (pango_font_description_get_set_fields (desc) & NO_FACEID, ==, PANGO_FONT_MASK_FAMILY |
                                                                                  PANGO_FONT_MASK_STYLE |
+                                                                                 PANGO_FONT_MASK_VARIANT |
                                                                                  PANGO_FONT_MASK_WEIGHT |
                                                                                  PANGO_FONT_MASK_STRETCH);
   g_assert_cmpstr (pango_font_description_get_family (desc), ==, "Cantarell");
@@ -138,6 +141,7 @@ test_hbface_roundtrip (void)
   desc = pango_font_face_describe (PANGO_FONT_FACE (face2));
   g_assert_cmpint (pango_font_description_get_set_fields (desc) & NO_FACEID, ==, PANGO_FONT_MASK_FAMILY |
                                                                                  PANGO_FONT_MASK_STYLE |
+                                                                                 PANGO_FONT_MASK_VARIANT |
                                                                                  PANGO_FONT_MASK_WEIGHT |
                                                                                  PANGO_FONT_MASK_STRETCH);
   g_assert_cmpstr (pango_font_description_get_family (desc), ==, "Cantarellagain");
@@ -163,6 +167,7 @@ test_hbface_roundtrip (void)
   g_assert_cmpint (pango_font_description_get_set_fields (desc) & NO_FACEID, ==, PANGO_FONT_MASK_FAMILY |
                                                                                  PANGO_FONT_MASK_STYLE |
                                                                                  PANGO_FONT_MASK_WEIGHT |
+                                                                                 PANGO_FONT_MASK_VARIANT |
                                                                                  PANGO_FONT_MASK_VARIATIONS |
                                                                                  PANGO_FONT_MASK_STRETCH);
   g_assert_cmpstr (pango_font_description_get_family (desc), ==, "Cat");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]