summaryrefslogtreecommitdiff
path: root/pango/pangowin32.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-07-09 17:07:25 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-07-09 17:07:25 +0000
commitcf7d2330339e54897ec1dd852bfead6ba023eb96 (patch)
tree3d39c60f1148086f8f51202b61600f372834d702 /pango/pangowin32.c
parent40aa32f1329e0d3fe4993c5955b94a24aedea836 (diff)
parent587834ca76aa80c2bf950396aa2e1edd0869f589 (diff)
downloadpango-cf7d2330339e54897ec1dd852bfead6ba023eb96.tar.gz
Merge branch 'win32-cmap-free' into 'master'
pangowin32: Clear cmap on finalize See merge request GNOME/pango!318
Diffstat (limited to 'pango/pangowin32.c')
-rw-r--r--pango/pangowin32.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index c8a5b46c..2d22e1d1 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -1275,3 +1275,62 @@ pango_win32_font_create_hb_font (PangoFont *font)
return hb_font;
}
+
+gpointer
+_pango_win32_copy_cmap (gpointer cmap, guint16 cmap_format)
+{
+ if (!cmap)
+ return NULL;
+
+ if (cmap_format == 12)
+ {
+ struct format_12_cmap *new_table;
+ struct format_12_cmap *old_table;
+ guint32 *tbl, *tbl_end;
+
+ old_table = (struct format_12_cmap *) cmap;
+
+ new_table = g_malloc (old_table->length);
+ memcpy (old_table, new_table, sizeof (struct format_12_cmap));
+
+ tbl_end = (guint32 *) ((char *) new_table + new_table->length);
+ tbl = new_table->groups;
+
+ while (tbl < tbl_end)
+ {
+ *tbl = GUINT32_FROM_BE (*tbl);
+ tbl++;
+ }
+
+ return new_table;
+ }
+ else if (cmap_format == 4)
+ {
+ struct format_4_cmap *new_table;
+ struct format_4_cmap *old_table;
+ guint16 *tbl, *tbl_end;
+
+ old_table = (struct format_4_cmap *) cmap;
+
+ new_table = g_malloc (old_table->length);
+ memcpy (old_table, new_table, sizeof (struct format_4_cmap));
+
+ tbl_end = (guint16 *)((char *) new_table + new_table->length);
+ tbl = &new_table->reserved;
+
+ while (tbl < tbl_end)
+ {
+ *tbl = GUINT16_FROM_BE (*tbl);
+ tbl++;
+ }
+
+ return new_table;
+ }
+ else
+ {
+ /* got non-null cmap but unknown format, it shouldn't happen */
+ g_assert_not_reached ();
+ }
+
+ return NULL;
+}