[pango/pango2: 108/135] serializer: Leave out faceid for now




commit 6664eebf7f18b6b30d4eb07a5f8eaf5521104320
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jan 4 23:31:11 2022 -0500

    serializer: Leave out faceid for now
    
    The serializer has its own checksum to guarantee
    font matches, and including the faceid in serialized
    font descriptions would make the serialization
    backend-dependent.
    
    We can add it later when all our fontmaps are hb.

 pango/serializer.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/pango/serializer.c b/pango/serializer.c
index 459682b2..ab4852b2 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -261,6 +261,23 @@ static const char *ellipsize_names[] = {
 /* }}} */
 /* {{{ Serialization */
 
+static char *
+font_description_to_string (PangoFontDescription *desc)
+{
+  PangoFontDescription *copy;
+  char *s;
+
+  /* Leave out the faceid for now, since it would make serialization
+   * backend-dependent.
+   */
+  copy = pango_font_description_copy_static (desc);
+  pango_font_description_unset_fields (copy, PANGO_FONT_MASK_FACEID);
+  s = pango_font_description_to_string (copy);
+  pango_font_description_free (copy);
+
+  return s;
+}
+
 static void
 add_attribute (GtkJsonPrinter *printer,
                PangoAttribute *attr)
@@ -354,7 +371,7 @@ add_attribute (GtkJsonPrinter *printer,
       break;
 
     case PANGO_ATTR_FONT_DESC:
-      str = pango_font_description_to_string (((PangoAttrFontDesc*)attr)->desc);
+      str = font_description_to_string (((PangoAttrFontDesc*)attr)->desc);
       gtk_json_printer_add_string (printer, "value", str);
       g_free (str);
       break;
@@ -456,7 +473,7 @@ add_context (GtkJsonPrinter *printer,
    * context gets updated as expected.
    */
 
-  str = pango_font_description_to_string (context->font_desc);
+  str = font_description_to_string (context->font_desc);
   gtk_json_printer_add_string (printer, "font", str);
   g_free (str);
 
@@ -552,7 +569,7 @@ add_font (GtkJsonPrinter *printer,
   gtk_json_printer_start_object (printer, member);
 
   desc = pango_font_describe (font);
-  str = pango_font_description_to_string (desc);
+  str = font_description_to_string (desc);
   gtk_json_printer_add_string (printer, "description", str);
   g_free (str);
   pango_font_description_free (desc);


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