From 672b9afb9bb05a67bbcd8664ba268521ea728ca6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 13 Nov 2018 21:49:56 +0100 Subject: Add more encoding tables. Add tables for Windows-1250, Windows-1251, and ISO-8859-1. Also add unicode_from_encoding tables. Move encodings from PDF namespace to Fitz. --- source/fitz/encodings.c | 33 + source/fitz/encodings.h | 3784 +++++++++++++++++++++++++++++++++++++++++++ source/pdf/pdf-appearance.c | 6 +- source/pdf/pdf-encoding.c | 59 +- source/pdf/pdf-encodings.h | 203 --- source/pdf/pdf-font.c | 12 +- 6 files changed, 3829 insertions(+), 268 deletions(-) create mode 100644 source/fitz/encodings.c create mode 100644 source/fitz/encodings.h (limited to 'source') diff --git a/source/fitz/encodings.c b/source/fitz/encodings.c new file mode 100644 index 00000000..004ae90f --- /dev/null +++ b/source/fitz/encodings.c @@ -0,0 +1,33 @@ +#include "mupdf/fitz.h" +#include "mupdf/pdf.h" + +#include "encodings.h" + +#include +#include + +#define FROM_UNICODE(ENC) \ +{ \ + int l = 0; \ + int r = nelem(ENC##_from_unicode) - 1; \ + if (u < 128) \ + return u; \ + while (l <= r) \ + { \ + int m = (l + r) >> 1; \ + if (u < ENC##_from_unicode[m].u) \ + r = m - 1; \ + else if (u > ENC##_from_unicode[m].u) \ + l = m + 1; \ + else \ + return ENC##_from_unicode[m].c; \ + } \ + return -1; \ +} + +int fz_iso8859_1_from_unicode(int u) FROM_UNICODE(iso8859_1) +int fz_iso8859_7_from_unicode(int u) FROM_UNICODE(iso8859_7) +int fz_koi8u_from_unicode(int u) FROM_UNICODE(koi8u) +int fz_windows_1250_from_unicode(int u) FROM_UNICODE(windows_1250) +int fz_windows_1251_from_unicode(int u) FROM_UNICODE(windows_1251) +int fz_windows_1252_from_unicode(int u) FROM_UNICODE(windows_1252) diff --git a/source/fitz/encodings.h b/source/fitz/encodings.h new file mode 100644 index 00000000..89f81e8f --- /dev/null +++ b/source/fitz/encodings.h @@ -0,0 +1,3784 @@ +#define _notdef NULL + +unsigned short fz_unicode_from_iso8859_1[256] = { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255, +}; + +const char *fz_glyph_name_from_iso8859_1[256] = { + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quotesingle", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "grave", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "controlDEL", + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "nbspace", + "exclamdown", + "cent", + "sterling", + "currency", + "yen", + "brokenbar", + "section", + "dieresis", + "copyright", + "ordfeminine", + "guillemotleft", + "logicalnot", + "sfthyphen", + "registered", + "macron", + "degree", + "plusminus", + "twosuperior", + "threesuperior", + "acute", + "mu", + "paragraph", + "middot", + "cedilla", + "onesuperior", + "ordmasculine", + "guillemotright", + "onequarter", + "onehalf", + "threequarters", + "questiondown", + "Agrave", + "Aacute", + "Acircumflex", + "Atilde", + "Adieresis", + "Aring", + "AE", + "Ccedilla", + "Egrave", + "Eacute", + "Ecircumflex", + "Edieresis", + "Igrave", + "Iacute", + "Icircumflex", + "Idieresis", + "Eth", + "Ntilde", + "Ograve", + "Oacute", + "Ocircumflex", + "Otilde", + "Odieresis", + "multiply", + "Oslash", + "Ugrave", + "Uacute", + "Ucircumflex", + "Udieresis", + "Yacute", + "Thorn", + "germandbls", + "agrave", + "aacute", + "acircumflex", + "atilde", + "adieresis", + "aring", + "ae", + "ccedilla", + "egrave", + "eacute", + "ecircumflex", + "edieresis", + "igrave", + "iacute", + "icircumflex", + "idieresis", + "eth", + "ntilde", + "ograve", + "oacute", + "ocircumflex", + "otilde", + "odieresis", + "divide", + "oslash", + "ugrave", + "uacute", + "ucircumflex", + "udieresis", + "yacute", + "thorn", + "ydieresis", +}; + +static const struct { unsigned short u, c; } iso8859_1_from_unicode[] = { + {0x00a0,160}, + {0x00a1,161}, + {0x00a2,162}, + {0x00a3,163}, + {0x00a4,164}, + {0x00a5,165}, + {0x00a6,166}, + {0x00a7,167}, + {0x00a8,168}, + {0x00a9,169}, + {0x00aa,170}, + {0x00ab,171}, + {0x00ac,172}, + {0x00ad,173}, + {0x00ae,174}, + {0x00af,175}, + {0x00b0,176}, + {0x00b1,177}, + {0x00b2,178}, + {0x00b3,179}, + {0x00b4,180}, + {0x00b5,181}, + {0x00b6,182}, + {0x00b7,183}, + {0x00b8,184}, + {0x00b9,185}, + {0x00ba,186}, + {0x00bb,187}, + {0x00bc,188}, + {0x00bd,189}, + {0x00be,190}, + {0x00bf,191}, + {0x00c0,192}, + {0x00c1,193}, + {0x00c2,194}, + {0x00c3,195}, + {0x00c4,196}, + {0x00c5,197}, + {0x00c6,198}, + {0x00c7,199}, + {0x00c8,200}, + {0x00c9,201}, + {0x00ca,202}, + {0x00cb,203}, + {0x00cc,204}, + {0x00cd,205}, + {0x00ce,206}, + {0x00cf,207}, + {0x00d0,208}, + {0x00d1,209}, + {0x00d2,210}, + {0x00d3,211}, + {0x00d4,212}, + {0x00d5,213}, + {0x00d6,214}, + {0x00d7,215}, + {0x00d8,216}, + {0x00d9,217}, + {0x00da,218}, + {0x00db,219}, + {0x00dc,220}, + {0x00dd,221}, + {0x00de,222}, + {0x00df,223}, + {0x00e0,224}, + {0x00e1,225}, + {0x00e2,226}, + {0x00e3,227}, + {0x00e4,228}, + {0x00e5,229}, + {0x00e6,230}, + {0x00e7,231}, + {0x00e8,232}, + {0x00e9,233}, + {0x00ea,234}, + {0x00eb,235}, + {0x00ec,236}, + {0x00ed,237}, + {0x00ee,238}, + {0x00ef,239}, + {0x00f0,240}, + {0x00f1,241}, + {0x00f2,242}, + {0x00f3,243}, + {0x00f4,244}, + {0x00f5,245}, + {0x00f6,246}, + {0x00f7,247}, + {0x00f8,248}, + {0x00f9,249}, + {0x00fa,250}, + {0x00fb,251}, + {0x00fc,252}, + {0x00fd,253}, + {0x00fe,254}, + {0x00ff,255}, +}; + +unsigned short fz_unicode_from_iso8859_7[256] = { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, + 157, + 158, + 159, + 160, + 8216, + 8217, + 163, + 8364, + 8367, + 166, + 167, + 168, + 169, + 890, + 171, + 172, + 173, + 0, + 8213, + 176, + 177, + 178, + 179, + 900, + 901, + 902, + 183, + 904, + 905, + 906, + 187, + 908, + 189, + 910, + 911, + 912, + 913, + 914, + 915, + 916, + 917, + 918, + 919, + 920, + 921, + 922, + 923, + 924, + 925, + 926, + 927, + 928, + 929, + 0, + 931, + 932, + 933, + 934, + 935, + 936, + 937, + 938, + 939, + 940, + 941, + 942, + 943, + 944, + 945, + 946, + 947, + 948, + 949, + 950, + 951, + 952, + 953, + 954, + 955, + 956, + 957, + 958, + 959, + 960, + 961, + 962, + 963, + 964, + 965, + 966, + 967, + 968, + 969, + 970, + 971, + 972, + 973, + 974, + 0, +}; + +const char *fz_glyph_name_from_iso8859_7[256] = { + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quotesingle", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "grave", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "controlDEL", + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "nbspace", + "quoteleft", + "quoteright", + "sterling", + "Euro", + _notdef, + "brokenbar", + "section", + "dieresis", + "copyright", + "ypogegrammeni", + "guillemotleft", + "logicalnot", + "sfthyphen", + _notdef, + "afii00208", + "degree", + "plusminus", + "twosuperior", + "threesuperior", + "tonos", + "dialytikatonos", + "Alphatonos", + "middot", + "Epsilontonos", + "Etatonos", + "Iotatonos", + "guillemotright", + "Omicrontonos", + "onehalf", + "Upsilontonos", + "Omegatonos", + "iotadieresistonos", + "Alpha", + "Beta", + "Gamma", + "Deltagreek", + "Epsilon", + "Zeta", + "Eta", + "Theta", + "Iota", + "Kappa", + "Lambda", + "Mu", + "Nu", + "Xi", + "Omicron", + "Pi", + "Rho", + _notdef, + "Sigma", + "Tau", + "Upsilon", + "Phi", + "Chi", + "Psi", + "Omegagreek", + "Iotadieresis", + "Upsilondieresis", + "alphatonos", + "epsilontonos", + "etatonos", + "iotatonos", + "upsilondieresistonos", + "alpha", + "beta", + "gamma", + "delta", + "epsilon", + "zeta", + "eta", + "theta", + "iota", + "kappa", + "lambda", + "mugreek", + "nu", + "xi", + "omicron", + "pi", + "rho", + "sigma1", + "sigma", + "tau", + "upsilon", + "phi", + "chi", + "psi", + "omega", + "iotadieresis", + "upsilondieresis", + "omicrontonos", + "upsilontonos", + "omegatonos", + _notdef, +}; + +static const struct { unsigned short u, c; } iso8859_7_from_unicode[] = { + {0x00a0,160}, + {0x00a3,163}, + {0x00a6,166}, + {0x00a7,167}, + {0x00a8,168}, + {0x00a9,169}, + {0x00ab,171}, + {0x00ac,172}, + {0x00ad,173}, + {0x00b0,176}, + {0x00b1,177}, + {0x00b2,178}, + {0x00b3,179}, + {0x00b7,183}, + {0x00bb,187}, + {0x00bd,189}, + {0x037a,170}, + {0x0384,180}, + {0x0385,181}, + {0x0386,182}, + {0x0388,184}, + {0x0389,185}, + {0x038a,186}, + {0x038c,188}, + {0x038e,190}, + {0x038f,191}, + {0x0390,192}, + {0x0391,193}, + {0x0392,194}, + {0x0393,195}, + {0x0394,196}, + {0x0395,197}, + {0x0396,198}, + {0x0397,199}, + {0x0398,200}, + {0x0399,201}, + {0x039a,202}, + {0x039b,203}, + {0x039c,204}, + {0x039d,205}, + {0x039e,206}, + {0x039f,207}, + {0x03a0,208}, + {0x03a1,209}, + {0x03a3,211}, + {0x03a4,212}, + {0x03a5,213}, + {0x03a6,214}, + {0x03a7,215}, + {0x03a8,216}, + {0x03a9,217}, + {0x03aa,218}, + {0x03ab,219}, + {0x03ac,220}, + {0x03ad,221}, + {0x03ae,222}, + {0x03af,223}, + {0x03b0,224}, + {0x03b1,225}, + {0x03b2,226}, + {0x03b3,227}, + {0x03b4,228}, + {0x03b5,229}, + {0x03b6,230}, + {0x03b7,231}, + {0x03b8,232}, + {0x03b9,233}, + {0x03ba,234}, + {0x03bb,235}, + {0x03bc,236}, + {0x03bd,237}, + {0x03be,238}, + {0x03bf,239}, + {0x03c0,240}, + {0x03c1,241}, + {0x03c2,242}, + {0x03c3,243}, + {0x03c4,244}, + {0x03c5,245}, + {0x03c6,246}, + {0x03c7,247}, + {0x03c8,248}, + {0x03c9,249}, + {0x03ca,250}, + {0x03cb,251}, + {0x03cc,252}, + {0x03cd,253}, + {0x03ce,254}, + {0x2015,175}, + {0x2018,161}, + {0x2019,162}, + {0x20ac,164}, +}; + +unsigned short fz_unicode_from_koi8u[256] = { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 9472, + 9474, + 9484, + 9488, + 9492, + 9496, + 9500, + 9508, + 9516, + 9524, + 9532, + 9600, + 9604, + 9608, + 9612, + 9616, + 9617, + 9618, + 9619, + 8992, + 9632, + 8729, + 8730, + 8776, + 8804, + 8805, + 160, + 8993, + 176, + 178, + 183, + 247, + 9552, + 9553, + 9554, + 1105, + 1108, + 9556, + 1110, + 1111, + 9559, + 9560, + 9561, + 9562, + 9563, + 1169, + 9565, + 9566, + 9567, + 9568, + 9569, + 1025, + 1028, + 9571, + 1030, + 1031, + 9574, + 9575, + 9576, + 9577, + 9578, + 1168, + 9580, + 169, + 1102, + 1072, + 1073, + 1094, + 1076, + 1077, + 1092, + 1075, + 1093, + 1080, + 1081, + 1082, + 1083, + 1084, + 1085, + 1086, + 1087, + 1103, + 1088, + 1089, + 1090, + 1091, + 1078, + 1074, + 1100, + 1099, + 1079, + 1096, + 1101, + 1097, + 1095, + 1098, + 1070, + 1040, + 1041, + 1062, + 1044, + 1045, + 1060, + 1043, + 1061, + 1048, + 1049, + 1050, + 1051, + 1052, + 1053, + 1054, + 1055, + 1071, + 1056, + 1057, + 1058, + 1059, + 1046, + 1042, + 1068, + 1067, + 1047, + 1064, + 1069, + 1065, + 1063, + 1066, +}; + +const char *fz_glyph_name_from_koi8u[256] = { + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quotesingle", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "grave", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "controlDEL", + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "upblock", + "dnblock", + "block", + "lfblock", + "rtblock", + "ltshade", + "shade", + "dkshade", + "integraltop", + "blacksquare", + "bulletoperator", + "radical", + "approxequal", + "lessequal", + "greaterequal", + "nbspace", + "integralbottom", + "degree", + "twosuperior", + "middot", + "divide", + _notdef, + _notdef, + _notdef, + "afii10071", + "afii10101", + _notdef, + "afii10103", + "afii10104", + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "afii10098", + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "Iocyrillic", + "Ecyrillic", + _notdef, + "Icyrillic", + "Yicyrillic", + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "Gheupturncyrillic", + _notdef, + "copyright", + "afii10096", + "acyrillic", + "afii10066", + "afii10088", + "afii10069", + "afii10070", + "afii10086", + "afii10068", + "afii10087", + "afii10074", + "afii10075", + "afii10076", + "afii10077", + "afii10078", + "afii10079", + "afii10080", + "afii10081", + "afii10097", + "afii10082", + "afii10083", + "afii10084", + "afii10085", + "afii10072", + "afii10067", + "afii10094", + "afii10093", + "afii10073", + "afii10090", + "afii10095", + "afii10091", + "afii10089", + "afii10092", + "IUcyrillic", + "Acyrillic", + "Becyrillic", + "Tsecyrillic", + "Decyrillic", + "Iecyrillic", + "Efcyrillic", + "Gecyrillic", + "Khacyrillic", + "Iicyrillic", + "Iishortcyrillic", + "Kacyrillic", + "Elcyrillic", + "Emcyrillic", + "Encyrillic", + "Ocyrillic", + "Pecyrillic", + "IAcyrillic", + "Ercyrillic", + "Escyrillic", + "Tecyrillic", + "Ucyrillic", + "Zhecyrillic", + "Vecyrillic", + "Softsigncyrillic", + "Yericyrillic", + "Zecyrillic", + "Shacyrillic", + "Ereversedcyrillic", + "Shchacyrillic", + "Checyrillic", + "Hardsigncyrillic", +}; + +static const struct { unsigned short u, c; } koi8u_from_unicode[] = { + {0x00a0,154}, + {0x00a9,191}, + {0x00b0,156}, + {0x00b2,157}, + {0x00b7,158}, + {0x00f7,159}, + {0x0401,179}, + {0x0404,180}, + {0x0406,182}, + {0x0407,183}, + {0x0410,225}, + {0x0411,226}, + {0x0412,247}, + {0x0413,231}, + {0x0414,228}, + {0x0415,229}, + {0x0416,246}, + {0x0417,250}, + {0x0418,233}, + {0x0419,234}, + {0x041a,235}, + {0x041b,236}, + {0x041c,237}, + {0x041d,238}, + {0x041e,239}, + {0x041f,240}, + {0x0420,242}, + {0x0421,243}, + {0x0422,244}, + {0x0423,245}, + {0x0424,230}, + {0x0425,232}, + {0x0426,227}, + {0x0427,254}, + {0x0428,251}, + {0x0429,253}, + {0x042a,255}, + {0x042b,249}, + {0x042c,248}, + {0x042d,252}, + {0x042e,224}, + {0x042f,241}, + {0x0430,193}, + {0x0431,194}, + {0x0432,215}, + {0x0433,199}, + {0x0434,196}, + {0x0435,197}, + {0x0436,214}, + {0x0437,218}, + {0x0438,201}, + {0x0439,202}, + {0x043a,203}, + {0x043b,204}, + {0x043c,205}, + {0x043d,206}, + {0x043e,207}, + {0x043f,208}, + {0x0440,210}, + {0x0441,211}, + {0x0442,212}, + {0x0443,213}, + {0x0444,198}, + {0x0445,200}, + {0x0446,195}, + {0x0447,222}, + {0x0448,219}, + {0x0449,221}, + {0x044a,223}, + {0x044b,217}, + {0x044c,216}, + {0x044d,220}, + {0x044e,192}, + {0x044f,209}, + {0x0451,163}, + {0x0454,164}, + {0x0456,166}, + {0x0457,167}, + {0x0490,189}, + {0x0491,173}, + {0x2219,149}, + {0x221a,150}, + {0x2248,151}, + {0x2264,152}, + {0x2265,153}, + {0x2320,147}, + {0x2321,155}, + {0x2580,139}, + {0x2584,140}, + {0x2588,141}, + {0x258c,142}, + {0x2590,143}, + {0x2591,144}, + {0x2592,145}, + {0x2593,146}, + {0x25a0,148}, +}; + +unsigned short fz_unicode_from_windows_1250[256] = { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 8364, + 0, + 8218, + 0, + 8222, + 8230, + 8224, + 8225, + 0, + 8240, + 352, + 8249, + 346, + 356, + 381, + 377, + 0, + 8216, + 8217, + 8220, + 8221, + 8226, + 8211, + 8212, + 0, + 8482, + 353, + 8250, + 347, + 357, + 382, + 378, + 160, + 711, + 728, + 321, + 164, + 260, + 166, + 167, + 168, + 169, + 350, + 171, + 172, + 173, + 174, + 379, + 176, + 177, + 731, + 322, + 180, + 181, + 182, + 183, + 184, + 261, + 351, + 187, + 317, + 733, + 318, + 380, + 340, + 193, + 194, + 258, + 196, + 313, + 262, + 199, + 268, + 201, + 280, + 203, + 282, + 205, + 206, + 270, + 272, + 323, + 327, + 211, + 212, + 336, + 214, + 215, + 344, + 366, + 218, + 368, + 220, + 221, + 354, + 223, + 341, + 225, + 226, + 259, + 228, + 314, + 263, + 231, + 269, + 233, + 281, + 235, + 283, + 237, + 238, + 271, + 273, + 324, + 328, + 243, + 244, + 337, + 246, + 247, + 345, + 367, + 250, + 369, + 252, + 253, + 355, + 729, +}; + +const char *fz_glyph_name_from_windows_1250[256] = { + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quotesingle", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "grave", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "controlDEL", + "Euro", + _notdef, + "quotesinglbase", + _notdef, + "quotedblbase", + "ellipsis", + "dagger", + "daggerdbl", + _notdef, + "perthousand", + "Scaron", + "guilsinglleft", + "Sacute", + "Tcaron", + "Zcaron", + "Zacute", + _notdef, + "quoteleft", + "quoteright", + "quotedblleft", + "quotedblright", + "bullet", + "endash", + "emdash", + _notdef, + "trademark", + "scaron", + "guilsinglright", + "sacute", + "tcaron", + "zcaron", + "zacute", + "nbspace", + "caron", + "breve", + "Lslash", + "currency", + "Aogonek", + "brokenbar", + "section", + "dieresis", + "copyright", + "Scedilla", + "guillemotleft", + "logicalnot", + "sfthyphen", + "registered", + "Zdot", + "degree", + "plusminus", + "ogonek", + "lslash", + "acute", + "mu", + "paragraph", + "middot", + "cedilla", + "aogonek", + "scedilla", + "guillemotright", + "Lcaron", + "hungarumlaut", + "lcaron", + "zdot", + "Racute", + "Aacute", + "Acircumflex", + "Abreve", + "Adieresis", + "Lacute", + "Cacute", + "Ccedilla", + "Ccaron", + "Eacute", + "Eogonek", + "Edieresis", + "Ecaron", + "Iacute", + "Icircumflex", + "Dcaron", + "Dcroat", + "Nacute", + "Ncaron", + "Oacute", + "Ocircumflex", + "Odblacute", + "Odieresis", + "multiply", + "Rcaron", + "Uring", + "Uacute", + "Udblacute", + "Udieresis", + "Yacute", + "Tcedilla", + "germandbls", + "racute", + "aacute", + "acircumflex", + "abreve", + "adieresis", + "lacute", + "cacute", + "ccedilla", + "ccaron", + "eacute", + "eogonek", + "edieresis", + "ecaron", + "iacute", + "icircumflex", + "dcaron", + "dcroat", + "nacute", + "ncaron", + "oacute", + "ocircumflex", + "odblacute", + "odieresis", + "divide", + "rcaron", + "uring", + "uacute", + "udblacute", + "udieresis", + "yacute", + "tcedilla", + "dotaccent", +}; + +static const struct { unsigned short u, c; } windows_1250_from_unicode[] = { + {0x00a0,160}, + {0x00a4,164}, + {0x00a6,166}, + {0x00a7,167}, + {0x00a8,168}, + {0x00a9,169}, + {0x00ab,171}, + {0x00ac,172}, + {0x00ad,173}, + {0x00ae,174}, + {0x00b0,176}, + {0x00b1,177}, + {0x00b4,180}, + {0x00b5,181}, + {0x00b6,182}, + {0x00b7,183}, + {0x00b8,184}, + {0x00bb,187}, + {0x00c1,193}, + {0x00c2,194}, + {0x00c4,196}, + {0x00c7,199}, + {0x00c9,201}, + {0x00cb,203}, + {0x00cd,205}, + {0x00ce,206}, + {0x00d3,211}, + {0x00d4,212}, + {0x00d6,214}, + {0x00d7,215}, + {0x00da,218}, + {0x00dc,220}, + {0x00dd,221}, + {0x00df,223}, + {0x00e1,225}, + {0x00e2,226}, + {0x00e4,228}, + {0x00e7,231}, + {0x00e9,233}, + {0x00eb,235}, + {0x00ed,237}, + {0x00ee,238}, + {0x00f3,243}, + {0x00f4,244}, + {0x00f6,246}, + {0x00f7,247}, + {0x00fa,250}, + {0x00fc,252}, + {0x00fd,253}, + {0x0102,195}, + {0x0103,227}, + {0x0104,165}, + {0x0105,185}, + {0x0106,198}, + {0x0107,230}, + {0x010c,200}, + {0x010d,232}, + {0x010e,207}, + {0x010f,239}, + {0x0110,208}, + {0x0111,240}, + {0x0118,202}, + {0x0119,234}, + {0x011a,204}, + {0x011b,236}, + {0x0139,197}, + {0x013a,229}, + {0x013d,188}, + {0x013e,190}, + {0x0141,163}, + {0x0142,179}, + {0x0143,209}, + {0x0144,241}, + {0x0147,210}, + {0x0148,242}, + {0x0150,213}, + {0x0151,245}, + {0x0154,192}, + {0x0155,224}, + {0x0158,216}, + {0x0159,248}, + {0x015a,140}, + {0x015b,156}, + {0x015e,170}, + {0x015f,186}, + {0x0160,138}, + {0x0161,154}, + {0x0162,222}, + {0x0163,254}, + {0x0164,141}, + {0x0165,157}, + {0x016e,217}, + {0x016f,249}, + {0x0170,219}, + {0x0171,251}, + {0x0179,143}, + {0x017a,159}, + {0x017b,175}, + {0x017c,191}, + {0x017d,142}, + {0x017e,158}, + {0x02c7,161}, + {0x02d8,162}, + {0x02d9,255}, + {0x02db,178}, + {0x02dd,189}, + {0x2013,150}, + {0x2014,151}, + {0x2018,145}, + {0x2019,146}, + {0x201a,130}, + {0x201c,147}, + {0x201d,148}, + {0x201e,132}, + {0x2020,134}, + {0x2021,135}, + {0x2022,149}, + {0x2026,133}, + {0x2030,137}, + {0x2039,139}, + {0x203a,155}, + {0x20ac,128}, + {0x2122,153}, +}; + +unsigned short fz_unicode_from_windows_1251[256] = { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 1026, + 1027, + 8218, + 1107, + 8222, + 8230, + 8224, + 8225, + 8364, + 8240, + 1033, + 8249, + 1034, + 1036, + 1035, + 1039, + 1106, + 8216, + 8217, + 8220, + 8221, + 8226, + 8211, + 8212, + 0, + 8482, + 1113, + 8250, + 1114, + 1116, + 1115, + 1119, + 160, + 1038, + 1118, + 1032, + 164, + 1168, + 166, + 167, + 1025, + 169, + 1028, + 171, + 172, + 173, + 174, + 1031, + 176, + 177, + 1030, + 1110, + 1169, + 181, + 182, + 183, + 1105, + 8470, + 1108, + 187, + 1112, + 1029, + 1109, + 1111, + 1040, + 1041, + 1042, + 1043, + 1044, + 1045, + 1046, + 1047, + 1048, + 1049, + 1050, + 1051, + 1052, + 1053, + 1054, + 1055, + 1056, + 1057, + 1058, + 1059, + 1060, + 1061, + 1062, + 1063, + 1064, + 1065, + 1066, + 1067, + 1068, + 1069, + 1070, + 1071, + 1072, + 1073, + 1074, + 1075, + 1076, + 1077, + 1078, + 1079, + 1080, + 1081, + 1082, + 1083, + 1084, + 1085, + 1086, + 1087, + 1088, + 1089, + 1090, + 1091, + 1092, + 1093, + 1094, + 1095, + 1096, + 1097, + 1098, + 1099, + 1100, + 1101, + 1102, + 1103, +}; + +const char *fz_glyph_name_from_windows_1251[256] = { + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quotesingle", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "grave", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "controlDEL", + "Djecyrillic", + "Gjecyrillic", + "quotesinglbase", + "afii10100", + "quotedblbase", + "ellipsis", + "dagger", + "daggerdbl", + "Euro", + "perthousand", + "Ljecyrillic", + "guilsinglleft", + "Njecyrillic", + "Kjecyrillic", + "Tshecyrillic", + "Dzhecyrillic", + "afii10099", + "quoteleft", + "quoteright", + "quotedblleft", + "quotedblright", + "bullet", + "endash", + "emdash", + _notdef, + "trademark", + "afii10106", + "guilsinglright", + "afii10107", + "afii10109", + "afii10108", + "afii10193", + "nbspace", + "Ushortcyrillic", + "afii10110", + "Jecyrillic", + "currency", + "Gheupturncyrillic", + "brokenbar", + "section", + "Iocyrillic", + "copyright", + "Ecyrillic", + "guillemotleft", + "logicalnot", + "sfthyphen", + "registered", + "Yicyrillic", + "degree", + "plusminus", + "Icyrillic", + "afii10103", + "afii10098", + "mu", + "paragraph", + "middot", + "afii10071", + "afii61352", + "afii10101", + "guillemotright", + "afii10105", + "Dzecyrillic", + "afii10102", + "afii10104", + "Acyrillic", + "Becyrillic", + "Vecyrillic", + "Gecyrillic", + "Decyrillic", + "Iecyrillic", + "Zhecyrillic", + "Zecyrillic", + "Iicyrillic", + "Iishortcyrillic", + "Kacyrillic", + "Elcyrillic", + "Emcyrillic", + "Encyrillic", + "Ocyrillic", + "Pecyrillic", + "Ercyrillic", + "Escyrillic", + "Tecyrillic", + "Ucyrillic", + "Efcyrillic", + "Khacyrillic", + "Tsecyrillic", + "Checyrillic", + "Shacyrillic", + "Shchacyrillic", + "Hardsigncyrillic", + "Yericyrillic", + "Softsigncyrillic", + "Ereversedcyrillic", + "IUcyrillic", + "IAcyrillic", + "acyrillic", + "afii10066", + "afii10067", + "afii10068", + "afii10069", + "afii10070", + "afii10072", + "afii10073", + "afii10074", + "afii10075", + "afii10076", + "afii10077", + "afii10078", + "afii10079", + "afii10080", + "afii10081", + "afii10082", + "afii10083", + "afii10084", + "afii10085", + "afii10086", + "afii10087", + "afii10088", + "afii10089", + "afii10090", + "afii10091", + "afii10092", + "afii10093", + "afii10094", + "afii10095", + "afii10096", + "afii10097", +}; + +static const struct { unsigned short u, c; } windows_1251_from_unicode[] = { + {0x00a0,160}, + {0x00a4,164}, + {0x00a6,166}, + {0x00a7,167}, + {0x00a9,169}, + {0x00ab,171}, + {0x00ac,172}, + {0x00ad,173}, + {0x00ae,174}, + {0x00b0,176}, + {0x00b1,177}, + {0x00b5,181}, + {0x00b6,182}, + {0x00b7,183}, + {0x00bb,187}, + {0x0401,168}, + {0x0402,128}, + {0x0403,129}, + {0x0404,170}, + {0x0405,189}, + {0x0406,178}, + {0x0407,175}, + {0x0408,163}, + {0x0409,138}, + {0x040a,140}, + {0x040b,142}, + {0x040c,141}, + {0x040e,161}, + {0x040f,143}, + {0x0410,192}, + {0x0411,193}, + {0x0412,194}, + {0x0413,195}, + {0x0414,196}, + {0x0415,197}, + {0x0416,198}, + {0x0417,199}, + {0x0418,200}, + {0x0419,201}, + {0x041a,202}, + {0x041b,203}, + {0x041c,204}, + {0x041d,205}, + {0x041e,206}, + {0x041f,207}, + {0x0420,208}, + {0x0421,209}, + {0x0422,210}, + {0x0423,211}, + {0x0424,212}, + {0x0425,213}, + {0x0426,214}, + {0x0427,215}, + {0x0428,216}, + {0x0429,217}, + {0x042a,218}, + {0x042b,219}, + {0x042c,220}, + {0x042d,221}, + {0x042e,222}, + {0x042f,223}, + {0x0430,224}, + {0x0431,225}, + {0x0432,226}, + {0x0433,227}, + {0x0434,228}, + {0x0435,229}, + {0x0436,230}, + {0x0437,231}, + {0x0438,232}, + {0x0439,233}, + {0x043a,234}, + {0x043b,235}, + {0x043c,236}, + {0x043d,237}, + {0x043e,238}, + {0x043f,239}, + {0x0440,240}, + {0x0441,241}, + {0x0442,242}, + {0x0443,243}, + {0x0444,244}, + {0x0445,245}, + {0x0446,246}, + {0x0447,247}, + {0x0448,248}, + {0x0449,249}, + {0x044a,250}, + {0x044b,251}, + {0x044c,252}, + {0x044d,253}, + {0x044e,254}, + {0x044f,255}, + {0x0451,184}, + {0x0452,144}, + {0x0453,131}, + {0x0454,186}, + {0x0455,190}, + {0x0456,179}, + {0x0457,191}, + {0x0458,188}, + {0x0459,154}, + {0x045a,156}, + {0x045b,158}, + {0x045c,157}, + {0x045e,162}, + {0x045f,159}, + {0x0490,165}, + {0x0491,180}, + {0x2013,150}, + {0x2014,151}, + {0x2018,145}, + {0x2019,146}, + {0x201a,130}, + {0x201c,147}, + {0x201d,148}, + {0x201e,132}, + {0x2020,134}, + {0x2021,135}, + {0x2022,149}, + {0x2026,133}, + {0x2030,137}, + {0x2039,139}, + {0x203a,155}, + {0x20ac,136}, + {0x2116,185}, + {0x2122,153}, +}; + +unsigned short fz_unicode_from_windows_1252[256] = { + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 8364, + 0, + 8218, + 402, + 8222, + 8230, + 8224, + 8225, + 710, + 8240, + 352, + 8249, + 338, + 0, + 381, + 0, + 0, + 8216, + 8217, + 8220, + 8221, + 8226, + 8211, + 8212, + 732, + 8482, + 353, + 8250, + 339, + 0, + 382, + 376, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255, +}; + +const char *fz_glyph_name_from_windows_1252[256] = { + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + _notdef, + "space", + "exclam", + "quotedbl", + "numbersign", + "dollar", + "percent", + "ampersand", + "quotesingle", + "parenleft", + "parenright", + "asterisk", + "plus", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less", + "equal", + "greater", + "question", + "at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "bracketleft", + "backslash", + "bracketright", + "asciicircum", + "underscore", + "grave", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "braceleft", + "bar", + "braceright", + "asciitilde", + "controlDEL", + "Euro", + _notdef, + "quotesinglbase", + "florin", + "quotedblbase", + "ellipsis", + "dagger", + "daggerdbl", + "circumflex", + "perthousand", + "Scaron", + "guilsinglleft", + "OE", + _notdef, + "Zcaron", + _notdef, + _notdef, + "quoteleft", + "quoteright", + "quotedblleft", + "quotedblright", + "bullet", + "endash", + "emdash", + "ilde", + "trademark", + "scaron", + "guilsinglright", + "oe", + _notdef, + "zcaron", + "Ydieresis", + "nbspace", + "exclamdown", + "cent", + "sterling", + "currency", + "yen", + "brokenbar", + "section", + "dieresis", + "copyright", + "ordfeminine", + "guillemotleft", + "logicalnot", + "sfthyphen", + "registered", + "macron", + "degree", + "plusminus", + "twosuperior", + "threesuperior", + "acute", + "mu", + "paragraph", + "middot", + "cedilla", + "onesuperior", + "ordmasculine", + "guillemotright", + "onequarter", + "onehalf", + "threequarters", + "questiondown", + "Agrave", + "Aacute", + "Acircumflex", + "Atilde", + "Adieresis", + "Aring", + "AE", + "Ccedilla", + "Egrave", + "Eacute", + "Ecircumflex", + "Edieresis", + "Igrave", + "Iacute", + "Icircumflex", + "Idieresis", + "Eth", + "Ntilde", + "Ograve", + "Oacute", + "Ocircumflex", + "Otilde", + "Odieresis", + "multiply", + "Oslash", + "Ugrave", + "Uacute", + "Ucircumflex", + "Udieresis", + "Yacute", + "Thorn", + "germandbls", + "agrave", + "aacute", + "acircumflex", + "atilde", + "adieresis", + "aring", + "ae", + "ccedilla", + "egrave", + "eacute", + "ecircumflex", + "edieresis", + "igrave", + "iacute", + "icircumflex", + "idieresis", + "eth", + "ntilde", + "ograve", + "oacute", + "ocircumflex", + "otilde", + "odieresis", + "divide", + "oslash", + "ugrave", + "uacute", + "ucircumflex", + "udieresis", + "yacute", + "thorn", + "ydieresis", +}; + +static const struct { unsigned short u, c; } windows_1252_from_unicode[] = { + {0x00a0,160}, + {0x00a1,161}, + {0x00a2,162}, + {0x00a3,163}, + {0x00a4,164}, + {0x00a5,165}, + {0x00a6,166}, + {0x00a7,167}, + {0x00a8,168}, + {0x00a9,169}, + {0x00aa,170}, + {0x00ab,171}, + {0x00ac,172}, + {0x00ad,173}, + {0x00ae,174}, + {0x00af,175}, + {0x00b0,176}, + {0x00b1,177}, + {0x00b2,178}, + {0x00b3,179}, + {0x00b4,180}, + {0x00b5,181}, + {0x00b6,182}, + {0x00b7,183}, + {0x00b8,184}, + {0x00b9,185}, + {0x00ba,186}, + {0x00bb,187}, + {0x00bc,188}, + {0x00bd,189}, + {0x00be,190}, + {0x00bf,191}, + {0x00c0,192}, + {0x00c1,193}, + {0x00c2,194}, + {0x00c3,195}, + {0x00c4,196}, + {0x00c5,197}, + {0x00c6,198}, + {0x00c7,199}, + {0x00c8,200}, + {0x00c9,201}, + {0x00ca,202}, + {0x00cb,203}, + {0x00cc,204}, + {0x00cd,205}, + {0x00ce,206}, + {0x00cf,207}, + {0x00d0,208}, + {0x00d1,209}, + {0x00d2,210}, + {0x00d3,211}, + {0x00d4,212}, + {0x00d5,213}, + {0x00d6,214}, + {0x00d7,215}, + {0x00d8,216}, + {0x00d9,217}, + {0x00da,218}, + {0x00db,219}, + {0x00dc,220}, + {0x00dd,221}, + {0x00de,222}, + {0x00df,223}, + {0x00e0,224}, + {0x00e1,225}, + {0x00e2,226}, + {0x00e3,227}, + {0x00e4,228}, + {0x00e5,229}, + {0x00e6,230}, + {0x00e7,231}, + {0x00e8,232}, + {0x00e9,233}, + {0x00ea,234}, + {0x00eb,235}, + {0x00ec,236}, + {0x00ed,237}, + {0x00ee,238}, + {0x00ef,239}, + {0x00f0,240}, + {0x00f1,241}, + {0x00f2,242}, + {0x00f3,243}, + {0x00f4,244}, + {0x00f5,245}, + {0x00f6,246}, + {0x00f7,247}, + {0x00f8,248}, + {0x00f9,249}, + {0x00fa,250}, + {0x00fb,251}, + {0x00fc,252}, + {0x00fd,253}, + {0x00fe,254}, + {0x00ff,255}, + {0x0152,140}, + {0x0153,156}, + {0x0160,138}, + {0x0161,154}, + {0x0178,159}, + {0x017d,142}, + {0x017e,158}, + {0x0192,131}, + {0x02c6,136}, + {0x02dc,152}, + {0x2013,150}, + {0x2014,151}, + {0x2018,145}, + {0x2019,146}, + {0x201a,130}, + {0x201c,147}, + {0x201d,148}, + {0x201e,132}, + {0x2020,134}, + {0x2021,135}, + {0x2022,149}, + {0x2026,133}, + {0x2030,137}, + {0x2039,139}, + {0x203a,155}, + {0x20ac,128}, + {0x2122,153}, +}; diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index c18d5860..a3067e16 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -673,7 +673,7 @@ measure_simple_string(fz_context *ctx, fz_font *font, const char *text) { int c, g; text += fz_chartorune(&c, text); - c = pdf_winansi_from_unicode(c); + c = fz_windows_1252_from_unicode(c); if (c < 0) c = REPLACEMENT; g = fz_encode_character(ctx, font, c); w += fz_advance_glyph(ctx, font, g, 0); @@ -689,7 +689,7 @@ write_simple_string(fz_context *ctx, fz_buffer *buf, const char *a, const char * { int c; a += fz_chartorune(&c, a); - c = pdf_winansi_from_unicode(c); + c = fz_windows_1252_from_unicode(c); if (c < 0) c = REPLACEMENT; if (c == '(' || c == ')' || c == '\\') fz_append_byte(ctx, buf, '\\'); @@ -871,7 +871,7 @@ write_comb_string(fz_context *ctx, fz_buffer *buf, const char *a, const char *b, int c, g; a += fz_chartorune(&c, a); - c = pdf_winansi_from_unicode(c); + c = fz_windows_1252_from_unicode(c); if (c < 0) c = REPLACEMENT; g = fz_encode_character(ctx, font, c); diff --git a/source/pdf/pdf-encoding.c b/source/pdf/pdf-encoding.c index f4fe584c..bf0d3df8 100644 --- a/source/pdf/pdf-encoding.c +++ b/source/pdf/pdf-encoding.c @@ -7,6 +7,8 @@ #include #include +#define pdf_win_ansi fz_glyph_name_from_windows_1252 + void pdf_load_encoding(const char **estrings, const char *encoding) { @@ -85,60 +87,3 @@ pdf_lookup_agl_duplicates(int ucs) } return empty_dup_list; } - -int pdf_cyrillic_from_unicode(int u) -{ - int l = 0; - int r = nelem(koi8u_from_unicode) - 1; - if (u < 128) - return u; - while (l <= r) - { - int m = (l + r) >> 1; - if (u < koi8u_from_unicode[m].u) - r = m - 1; - else if (u > koi8u_from_unicode[m].u) - l = m + 1; - else - return koi8u_from_unicode[m].c; - } - return -1; -} - -int pdf_greek_from_unicode(int u) -{ - int l = 0; - int r = nelem(iso8859_7_from_unicode) - 1; - if (u < 128) - return u; - while (l <= r) - { - int m = (l + r) >> 1; - if (u < iso8859_7_from_unicode[m].u) - r = m - 1; - else if (u > iso8859_7_from_unicode[m].u) - l = m + 1; - else - return iso8859_7_from_unicode[m].c; - } - return -1; -} - -int pdf_winansi_from_unicode(int u) -{ - int l = 0; - int r = nelem(winansi_from_unicode) - 1; - if (u < 128) - return u; - while (l <= r) - { - int m = (l + r) >> 1; - if (u < winansi_from_unicode[m].u) - r = m - 1; - else if (u > winansi_from_unicode[m].u) - l = m + 1; - else - return winansi_from_unicode[m].c; - } - return -1; -} diff --git a/source/pdf/pdf-encodings.h b/source/pdf/pdf-encodings.h index f9e84c49..efdfe1f7 100644 --- a/source/pdf/pdf-encodings.h +++ b/source/pdf/pdf-encodings.h @@ -166,206 +166,3 @@ const char *pdf_mac_expert[256] = { "periodsuperior", "Dotaccentsmall", "Ringsmall", _notdef, _notdef, _notdef, _notdef }; - -const char *pdf_win_ansi[256] = { - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", - "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", - "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", - "three", "four", "five", "six", "seven", "eight", "nine", "colon", - "semicolon", "less", "equal", "greater", "question", "at", "A", "B", - "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", - "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", - "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", - "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", - "bar", "braceright", "asciitilde", "bullet", "Euro", "bullet", - "quotesinglbase", "florin", "quotedblbase", "ellipsis", "dagger", - "daggerdbl", "circumflex", "perthousand", "Scaron", "guilsinglleft", - "OE", "bullet", "Zcaron", "bullet", "bullet", "quoteleft", - "quoteright", "quotedblleft", "quotedblright", "bullet", "endash", - "emdash", "tilde", "trademark", "scaron", "guilsinglright", "oe", - "bullet", "zcaron", "Ydieresis", "space", "exclamdown", "cent", - "sterling", "currency", "yen", "brokenbar", "section", "dieresis", - "copyright", "ordfeminine", "guillemotleft", "logicalnot", "hyphen", - "registered", "macron", "degree", "plusminus", "twosuperior", - "threesuperior", "acute", "mu", "paragraph", "periodcentered", - "cedilla", "onesuperior", "ordmasculine", "guillemotright", - "onequarter", "onehalf", "threequarters", "questiondown", "Agrave", - "Aacute", "Acircumflex", "Atilde", "Adieresis", "Aring", "AE", - "Ccedilla", "Egrave", "Eacute", "Ecircumflex", "Edieresis", "Igrave", - "Iacute", "Icircumflex", "Idieresis", "Eth", "Ntilde", "Ograve", - "Oacute", "Ocircumflex", "Otilde", "Odieresis", "multiply", "Oslash", - "Ugrave", "Uacute", "Ucircumflex", "Udieresis", "Yacute", "Thorn", - "germandbls", "agrave", "aacute", "acircumflex", "atilde", "adieresis", - "aring", "ae", "ccedilla", "egrave", "eacute", "ecircumflex", - "edieresis", "igrave", "iacute", "icircumflex", "idieresis", "eth", - "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", - "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", - "yacute", "thorn", "ydieresis" -}; - -const char *pdf_glyph_name_from_koi8u[256] = { - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", - "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", - "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", - "three", "four", "five", "six", "seven", "eight", "nine", "colon", - "semicolon", "less", "equal", "greater", "question", "at", "A", "B", - "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", - "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", - "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", - "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", - "bar", "braceright", "asciitilde", _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, "integraltp", _notdef, "bulletoperator", - "radical", "approxequal", "lessequal", "greaterequal", - "nonbreakingspace", "integralbt", "degree", "twosuperior", - "periodcentered", "divide", _notdef, _notdef, _notdef, "iocyrillic", - "ecyrillic", _notdef, "icyrillic", "yicyrillic", _notdef, _notdef, - _notdef, _notdef, _notdef, "gheupturncyrillic", _notdef, _notdef, - _notdef, _notdef, _notdef, "afii10023", "afii10053", _notdef, - "afii10055", "afii10056", _notdef, _notdef, _notdef, _notdef, _notdef, - "afii10050", _notdef, "copyright", "iucyrillic", "afii10065", - "becyrillic", "tsecyrillic", "decyrillic", "iecyrillic", "efcyrillic", - "gecyrillic", "khacyrillic", "iicyrillic", "iishortcyrillic", - "kacyrillic", "elcyrillic", "emcyrillic", "encyrillic", "ocyrillic", - "pecyrillic", "iacyrillic", "ercyrillic", "escyrillic", "tecyrillic", - "ucyrillic", "zhecyrillic", "vecyrillic", "softsigncyrillic", - "yericyrillic", "zecyrillic", "shacyrillic", "ereversedcyrillic", - "shchacyrillic", "checyrillic", "hardsigncyrillic", "afii10048", - "afii10017", "afii10018", "afii10040", "afii10021", "afii10022", - "afii10038", "afii10020", "afii10039", "afii10026", "afii10027", - "afii10028", "afii10029", "afii10030", "afii10031", "afii10032", - "afii10033", "afii10049", "afii10034", "afii10035", "afii10036", - "afii10037", "afii10024", "afii10019", "afii10046", "afii10045", - "afii10025", "afii10042", "afii10047", "afii10043", "afii10041", - "afii10044", -}; - -static const struct { unsigned short u, c; } koi8u_from_unicode[] = { - {0x00a0,154}, {0x00a9,191}, {0x00b0,156}, {0x00b2,157}, {0x00b7,158}, - {0x00f7,159}, {0x0401,179}, {0x0404,180}, {0x0406,182}, {0x0407,183}, - {0x0410,225}, {0x0411,226}, {0x0412,247}, {0x0413,231}, {0x0414,228}, - {0x0415,229}, {0x0416,246}, {0x0417,250}, {0x0418,233}, {0x0419,234}, - {0x041a,235}, {0x041b,236}, {0x041c,237}, {0x041d,238}, {0x041e,239}, - {0x041f,240}, {0x0420,242}, {0x0421,243}, {0x0422,244}, {0x0423,245}, - {0x0424,230}, {0x0425,232}, {0x0426,227}, {0x0427,254}, {0x0428,251}, - {0x0429,253}, {0x042a,255}, {0x042b,249}, {0x042c,248}, {0x042d,252}, - {0x042e,224}, {0x042f,241}, {0x0430,193}, {0x0431,194}, {0x0432,215}, - {0x0433,199}, {0x0434,196}, {0x0435,197}, {0x0436,214}, {0x0437,218}, - {0x0438,201}, {0x0439,202}, {0x043a,203}, {0x043b,204}, {0x043c,205}, - {0x043d,206}, {0x043e,207}, {0x043f,208}, {0x0440,210}, {0x0441,211}, - {0x0442,212}, {0x0443,213}, {0x0444,198}, {0x0445,200}, {0x0446,195}, - {0x0447,222}, {0x0448,219}, {0x0449,221}, {0x044a,223}, {0x044b,217}, - {0x044c,216}, {0x044d,220}, {0x044e,192}, {0x044f,209}, {0x0451,163}, - {0x0454,164}, {0x0456,166}, {0x0457,167}, {0x0490,189}, {0x0491,173}, - {0x2219,149}, {0x221a,150}, {0x2248,151}, {0x2264,152}, {0x2265,153}, - {0x2320,147}, {0x2321,155}, {0x2500,128}, {0x2502,129}, {0x250c,130}, - {0x2510,131}, {0x2514,132}, {0x2518,133}, {0x251c,134}, {0x2524,135}, - {0x252c,136}, {0x2534,137}, {0x253c,138}, {0x2550,160}, {0x2551,161}, - {0x2552,162}, {0x2554,165}, {0x2557,168}, {0x2558,169}, {0x2559,170}, - {0x255a,171}, {0x255b,172}, {0x255d,174}, {0x255e,175}, {0x255f,176}, - {0x2560,177}, {0x2561,178}, {0x2563,181}, {0x2566,184}, {0x2567,185}, - {0x2568,186}, {0x2569,187}, {0x256a,188}, {0x256c,190}, {0x2580,139}, - {0x2584,140}, {0x2588,141}, {0x258c,142}, {0x2590,143}, {0x2591,144}, - {0x2592,145}, {0x2593,146}, {0x25a0,148} -}; - -const char *pdf_glyph_name_from_iso8859_7[256] = { - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", - "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", - "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", - "three", "four", "five", "six", "seven", "eight", "nine", "colon", - "semicolon", "less", "equal", "greater", "question", "at", "A", "B", - "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", - "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", - "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", - "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", - "bar", "braceright", "asciitilde", _notdef, - /* the block drawing characters have been omitted */ - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, - "nonbreakingspace", "quoteleft", "quoteright", "sterling", "euro", - _notdef, "brokenbar", "section", "dieresis", "copyright", - "ypogegrammeni", "guillemotleft", "logicalnot", "softhyphen", _notdef, - "horizontalbar", "degree", "plusminus", "twosuperior", "threesuperior", - "tonos", "dieresistonos", "Alphatonos", "periodcentered", - "Epsilontonos", "Etatonos", "Iotatonos", "guillemotright", - "Omicrontonos", "onehalf", "Upsilontonos", "Omegatonos", - "iotadieresistonos", "Alpha", "Beta", "Gamma", "Deltagreek", "Epsilon", - "Zeta", "Eta", "Theta", "Iota", "Kappa", "Lambda", "Mu", "Nu", "Xi", - "Omicron", "Pi", "Rho", _notdef, "Sigma", "Tau", "Upsilon", "Phi", - "Chi", "Psi", "Omegagreek", "Iotadieresis", "Upsilondieresis", - "alphatonos", "epsilontonos", "etatonos", "iotatonos", - "upsilondieresistonos", "alpha", "beta", "gamma", "delta", "epsilon", - "zeta", "eta", "theta", "iota", "kappa", "lambda", "mugreek", "nu", - "xi", "omicron", "pi", "rho", "sigmafinal", "sigma", "tau", "upsilon", - "phi", "chi", "psi", "omega", "iotadieresis", "upsilondieresis", - "omicrontonos", "upsilontonos", "omegatonos", _notdef, -}; - -static const struct { unsigned short u, c; } iso8859_7_from_unicode[] = { - {0x00a0,160}, {0x00a3,163}, {0x00a6,166}, {0x00a7,167}, {0x00a8,168}, - {0x00a9,169}, {0x00ab,171}, {0x00ac,172}, {0x00ad,173}, {0x00b0,176}, - {0x00b1,177}, {0x00b2,178}, {0x00b3,179}, {0x00b7,183}, {0x00bb,187}, - {0x00bd,189}, {0x037a,170}, {0x0384,180}, {0x0385,181}, {0x0386,182}, - {0x0388,184}, {0x0389,185}, {0x038a,186}, {0x038c,188}, {0x038e,190}, - {0x038f,191}, {0x0390,192}, {0x0391,193}, {0x0392,194}, {0x0393,195}, - {0x0394,196}, {0x0395,197}, {0x0396,198}, {0x0397,199}, {0x0398,200}, - {0x0399,201}, {0x039a,202}, {0x039b,203}, {0x039c,204}, {0x039d,205}, - {0x039e,206}, {0x039f,207}, {0x03a0,208}, {0x03a1,209}, {0x03a3,211}, - {0x03a4,212}, {0x03a5,213}, {0x03a6,214}, {0x03a7,215}, {0x03a8,216}, - {0x03a9,217}, {0x03aa,218}, {0x03ab,219}, {0x03ac,220}, {0x03ad,221}, - {0x03ae,222}, {0x03af,223}, {0x03b0,224}, {0x03b1,225}, {0x03b2,226}, - {0x03b3,227}, {0x03b4,228}, {0x03b5,229}, {0x03b6,230}, {0x03b7,231}, - {0x03b8,232}, {0x03b9,233}, {0x03ba,234}, {0x03bb,235}, {0x03bc,236}, - {0x03bd,237}, {0x03be,238}, {0x03bf,239}, {0x03c0,240}, {0x03c1,241}, - {0x03c2,242}, {0x03c3,243}, {0x03c4,244}, {0x03c5,245}, {0x03c6,246}, - {0x03c7,247}, {0x03c8,248}, {0x03c9,249}, {0x03ca,250}, {0x03cb,251}, - {0x03cc,252}, {0x03cd,253}, {0x03ce,254}, {0x2015,175}, {0x2018,161}, - {0x2019,162}, {0x20ac,164}, -}; - -static const struct { unsigned short u, c; } winansi_from_unicode[] = { - {0x00a0,160}, {0x00a1,161}, {0x00a2,162}, {0x00a3,163}, {0x00a4,164}, - {0x00a5,165}, {0x00a6,166}, {0x00a7,167}, {0x00a8,168}, {0x00a9,169}, - {0x00aa,170}, {0x00ab,171}, {0x00ac,172}, {0x00ad,173}, {0x00ae,174}, - {0x00af,175}, {0x00b0,176}, {0x00b1,177}, {0x00b2,178}, {0x00b3,179}, - {0x00b4,180}, {0x00b5,181}, {0x00b6,182}, {0x00b7,183}, {0x00b8,184}, - {0x00b9,185}, {0x00ba,186}, {0x00bb,187}, {0x00bc,188}, {0x00bd,189}, - {0x00be,190}, {0x00bf,191}, {0x00c0,192}, {0x00c1,193}, {0x00c2,194}, - {0x00c3,195}, {0x00c4,196}, {0x00c5,197}, {0x00c6,198}, {0x00c7,199}, - {0x00c8,200}, {0x00c9,201}, {0x00ca,202}, {0x00cb,203}, {0x00cc,204}, - {0x00cd,205}, {0x00ce,206}, {0x00cf,207}, {0x00d0,208}, {0x00d1,209}, - {0x00d2,210}, {0x00d3,211}, {0x00d4,212}, {0x00d5,213}, {0x00d6,214}, - {0x00d7,215}, {0x00d8,216}, {0x00d9,217}, {0x00da,218}, {0x00db,219}, - {0x00dc,220}, {0x00dd,221}, {0x00de,222}, {0x00df,223}, {0x00e0,224}, - {0x00e1,225}, {0x00e2,226}, {0x00e3,227}, {0x00e4,228}, {0x00e5,229}, - {0x00e6,230}, {0x00e7,231}, {0x00e8,232}, {0x00e9,233}, {0x00ea,234}, - {0x00eb,235}, {0x00ec,236}, {0x00ed,237}, {0x00ee,238}, {0x00ef,239}, - {0x00f0,240}, {0x00f1,241}, {0x00f2,242}, {0x00f3,243}, {0x00f4,244}, - {0x00f5,245}, {0x00f6,246}, {0x00f7,247}, {0x00f8,248}, {0x00f9,249}, - {0x00fa,250}, {0x00fb,251}, {0x00fc,252}, {0x00fd,253}, {0x00fe,254}, - {0x00ff,255}, {0x0152,140}, {0x0153,156}, {0x0160,138}, {0x0161,154}, - {0x0178,159}, {0x017d,142}, {0x017e,158}, {0x0192,131}, {0x02c6,136}, - {0x02dc,152}, {0x2013,150}, {0x2014,151}, {0x2018,145}, {0x2019,146}, - {0x201a,130}, {0x201c,147}, {0x201d,148}, {0x201e,132}, {0x2020,134}, - {0x2021,135}, {0x2022,149}, {0x2026,133}, {0x2030,137}, {0x2039,139}, - {0x203a,155}, {0x20ac,128}, {0x2122,153}, -}; diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index a0df70fd..391a1024 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -20,6 +20,8 @@ #define FT_SFNT_HEAD ft_sfnt_head #endif +#define pdf_win_ansi fz_glyph_name_from_windows_1252 + static void pdf_load_font_descriptor(fz_context *ctx, pdf_document *doc, pdf_font_desc *fontdesc, pdf_obj *dict, const char *collection, const char *basefont, int iscidfont); @@ -2037,10 +2039,10 @@ pdf_add_simple_font_encoding(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, pdf_dict_put(ctx, fobj, PDF_NAME(Encoding), PDF_NAME(WinAnsiEncoding)); break; case PDF_SIMPLE_ENCODING_GREEK: - pdf_add_simple_font_encoding_imp(ctx, doc, fobj, pdf_glyph_name_from_iso8859_7); + pdf_add_simple_font_encoding_imp(ctx, doc, fobj, fz_glyph_name_from_iso8859_7); break; case PDF_SIMPLE_ENCODING_CYRILLIC: - pdf_add_simple_font_encoding_imp(ctx, doc, fobj, pdf_glyph_name_from_koi8u); + pdf_add_simple_font_encoding_imp(ctx, doc, fobj, fz_glyph_name_from_koi8u); break; } } @@ -2061,9 +2063,9 @@ pdf_add_simple_font(fz_context *ctx, pdf_document *doc, fz_font *font, int encod switch (encoding) { default: enc = pdf_win_ansi; break; - case PDF_SIMPLE_ENCODING_LATIN: enc = pdf_win_ansi; break; - case PDF_SIMPLE_ENCODING_GREEK: enc = pdf_glyph_name_from_iso8859_7; break; - case PDF_SIMPLE_ENCODING_CYRILLIC: enc = pdf_glyph_name_from_koi8u; break; + case PDF_SIMPLE_ENCODING_LATIN: enc = fz_glyph_name_from_windows_1252; break; + case PDF_SIMPLE_ENCODING_GREEK: enc = fz_glyph_name_from_iso8859_7; break; + case PDF_SIMPLE_ENCODING_CYRILLIC: enc = fz_glyph_name_from_koi8u; break; } fobj = pdf_add_new_dict(ctx, doc, 10); -- cgit v1.2.3