diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-12-26 12:42:30 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-01-28 09:03:03 -0500 |
commit | e1da783fe5a70e3f93c779f258b2ba46c5277695 (patch) | |
tree | 27b587de1b433241c9c3c524cf90dcf73413d6a6 | |
parent | a07c85be22ddd119c5d2725d88a383c81403c87c (diff) | |
download | pango-e1da783fe5a70e3f93c779f258b2ba46c5277695.tar.gz |
serializer: Improve font serialization
Include index and instance_id in the output
when serializing fonts.
Update all affected tests.
-rw-r--r-- | pango/serializer.c | 28 | ||||
-rw-r--r-- | tests/layouts/bratwurst.layout | 2 | ||||
-rw-r--r-- | tests/layouts/bratwurst2.layout | 1 | ||||
-rw-r--r-- | tests/layouts/bratwurst3.layout | 4 | ||||
-rw-r--r-- | tests/layouts/bratwurst4.layout | 2 | ||||
-rw-r--r-- | tests/layouts/kebab.layout | 2 |
6 files changed, 39 insertions, 0 deletions
diff --git a/pango/serializer.c b/pango/serializer.c index 2dab93b4..37969e1b 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.h> #include <hb-ot.h> #include "pango/json/gtkjsonparserprivate.h" @@ -549,6 +550,9 @@ add_font (GtkJsonPrinter *printer, const int *coords; hb_feature_t features[32]; PangoMatrix matrix; + unsigned int index; + int instance_id; + gboolean embolden; gtk_json_printer_start_object (printer, member); @@ -567,6 +571,30 @@ 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 = pango_hb_face_get_face_index (hbface); + instance_id = pango_hb_face_get_instance_id (hbface); + embolden = pango_hb_face_get_embolden (hbface); + } + else + { + index = hb_face_get_index (face); + instance_id = (index >> 16) - 1; + index = index & 0xffff; + embolden = FALSE; + } + + 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); + + if (embolden) + gtk_json_printer_add_boolean (printer, "embolden", embolden); + 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 }, |