diff options
Diffstat (limited to 'pango/pangowin32.c')
-rw-r--r-- | pango/pangowin32.c | 59 |
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; +} |