diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-03-14 15:50:07 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-03-14 15:50:07 +0100 |
commit | 5ab19f67baae9760a12fee71b10fdab83987f221 (patch) | |
tree | ad73ea46024b4b49c2e30469f4f0de76b7ef98f2 | |
parent | ff0f46d53dce7c85469baccaea00ad5f49bdb889 (diff) | |
download | mupdf-5ab19f67baae9760a12fee71b10fdab83987f221.tar.xz |
Support StyleSimulation for fonts in XPS.
-rw-r--r-- | xps/xps_glyphs.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/xps/xps_glyphs.c b/xps/xps_glyphs.c index 94baa918..8a1b7fb8 100644 --- a/xps/xps_glyphs.c +++ b/xps/xps_glyphs.c @@ -402,6 +402,7 @@ xps_parse_glyphs(xps_document *doc, fz_matrix ctm, fz_font *font; char partname[1024]; + char fakename[1024]; char *subfont; float font_size = 10; @@ -483,7 +484,19 @@ xps_parse_glyphs(xps_document *doc, fz_matrix ctm, *subfont = 0; } - font = xps_lookup_font(doc, partname); + /* Make a new part name for font with style simulation applied */ + fz_strlcpy(fakename, partname, sizeof fakename); + if (style_att) + { + if (!strcmp(style_att, "BoldSimulation")) + fz_strlcat(fakename, "#Bold", sizeof fakename); + else if (!strcmp(style_att, "ItalicSimulation")) + fz_strlcat(fakename, "#Italic", sizeof fakename); + else if (!strcmp(style_att, "BoldItalicSimulation")) + fz_strlcat(fakename, "#BoldItalic", sizeof fakename); + } + + font = xps_lookup_font(doc, fakename); if (!font) { fz_try(doc->ctx) @@ -513,9 +526,15 @@ xps_parse_glyphs(xps_document *doc, fz_matrix ctm, return; } + if (style_att) + { + font->ft_bold = !!strstr(style_att, "Bold"); + font->ft_italic = !!strstr(style_att, "Italic"); + } + xps_select_best_font_encoding(doc, font); - xps_insert_font(doc, part->name, font); + xps_insert_font(doc, fakename, font); /* NOTE: we keep part->data in the font */ font->ft_data = part->data; |