[pango/simple-fontmap: 15/16] Improve serialization for PangoHbFont




commit 12c3b4bcfc426ed9e530f5d638cf597f79ae68ee
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 26 12:42:30 2021 -0500

    Improve serialization for PangoHbFont
    
    Include index and instance_id in the output.

 pango/serializer.c    | 11 +++++++++++
 tests/testserialize.c |  1 +
 2 files changed, 12 insertions(+)
---
diff --git a/pango/serializer.c b/pango/serializer.c
index 2dab93b4..ee30a01d 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -26,6 +26,7 @@
 #include <pango/pango-context-private.h>
 #include <pango/pango-enum-types.h>
 #include <pango/pango-font-private.h>
+#include <pango/pango-hbface-private.h>
 
 #include <hb-ot.h>
 #include "pango/json/gtkjsonparserprivate.h"
@@ -566,6 +567,16 @@ add_font (GtkJsonPrinter *printer,
   str = g_compute_checksum_for_data (G_CHECKSUM_SHA256, (const guchar *)data, length);
 
   gtk_json_printer_add_string (printer, "checksum", str);
+  if (hb_face_get_index (face) != 0)
+    gtk_json_printer_add_integer (printer, "index", hb_face_get_index (face));
+
+  if (PANGO_IS_HB_FACE (pango_font_get_face (font)))
+    {
+      PangoHbFace *hbface = PANGO_HB_FACE (pango_font_get_face (font));
+
+      if (hbface->instance_id != -1)
+        gtk_json_printer_add_integer (printer, "instance-id", hbface->instance_id);
+    }
 
   g_free (str);
   hb_blob_destroy (blob);
diff --git a/tests/testserialize.c b/tests/testserialize.c
index e480da31..6b4645a1 100644
--- a/tests/testserialize.c
+++ b/tests/testserialize.c
@@ -143,6 +143,7 @@ test_serialize_font (void)
     "{\n"
     "  \"description\" : \"Cantarell 20 @wght=600\",\n"
     "  \"checksum\" : \"5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2\",\n"
+    "  \"index\" : 0,\n"
     "  \"variations\" : {\n"
     "    \"wght\" : 5583\n"
     "  },\n"


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