[pango/simple-fontmap: 13/14] Improve serialization for PangoHbFont
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/simple-fontmap: 13/14] Improve serialization for PangoHbFont
- Date: Wed, 29 Dec 2021 04:36:09 +0000 (UTC)
commit 24193965a0d86f71f9a62aafcdd4c9a9dcf99e45
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.
Update all affected tests.
pango/serializer.c | 22 ++++++++++++++++++++++
tests/layouts/bratwurst.layout | 2 ++
tests/layouts/bratwurst2.layout | 1 +
tests/layouts/bratwurst3.layout | 4 ++++
tests/layouts/bratwurst4.layout | 2 ++
tests/layouts/kebab.layout | 2 ++
6 files changed, 33 insertions(+)
---
diff --git a/pango/serializer.c b/pango/serializer.c
index 2dab93b4..78fba783 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"
@@ -549,6 +550,8 @@ add_font (GtkJsonPrinter *printer,
const int *coords;
hb_feature_t features[32];
PangoMatrix matrix;
+ unsigned int index;
+ int instance_id;
gtk_json_printer_start_object (printer, member);
@@ -567,6 +570,25 @@ add_font (GtkJsonPrinter *printer,
gtk_json_printer_add_string (printer, "checksum", str);
+ if (PANGO_IS_HB_FACE (pango_font_get_face (font)))
+ {
+ PangoHbFace *hbface = PANGO_HB_FACE (pango_font_get_face (font));
+
+ index = hbface->index;
+ instance_id = hbface->instance_id;
+ }
+ else
+ {
+ index = hb_face_get_index (face);
+ instance_id = (index >> 16) - 1;
+ index = index & 0xffff;
+ }
+
+ if (index != 0)
+ gtk_json_printer_add_integer (printer, "index", index);
+ if (instance_id != -1)
+ gtk_json_printer_add_integer (printer, "instance-id", instance_id);
+
g_free (str);
hb_blob_destroy (blob);
diff --git a/tests/layouts/bratwurst.layout b/tests/layouts/bratwurst.layout
index 06ec8272..3940da79 100644
--- a/tests/layouts/bratwurst.layout
+++ b/tests/layouts/bratwurst.layout
@@ -112,6 +112,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
@@ -166,6 +167,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
diff --git a/tests/layouts/bratwurst2.layout b/tests/layouts/bratwurst2.layout
index 0c3be229..d9d7e40a 100644
--- a/tests/layouts/bratwurst2.layout
+++ b/tests/layouts/bratwurst2.layout
@@ -105,6 +105,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
diff --git a/tests/layouts/bratwurst3.layout b/tests/layouts/bratwurst3.layout
index 42c6a487..1ebec843 100644
--- a/tests/layouts/bratwurst3.layout
+++ b/tests/layouts/bratwurst3.layout
@@ -106,6 +106,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
@@ -161,6 +162,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
@@ -216,6 +218,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
@@ -271,6 +274,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
diff --git a/tests/layouts/bratwurst4.layout b/tests/layouts/bratwurst4.layout
index 34a4e1aa..9a189941 100644
--- a/tests/layouts/bratwurst4.layout
+++ b/tests/layouts/bratwurst4.layout
@@ -111,6 +111,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
@@ -184,6 +185,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
diff --git a/tests/layouts/kebab.layout b/tests/layouts/kebab.layout
index a0efe11d..eb3b8984 100644
--- a/tests/layouts/kebab.layout
+++ b/tests/layouts/kebab.layout
@@ -120,6 +120,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
@@ -194,6 +195,7 @@
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
+ "instance-id" : 3,
"variations" : {
"wght" : 8374
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]