diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2013-06-19 15:29:44 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-06-20 16:45:35 +0200 |
commit | 0a927854a10e1e6b9770a81e2e1d9f3093631757 (patch) | |
tree | 3d65d820d9fdba2d0d394d99c36290c851b78ca0 /source/pdf/pdf-encoding.c | |
parent | 1ae8f19179c5f0f8c6352b3c7855465325d5449a (diff) | |
download | mupdf-0a927854a10e1e6b9770a81e2e1d9f3093631757.tar.xz |
Rearrange source files.
Diffstat (limited to 'source/pdf/pdf-encoding.c')
-rw-r--r-- | source/pdf/pdf-encoding.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/source/pdf/pdf-encoding.c b/source/pdf/pdf-encoding.c new file mode 100644 index 00000000..c634a9ee --- /dev/null +++ b/source/pdf/pdf-encoding.c @@ -0,0 +1,82 @@ +#include "mupdf/pdf.h" + +#include "pdf-encodings.h" +#include "pdf-glyphlist.h" + +void +pdf_load_encoding(char **estrings, char *encoding) +{ + char **bstrings = NULL; + int i; + + if (!strcmp(encoding, "StandardEncoding")) + bstrings = (char**) pdf_standard; + if (!strcmp(encoding, "MacRomanEncoding")) + bstrings = (char**) pdf_mac_roman; + if (!strcmp(encoding, "MacExpertEncoding")) + bstrings = (char**) pdf_mac_expert; + if (!strcmp(encoding, "WinAnsiEncoding")) + bstrings = (char**) pdf_win_ansi; + + if (bstrings) + for (i = 0; i < 256; i++) + estrings[i] = bstrings[i]; +} + +int +pdf_lookup_agl(char *name) +{ + char buf[64]; + char *p; + int l = 0; + int r = nelem(agl_name_list) - 1; + + fz_strlcpy(buf, name, sizeof buf); + + /* kill anything after first period and underscore */ + p = strchr(buf, '.'); + if (p) p[0] = 0; + p = strchr(buf, '_'); + if (p) p[0] = 0; + + while (l <= r) + { + int m = (l + r) >> 1; + int c = strcmp(buf, agl_name_list[m]); + if (c < 0) + r = m - 1; + else if (c > 0) + l = m + 1; + else + return agl_code_list[m]; + } + + if (strstr(buf, "uni") == buf) + return strtol(buf + 3, NULL, 16); + else if (strstr(buf, "u") == buf) + return strtol(buf + 1, NULL, 16); + else if (strstr(buf, "a") == buf && strlen(buf) >= 3) + return strtol(buf + 1, NULL, 10); + + return 0; +} + +static const char *empty_dup_list[] = { 0 }; + +const char ** +pdf_lookup_agl_duplicates(int ucs) +{ + int l = 0; + int r = nelem(agl_dup_offsets) / 2 - 1; + while (l <= r) + { + int m = (l + r) >> 1; + if (ucs < agl_dup_offsets[m << 1]) + r = m - 1; + else if (ucs > agl_dup_offsets[m << 1]) + l = m + 1; + else + return agl_dup_names + agl_dup_offsets[(m << 1) + 1]; + } + return empty_dup_list; +} |