summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-03-03 12:18:39 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-03-03 12:48:21 +0100
commit4c16a5371c109be8d52eae8690ab96ceebf1349b (patch)
tree5597f48089c9e706ee4047b4e82442a360643166 /source
parentd84fc450c0434d9b0c7230e39a55b29d979af0fe (diff)
downloadmupdf-4c16a5371c109be8d52eae8690ab96ceebf1349b.tar.xz
pdf: Additional entries in Mac OS Roman encoding not in MacRomanEncoding.
When encoding truetype fonts via the mac roman cmap table, we should be using the additional entries introduced in PDF 1.5, which are different from the standard MacRomanEncoding table in the appendix.
Diffstat (limited to 'source')
-rw-r--r--source/pdf/pdf-encoding.c14
-rw-r--r--source/pdf/pdf-font.c31
-rw-r--r--source/pdf/pdf-type3.c2
-rw-r--r--source/pdf/pdf-unicode.c2
4 files changed, 36 insertions, 13 deletions
diff --git a/source/pdf/pdf-encoding.c b/source/pdf/pdf-encoding.c
index d0a4bb88..25843c12 100644
--- a/source/pdf/pdf-encoding.c
+++ b/source/pdf/pdf-encoding.c
@@ -4,19 +4,19 @@
#include "pdf-glyphlist.h"
void
-pdf_load_encoding(char **estrings, char *encoding)
+pdf_load_encoding(const char **estrings, char *encoding)
{
- char **bstrings = NULL;
+ const char * const *bstrings = NULL;
int i;
if (!strcmp(encoding, "StandardEncoding"))
- bstrings = (char**) pdf_standard;
+ bstrings = pdf_standard;
if (!strcmp(encoding, "MacRomanEncoding"))
- bstrings = (char**) pdf_mac_roman;
+ bstrings = pdf_mac_roman;
if (!strcmp(encoding, "MacExpertEncoding"))
- bstrings = (char**) pdf_mac_expert;
+ bstrings = pdf_mac_expert;
if (!strcmp(encoding, "WinAnsiEncoding"))
- bstrings = (char**) pdf_win_ansi;
+ bstrings = pdf_win_ansi;
if (bstrings)
for (i = 0; i < 256; i++)
@@ -24,7 +24,7 @@ pdf_load_encoding(char **estrings, char *encoding)
}
int
-pdf_lookup_agl(char *name)
+pdf_lookup_agl(const char *name)
{
char buf[64];
char *p;
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index a974c8d5..eaeac3c0 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -178,9 +178,9 @@ static int ft_char_index(FT_Face face, int cid)
return gid;
}
-static int ft_name_index(FT_Face face, char *name)
+static int ft_name_index(FT_Face face, const char *name)
{
- int code = FT_Get_Name_Index(face, name);
+ int code = FT_Get_Name_Index(face, (char*)name);
if (code == 0)
{
int unicode = pdf_lookup_agl(name);
@@ -300,9 +300,32 @@ static int ft_width(fz_context *ctx, pdf_font_desc *fontdesc, int cid)
return adv * 1000 / ((FT_Face)fontdesc->font->ft_face)->units_per_EM;
}
-static int lookup_mre_code(char *name)
+static const struct { int code; const char *name; } mre_diff_table[] =
+{
+ { 173, "notequal" },
+ { 176, "infinity" },
+ { 178, "lessequal" },
+ { 179, "greaterequal" },
+ { 182, "partialdiff" },
+ { 183, "summation" },
+ { 184, "product" },
+ { 185, "pi" },
+ { 186, "integral" },
+ { 189, "Omega" },
+ { 195, "radical" },
+ { 197, "approxequal" },
+ { 198, "Delta" },
+ { 215, "lozenge" },
+ { 219, "Euro" },
+ { 240, "apple" },
+};
+
+static int lookup_mre_code(const char *name)
{
int i;
+ for (i = 0; i < nelem(mre_diff_table); ++i)
+ if (!strcmp(name, mre_diff_table[i].name))
+ return mre_diff_table[i].code;
for (i = 0; i < 256; i++)
if (pdf_mac_roman[i] && !strcmp(name, pdf_mac_roman[i]))
return i;
@@ -557,7 +580,7 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
int kind;
int glyph;
- char *estrings[256];
+ const char *estrings[256];
char ebuffer[256][32];
int i, k, n;
int fterr;
diff --git a/source/pdf/pdf-type3.c b/source/pdf/pdf-type3.c
index 677a26e5..3eeff1f8 100644
--- a/source/pdf/pdf-type3.c
+++ b/source/pdf/pdf-type3.c
@@ -19,7 +19,7 @@ pdf_font_desc *
pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *dict)
{
char buf[256];
- char *estrings[256];
+ const char *estrings[256];
pdf_font_desc *fontdesc = NULL;
pdf_obj *encoding;
pdf_obj *widths;
diff --git a/source/pdf/pdf-unicode.c b/source/pdf/pdf-unicode.c
index 65bda460..fdff47ba 100644
--- a/source/pdf/pdf-unicode.c
+++ b/source/pdf/pdf-unicode.c
@@ -57,7 +57,7 @@ pdf_remap_cmap(fz_context *ctx, pdf_cmap *gid_from_cpt, pdf_cmap *ucs_from_cpt)
void
pdf_load_to_unicode(fz_context *ctx, pdf_document *doc, pdf_font_desc *font,
- char **strings, char *collection, pdf_obj *cmapstm)
+ const char **strings, char *collection, pdf_obj *cmapstm)
{
unsigned int cpt;