[pango/simple-fontmap: 13/15] serializer: Leave out faceid for now




commit 9b34c9ee953138a1afa3e1b43de481cabf591725
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 | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/pango/serializer.c b/pango/serializer.c
index 37969e1b..99352c0d 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -265,6 +265,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)
@@ -356,7 +373,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;
@@ -458,7 +475,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);
 
@@ -557,7 +574,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);
@@ -806,9 +823,9 @@ layout_to_json (GtkJsonPrinter            *printer,
 
   if (layout->font_desc)
     {
-      char *str = pango_font_description_to_string (layout->font_desc);
-      gtk_json_printer_add_string (printer, "font", str);
-      g_free (str);
+      char *s = font_description_to_string (layout->font_desc);
+      gtk_json_printer_add_string (printer, "font", s);
+      g_free (s);
     }
 
   add_tab_array (printer, layout->tabs);


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