diff options
Diffstat (limited to 'Build/source/texk/web2c/mfluadir/otfcc/lib/support')
25 files changed, 3589 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.c new file mode 100644 index 00000000000..1b770527de0 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.c @@ -0,0 +1,592 @@ +#include "aglfn.h" +#define GlyphOrder otfcc_pkgGlyphOrder + +// This table contains standard AGLFN 1.7 glyph names, mapped to Unicode. +void aglfn_setupNames(otfcc_GlyphOrder *map) { + GlyphOrder.setByGID(map, 0x0041, sdsnew("A")); + GlyphOrder.setByGID(map, 0x00C6, sdsnew("AE")); + GlyphOrder.setByGID(map, 0x01FC, sdsnew("AEacute")); + GlyphOrder.setByGID(map, 0x00C1, sdsnew("Aacute")); + GlyphOrder.setByGID(map, 0x0102, sdsnew("Abreve")); + GlyphOrder.setByGID(map, 0x00C2, sdsnew("Acircumflex")); + GlyphOrder.setByGID(map, 0x00C4, sdsnew("Adieresis")); + GlyphOrder.setByGID(map, 0x00C0, sdsnew("Agrave")); + GlyphOrder.setByGID(map, 0x0391, sdsnew("Alpha")); + GlyphOrder.setByGID(map, 0x0386, sdsnew("Alphatonos")); + GlyphOrder.setByGID(map, 0x0100, sdsnew("Amacron")); + GlyphOrder.setByGID(map, 0x0104, sdsnew("Aogonek")); + GlyphOrder.setByGID(map, 0x00C5, sdsnew("Aring")); + GlyphOrder.setByGID(map, 0x01FA, sdsnew("Aringacute")); + GlyphOrder.setByGID(map, 0x00C3, sdsnew("Atilde")); + GlyphOrder.setByGID(map, 0x0042, sdsnew("B")); + GlyphOrder.setByGID(map, 0x0392, sdsnew("Beta")); + GlyphOrder.setByGID(map, 0x0043, sdsnew("C")); + GlyphOrder.setByGID(map, 0x0106, sdsnew("Cacute")); + GlyphOrder.setByGID(map, 0x010C, sdsnew("Ccaron")); + GlyphOrder.setByGID(map, 0x00C7, sdsnew("Ccedilla")); + GlyphOrder.setByGID(map, 0x0108, sdsnew("Ccircumflex")); + GlyphOrder.setByGID(map, 0x010A, sdsnew("Cdotaccent")); + GlyphOrder.setByGID(map, 0x03A7, sdsnew("Chi")); + GlyphOrder.setByGID(map, 0x0044, sdsnew("D")); + GlyphOrder.setByGID(map, 0x010E, sdsnew("Dcaron")); + GlyphOrder.setByGID(map, 0x0110, sdsnew("Dcroat")); + GlyphOrder.setByGID(map, 0x2206, sdsnew("Delta")); + GlyphOrder.setByGID(map, 0x0045, sdsnew("E")); + GlyphOrder.setByGID(map, 0x00C9, sdsnew("Eacute")); + GlyphOrder.setByGID(map, 0x0114, sdsnew("Ebreve")); + GlyphOrder.setByGID(map, 0x011A, sdsnew("Ecaron")); + GlyphOrder.setByGID(map, 0x00CA, sdsnew("Ecircumflex")); + GlyphOrder.setByGID(map, 0x00CB, sdsnew("Edieresis")); + GlyphOrder.setByGID(map, 0x0116, sdsnew("Edotaccent")); + GlyphOrder.setByGID(map, 0x00C8, sdsnew("Egrave")); + GlyphOrder.setByGID(map, 0x0112, sdsnew("Emacron")); + GlyphOrder.setByGID(map, 0x014A, sdsnew("Eng")); + GlyphOrder.setByGID(map, 0x0118, sdsnew("Eogonek")); + GlyphOrder.setByGID(map, 0x0395, sdsnew("Epsilon")); + GlyphOrder.setByGID(map, 0x0388, sdsnew("Epsilontonos")); + GlyphOrder.setByGID(map, 0x0397, sdsnew("Eta")); + GlyphOrder.setByGID(map, 0x0389, sdsnew("Etatonos")); + GlyphOrder.setByGID(map, 0x00D0, sdsnew("Eth")); + GlyphOrder.setByGID(map, 0x20AC, sdsnew("Euro")); + GlyphOrder.setByGID(map, 0x0046, sdsnew("F")); + GlyphOrder.setByGID(map, 0x0047, sdsnew("G")); + GlyphOrder.setByGID(map, 0x0393, sdsnew("Gamma")); + GlyphOrder.setByGID(map, 0x011E, sdsnew("Gbreve")); + GlyphOrder.setByGID(map, 0x01E6, sdsnew("Gcaron")); + GlyphOrder.setByGID(map, 0x011C, sdsnew("Gcircumflex")); + GlyphOrder.setByGID(map, 0x0120, sdsnew("Gdotaccent")); + GlyphOrder.setByGID(map, 0x0048, sdsnew("H")); + GlyphOrder.setByGID(map, 0x25CF, sdsnew("H18533")); + GlyphOrder.setByGID(map, 0x25AA, sdsnew("H18543")); + GlyphOrder.setByGID(map, 0x25AB, sdsnew("H18551")); + GlyphOrder.setByGID(map, 0x25A1, sdsnew("H22073")); + GlyphOrder.setByGID(map, 0x0126, sdsnew("Hbar")); + GlyphOrder.setByGID(map, 0x0124, sdsnew("Hcircumflex")); + GlyphOrder.setByGID(map, 0x0049, sdsnew("I")); + GlyphOrder.setByGID(map, 0x0132, sdsnew("IJ")); + GlyphOrder.setByGID(map, 0x00CD, sdsnew("Iacute")); + GlyphOrder.setByGID(map, 0x012C, sdsnew("Ibreve")); + GlyphOrder.setByGID(map, 0x00CE, sdsnew("Icircumflex")); + GlyphOrder.setByGID(map, 0x00CF, sdsnew("Idieresis")); + GlyphOrder.setByGID(map, 0x0130, sdsnew("Idotaccent")); + GlyphOrder.setByGID(map, 0x2111, sdsnew("Ifraktur")); + GlyphOrder.setByGID(map, 0x00CC, sdsnew("Igrave")); + GlyphOrder.setByGID(map, 0x012A, sdsnew("Imacron")); + GlyphOrder.setByGID(map, 0x012E, sdsnew("Iogonek")); + GlyphOrder.setByGID(map, 0x0399, sdsnew("Iota")); + GlyphOrder.setByGID(map, 0x03AA, sdsnew("Iotadieresis")); + GlyphOrder.setByGID(map, 0x038A, sdsnew("Iotatonos")); + GlyphOrder.setByGID(map, 0x0128, sdsnew("Itilde")); + GlyphOrder.setByGID(map, 0x004A, sdsnew("J")); + GlyphOrder.setByGID(map, 0x0134, sdsnew("Jcircumflex")); + GlyphOrder.setByGID(map, 0x004B, sdsnew("K")); + GlyphOrder.setByGID(map, 0x039A, sdsnew("Kappa")); + GlyphOrder.setByGID(map, 0x004C, sdsnew("L")); + GlyphOrder.setByGID(map, 0x0139, sdsnew("Lacute")); + GlyphOrder.setByGID(map, 0x039B, sdsnew("Lambda")); + GlyphOrder.setByGID(map, 0x013D, sdsnew("Lcaron")); + GlyphOrder.setByGID(map, 0x013F, sdsnew("Ldot")); + GlyphOrder.setByGID(map, 0x0141, sdsnew("Lslash")); + GlyphOrder.setByGID(map, 0x004D, sdsnew("M")); + GlyphOrder.setByGID(map, 0x039C, sdsnew("Mu")); + GlyphOrder.setByGID(map, 0x004E, sdsnew("N")); + GlyphOrder.setByGID(map, 0x0143, sdsnew("Nacute")); + GlyphOrder.setByGID(map, 0x0147, sdsnew("Ncaron")); + GlyphOrder.setByGID(map, 0x00D1, sdsnew("Ntilde")); + GlyphOrder.setByGID(map, 0x039D, sdsnew("Nu")); + GlyphOrder.setByGID(map, 0x004F, sdsnew("O")); + GlyphOrder.setByGID(map, 0x0152, sdsnew("OE")); + GlyphOrder.setByGID(map, 0x00D3, sdsnew("Oacute")); + GlyphOrder.setByGID(map, 0x014E, sdsnew("Obreve")); + GlyphOrder.setByGID(map, 0x00D4, sdsnew("Ocircumflex")); + GlyphOrder.setByGID(map, 0x00D6, sdsnew("Odieresis")); + GlyphOrder.setByGID(map, 0x00D2, sdsnew("Ograve")); + GlyphOrder.setByGID(map, 0x01A0, sdsnew("Ohorn")); + GlyphOrder.setByGID(map, 0x0150, sdsnew("Ohungarumlaut")); + GlyphOrder.setByGID(map, 0x014C, sdsnew("Omacron")); + GlyphOrder.setByGID(map, 0x2126, sdsnew("Omega")); + GlyphOrder.setByGID(map, 0x038F, sdsnew("Omegatonos")); + GlyphOrder.setByGID(map, 0x039F, sdsnew("Omicron")); + GlyphOrder.setByGID(map, 0x038C, sdsnew("Omicrontonos")); + GlyphOrder.setByGID(map, 0x00D8, sdsnew("Oslash")); + GlyphOrder.setByGID(map, 0x01FE, sdsnew("Oslashacute")); + GlyphOrder.setByGID(map, 0x00D5, sdsnew("Otilde")); + GlyphOrder.setByGID(map, 0x0050, sdsnew("P")); + GlyphOrder.setByGID(map, 0x03A6, sdsnew("Phi")); + GlyphOrder.setByGID(map, 0x03A0, sdsnew("Pi")); + GlyphOrder.setByGID(map, 0x03A8, sdsnew("Psi")); + GlyphOrder.setByGID(map, 0x0051, sdsnew("Q")); + GlyphOrder.setByGID(map, 0x0052, sdsnew("R")); + GlyphOrder.setByGID(map, 0x0154, sdsnew("Racute")); + GlyphOrder.setByGID(map, 0x0158, sdsnew("Rcaron")); + GlyphOrder.setByGID(map, 0x211C, sdsnew("Rfraktur")); + GlyphOrder.setByGID(map, 0x03A1, sdsnew("Rho")); + GlyphOrder.setByGID(map, 0x0053, sdsnew("S")); + GlyphOrder.setByGID(map, 0x250C, sdsnew("SF010000")); + GlyphOrder.setByGID(map, 0x2514, sdsnew("SF020000")); + GlyphOrder.setByGID(map, 0x2510, sdsnew("SF030000")); + GlyphOrder.setByGID(map, 0x2518, sdsnew("SF040000")); + GlyphOrder.setByGID(map, 0x253C, sdsnew("SF050000")); + GlyphOrder.setByGID(map, 0x252C, sdsnew("SF060000")); + GlyphOrder.setByGID(map, 0x2534, sdsnew("SF070000")); + GlyphOrder.setByGID(map, 0x251C, sdsnew("SF080000")); + GlyphOrder.setByGID(map, 0x2524, sdsnew("SF090000")); + GlyphOrder.setByGID(map, 0x2500, sdsnew("SF100000")); + GlyphOrder.setByGID(map, 0x2502, sdsnew("SF110000")); + GlyphOrder.setByGID(map, 0x2561, sdsnew("SF190000")); + GlyphOrder.setByGID(map, 0x2562, sdsnew("SF200000")); + GlyphOrder.setByGID(map, 0x2556, sdsnew("SF210000")); + GlyphOrder.setByGID(map, 0x2555, sdsnew("SF220000")); + GlyphOrder.setByGID(map, 0x2563, sdsnew("SF230000")); + GlyphOrder.setByGID(map, 0x2551, sdsnew("SF240000")); + GlyphOrder.setByGID(map, 0x2557, sdsnew("SF250000")); + GlyphOrder.setByGID(map, 0x255D, sdsnew("SF260000")); + GlyphOrder.setByGID(map, 0x255C, sdsnew("SF270000")); + GlyphOrder.setByGID(map, 0x255B, sdsnew("SF280000")); + GlyphOrder.setByGID(map, 0x255E, sdsnew("SF360000")); + GlyphOrder.setByGID(map, 0x255F, sdsnew("SF370000")); + GlyphOrder.setByGID(map, 0x255A, sdsnew("SF380000")); + GlyphOrder.setByGID(map, 0x2554, sdsnew("SF390000")); + GlyphOrder.setByGID(map, 0x2569, sdsnew("SF400000")); + GlyphOrder.setByGID(map, 0x2566, sdsnew("SF410000")); + GlyphOrder.setByGID(map, 0x2560, sdsnew("SF420000")); + GlyphOrder.setByGID(map, 0x2550, sdsnew("SF430000")); + GlyphOrder.setByGID(map, 0x256C, sdsnew("SF440000")); + GlyphOrder.setByGID(map, 0x2567, sdsnew("SF450000")); + GlyphOrder.setByGID(map, 0x2568, sdsnew("SF460000")); + GlyphOrder.setByGID(map, 0x2564, sdsnew("SF470000")); + GlyphOrder.setByGID(map, 0x2565, sdsnew("SF480000")); + GlyphOrder.setByGID(map, 0x2559, sdsnew("SF490000")); + GlyphOrder.setByGID(map, 0x2558, sdsnew("SF500000")); + GlyphOrder.setByGID(map, 0x2552, sdsnew("SF510000")); + GlyphOrder.setByGID(map, 0x2553, sdsnew("SF520000")); + GlyphOrder.setByGID(map, 0x256B, sdsnew("SF530000")); + GlyphOrder.setByGID(map, 0x256A, sdsnew("SF540000")); + GlyphOrder.setByGID(map, 0x015A, sdsnew("Sacute")); + GlyphOrder.setByGID(map, 0x0160, sdsnew("Scaron")); + GlyphOrder.setByGID(map, 0x015E, sdsnew("Scedilla")); + GlyphOrder.setByGID(map, 0x015C, sdsnew("Scircumflex")); + GlyphOrder.setByGID(map, 0x03A3, sdsnew("Sigma")); + GlyphOrder.setByGID(map, 0x0054, sdsnew("T")); + GlyphOrder.setByGID(map, 0x03A4, sdsnew("Tau")); + GlyphOrder.setByGID(map, 0x0166, sdsnew("Tbar")); + GlyphOrder.setByGID(map, 0x0164, sdsnew("Tcaron")); + GlyphOrder.setByGID(map, 0x0398, sdsnew("Theta")); + GlyphOrder.setByGID(map, 0x00DE, sdsnew("Thorn")); + GlyphOrder.setByGID(map, 0x0055, sdsnew("U")); + GlyphOrder.setByGID(map, 0x00DA, sdsnew("Uacute")); + GlyphOrder.setByGID(map, 0x016C, sdsnew("Ubreve")); + GlyphOrder.setByGID(map, 0x00DB, sdsnew("Ucircumflex")); + GlyphOrder.setByGID(map, 0x00DC, sdsnew("Udieresis")); + GlyphOrder.setByGID(map, 0x00D9, sdsnew("Ugrave")); + GlyphOrder.setByGID(map, 0x01AF, sdsnew("Uhorn")); + GlyphOrder.setByGID(map, 0x0170, sdsnew("Uhungarumlaut")); + GlyphOrder.setByGID(map, 0x016A, sdsnew("Umacron")); + GlyphOrder.setByGID(map, 0x0172, sdsnew("Uogonek")); + GlyphOrder.setByGID(map, 0x03A5, sdsnew("Upsilon")); + GlyphOrder.setByGID(map, 0x03D2, sdsnew("Upsilon1")); + GlyphOrder.setByGID(map, 0x03AB, sdsnew("Upsilondieresis")); + GlyphOrder.setByGID(map, 0x038E, sdsnew("Upsilontonos")); + GlyphOrder.setByGID(map, 0x016E, sdsnew("Uring")); + GlyphOrder.setByGID(map, 0x0168, sdsnew("Utilde")); + GlyphOrder.setByGID(map, 0x0056, sdsnew("V")); + GlyphOrder.setByGID(map, 0x0057, sdsnew("W")); + GlyphOrder.setByGID(map, 0x1E82, sdsnew("Wacute")); + GlyphOrder.setByGID(map, 0x0174, sdsnew("Wcircumflex")); + GlyphOrder.setByGID(map, 0x1E84, sdsnew("Wdieresis")); + GlyphOrder.setByGID(map, 0x1E80, sdsnew("Wgrave")); + GlyphOrder.setByGID(map, 0x0058, sdsnew("X")); + GlyphOrder.setByGID(map, 0x039E, sdsnew("Xi")); + GlyphOrder.setByGID(map, 0x0059, sdsnew("Y")); + GlyphOrder.setByGID(map, 0x00DD, sdsnew("Yacute")); + GlyphOrder.setByGID(map, 0x0176, sdsnew("Ycircumflex")); + GlyphOrder.setByGID(map, 0x0178, sdsnew("Ydieresis")); + GlyphOrder.setByGID(map, 0x1EF2, sdsnew("Ygrave")); + GlyphOrder.setByGID(map, 0x005A, sdsnew("Z")); + GlyphOrder.setByGID(map, 0x0179, sdsnew("Zacute")); + GlyphOrder.setByGID(map, 0x017D, sdsnew("Zcaron")); + GlyphOrder.setByGID(map, 0x017B, sdsnew("Zdotaccent")); + GlyphOrder.setByGID(map, 0x0396, sdsnew("Zeta")); + GlyphOrder.setByGID(map, 0x0061, sdsnew("a")); + GlyphOrder.setByGID(map, 0x00E1, sdsnew("aacute")); + GlyphOrder.setByGID(map, 0x0103, sdsnew("abreve")); + GlyphOrder.setByGID(map, 0x00E2, sdsnew("acircumflex")); + GlyphOrder.setByGID(map, 0x00B4, sdsnew("acute")); + GlyphOrder.setByGID(map, 0x0301, sdsnew("acutecomb")); + GlyphOrder.setByGID(map, 0x00E4, sdsnew("adieresis")); + GlyphOrder.setByGID(map, 0x00E6, sdsnew("ae")); + GlyphOrder.setByGID(map, 0x01FD, sdsnew("aeacute")); + GlyphOrder.setByGID(map, 0x00E0, sdsnew("agrave")); + GlyphOrder.setByGID(map, 0x2135, sdsnew("aleph")); + GlyphOrder.setByGID(map, 0x03B1, sdsnew("alpha")); + GlyphOrder.setByGID(map, 0x03AC, sdsnew("alphatonos")); + GlyphOrder.setByGID(map, 0x0101, sdsnew("amacron")); + GlyphOrder.setByGID(map, 0x0026, sdsnew("ampersand")); + GlyphOrder.setByGID(map, 0x2220, sdsnew("angle")); + GlyphOrder.setByGID(map, 0x2329, sdsnew("angleleft")); + GlyphOrder.setByGID(map, 0x232A, sdsnew("angleright")); + GlyphOrder.setByGID(map, 0x0387, sdsnew("anoteleia")); + GlyphOrder.setByGID(map, 0x0105, sdsnew("aogonek")); + GlyphOrder.setByGID(map, 0x2248, sdsnew("approxequal")); + GlyphOrder.setByGID(map, 0x00E5, sdsnew("aring")); + GlyphOrder.setByGID(map, 0x01FB, sdsnew("aringacute")); + GlyphOrder.setByGID(map, 0x2194, sdsnew("arrowboth")); + GlyphOrder.setByGID(map, 0x21D4, sdsnew("arrowdblboth")); + GlyphOrder.setByGID(map, 0x21D3, sdsnew("arrowdbldown")); + GlyphOrder.setByGID(map, 0x21D0, sdsnew("arrowdblleft")); + GlyphOrder.setByGID(map, 0x21D2, sdsnew("arrowdblright")); + GlyphOrder.setByGID(map, 0x21D1, sdsnew("arrowdblup")); + GlyphOrder.setByGID(map, 0x2193, sdsnew("arrowdown")); + GlyphOrder.setByGID(map, 0x2190, sdsnew("arrowleft")); + GlyphOrder.setByGID(map, 0x2192, sdsnew("arrowright")); + GlyphOrder.setByGID(map, 0x2191, sdsnew("arrowup")); + GlyphOrder.setByGID(map, 0x2195, sdsnew("arrowupdn")); + GlyphOrder.setByGID(map, 0x21A8, sdsnew("arrowupdnbse")); + GlyphOrder.setByGID(map, 0x005E, sdsnew("asciicircum")); + GlyphOrder.setByGID(map, 0x007E, sdsnew("asciitilde")); + GlyphOrder.setByGID(map, 0x002A, sdsnew("asterisk")); + GlyphOrder.setByGID(map, 0x2217, sdsnew("asteriskmath")); + GlyphOrder.setByGID(map, 0x0040, sdsnew("at")); + GlyphOrder.setByGID(map, 0x00E3, sdsnew("atilde")); + GlyphOrder.setByGID(map, 0x0062, sdsnew("b")); + GlyphOrder.setByGID(map, 0x005C, sdsnew("backslash")); + GlyphOrder.setByGID(map, 0x007C, sdsnew("bar")); + GlyphOrder.setByGID(map, 0x03B2, sdsnew("beta")); + GlyphOrder.setByGID(map, 0x2588, sdsnew("block")); + GlyphOrder.setByGID(map, 0x007B, sdsnew("braceleft")); + GlyphOrder.setByGID(map, 0x007D, sdsnew("braceright")); + GlyphOrder.setByGID(map, 0x005B, sdsnew("bracketleft")); + GlyphOrder.setByGID(map, 0x005D, sdsnew("bracketright")); + GlyphOrder.setByGID(map, 0x02D8, sdsnew("breve")); + GlyphOrder.setByGID(map, 0x00A6, sdsnew("brokenbar")); + GlyphOrder.setByGID(map, 0x2022, sdsnew("bullet")); + GlyphOrder.setByGID(map, 0x0063, sdsnew("c")); + GlyphOrder.setByGID(map, 0x0107, sdsnew("cacute")); + GlyphOrder.setByGID(map, 0x02C7, sdsnew("caron")); + GlyphOrder.setByGID(map, 0x21B5, sdsnew("carriagereturn")); + GlyphOrder.setByGID(map, 0x010D, sdsnew("ccaron")); + GlyphOrder.setByGID(map, 0x00E7, sdsnew("ccedilla")); + GlyphOrder.setByGID(map, 0x0109, sdsnew("ccircumflex")); + GlyphOrder.setByGID(map, 0x010B, sdsnew("cdotaccent")); + GlyphOrder.setByGID(map, 0x00B8, sdsnew("cedilla")); + GlyphOrder.setByGID(map, 0x00A2, sdsnew("cent")); + GlyphOrder.setByGID(map, 0x03C7, sdsnew("chi")); + GlyphOrder.setByGID(map, 0x25CB, sdsnew("circle")); + GlyphOrder.setByGID(map, 0x2297, sdsnew("circlemultiply")); + GlyphOrder.setByGID(map, 0x2295, sdsnew("circleplus")); + GlyphOrder.setByGID(map, 0x02C6, sdsnew("circumflex")); + GlyphOrder.setByGID(map, 0x2663, sdsnew("club")); + GlyphOrder.setByGID(map, 0x003A, sdsnew("colon")); + GlyphOrder.setByGID(map, 0x20A1, sdsnew("colonmonetary")); + GlyphOrder.setByGID(map, 0x002C, sdsnew("comma")); + GlyphOrder.setByGID(map, 0x2245, sdsnew("congruent")); + GlyphOrder.setByGID(map, 0x00A9, sdsnew("copyright")); + GlyphOrder.setByGID(map, 0x00A4, sdsnew("currency")); + GlyphOrder.setByGID(map, 0x0064, sdsnew("d")); + GlyphOrder.setByGID(map, 0x2020, sdsnew("dagger")); + GlyphOrder.setByGID(map, 0x2021, sdsnew("daggerdbl")); + GlyphOrder.setByGID(map, 0x010F, sdsnew("dcaron")); + GlyphOrder.setByGID(map, 0x0111, sdsnew("dcroat")); + GlyphOrder.setByGID(map, 0x00B0, sdsnew("degree")); + GlyphOrder.setByGID(map, 0x03B4, sdsnew("delta")); + GlyphOrder.setByGID(map, 0x2666, sdsnew("diamond")); + GlyphOrder.setByGID(map, 0x00A8, sdsnew("dieresis")); + GlyphOrder.setByGID(map, 0x0385, sdsnew("dieresistonos")); + GlyphOrder.setByGID(map, 0x00F7, sdsnew("divide")); + GlyphOrder.setByGID(map, 0x2593, sdsnew("dkshade")); + GlyphOrder.setByGID(map, 0x2584, sdsnew("dnblock")); + GlyphOrder.setByGID(map, 0x0024, sdsnew("dollar")); + GlyphOrder.setByGID(map, 0x20AB, sdsnew("dong")); + GlyphOrder.setByGID(map, 0x02D9, sdsnew("dotaccent")); + GlyphOrder.setByGID(map, 0x0323, sdsnew("dotbelowcomb")); + GlyphOrder.setByGID(map, 0x0131, sdsnew("dotlessi")); + GlyphOrder.setByGID(map, 0x22C5, sdsnew("dotmath")); + GlyphOrder.setByGID(map, 0x0065, sdsnew("e")); + GlyphOrder.setByGID(map, 0x00E9, sdsnew("eacute")); + GlyphOrder.setByGID(map, 0x0115, sdsnew("ebreve")); + GlyphOrder.setByGID(map, 0x011B, sdsnew("ecaron")); + GlyphOrder.setByGID(map, 0x00EA, sdsnew("ecircumflex")); + GlyphOrder.setByGID(map, 0x00EB, sdsnew("edieresis")); + GlyphOrder.setByGID(map, 0x0117, sdsnew("edotaccent")); + GlyphOrder.setByGID(map, 0x00E8, sdsnew("egrave")); + GlyphOrder.setByGID(map, 0x0038, sdsnew("eight")); + GlyphOrder.setByGID(map, 0x2208, sdsnew("element")); + GlyphOrder.setByGID(map, 0x2026, sdsnew("ellipsis")); + GlyphOrder.setByGID(map, 0x0113, sdsnew("emacron")); + GlyphOrder.setByGID(map, 0x2014, sdsnew("emdash")); + GlyphOrder.setByGID(map, 0x2205, sdsnew("emptyset")); + GlyphOrder.setByGID(map, 0x2013, sdsnew("endash")); + GlyphOrder.setByGID(map, 0x014B, sdsnew("eng")); + GlyphOrder.setByGID(map, 0x0119, sdsnew("eogonek")); + GlyphOrder.setByGID(map, 0x03B5, sdsnew("epsilon")); + GlyphOrder.setByGID(map, 0x03AD, sdsnew("epsilontonos")); + GlyphOrder.setByGID(map, 0x003D, sdsnew("equal")); + GlyphOrder.setByGID(map, 0x2261, sdsnew("equivalence")); + GlyphOrder.setByGID(map, 0x212E, sdsnew("estimated")); + GlyphOrder.setByGID(map, 0x03B7, sdsnew("eta")); + GlyphOrder.setByGID(map, 0x03AE, sdsnew("etatonos")); + GlyphOrder.setByGID(map, 0x00F0, sdsnew("eth")); + GlyphOrder.setByGID(map, 0x0021, sdsnew("exclam")); + GlyphOrder.setByGID(map, 0x203C, sdsnew("exclamdbl")); + GlyphOrder.setByGID(map, 0x00A1, sdsnew("exclamdown")); + GlyphOrder.setByGID(map, 0x2203, sdsnew("existential")); + GlyphOrder.setByGID(map, 0x0066, sdsnew("f")); + GlyphOrder.setByGID(map, 0x2640, sdsnew("female")); + GlyphOrder.setByGID(map, 0x2012, sdsnew("figuredash")); + GlyphOrder.setByGID(map, 0x25A0, sdsnew("filledbox")); + GlyphOrder.setByGID(map, 0x25AC, sdsnew("filledrect")); + GlyphOrder.setByGID(map, 0x0035, sdsnew("five")); + GlyphOrder.setByGID(map, 0x215D, sdsnew("fiveeighths")); + GlyphOrder.setByGID(map, 0x0192, sdsnew("florin")); + GlyphOrder.setByGID(map, 0x0034, sdsnew("four")); + GlyphOrder.setByGID(map, 0x2044, sdsnew("fraction")); + GlyphOrder.setByGID(map, 0x20A3, sdsnew("franc")); + GlyphOrder.setByGID(map, 0x0067, sdsnew("g")); + GlyphOrder.setByGID(map, 0x03B3, sdsnew("gamma")); + GlyphOrder.setByGID(map, 0x011F, sdsnew("gbreve")); + GlyphOrder.setByGID(map, 0x01E7, sdsnew("gcaron")); + GlyphOrder.setByGID(map, 0x011D, sdsnew("gcircumflex")); + GlyphOrder.setByGID(map, 0x0121, sdsnew("gdotaccent")); + GlyphOrder.setByGID(map, 0x00DF, sdsnew("germandbls")); + GlyphOrder.setByGID(map, 0x2207, sdsnew("gradient")); + GlyphOrder.setByGID(map, 0x0060, sdsnew("grave")); + GlyphOrder.setByGID(map, 0x0300, sdsnew("gravecomb")); + GlyphOrder.setByGID(map, 0x003E, sdsnew("greater")); + GlyphOrder.setByGID(map, 0x2265, sdsnew("greaterequal")); + GlyphOrder.setByGID(map, 0x00AB, sdsnew("guillemotleft")); + GlyphOrder.setByGID(map, 0x00BB, sdsnew("guillemotright")); + GlyphOrder.setByGID(map, 0x2039, sdsnew("guilsinglleft")); + GlyphOrder.setByGID(map, 0x203A, sdsnew("guilsinglright")); + GlyphOrder.setByGID(map, 0x0068, sdsnew("h")); + GlyphOrder.setByGID(map, 0x0127, sdsnew("hbar")); + GlyphOrder.setByGID(map, 0x0125, sdsnew("hcircumflex")); + GlyphOrder.setByGID(map, 0x2665, sdsnew("heart")); + GlyphOrder.setByGID(map, 0x0309, sdsnew("hookabovecomb")); + GlyphOrder.setByGID(map, 0x2302, sdsnew("house")); + GlyphOrder.setByGID(map, 0x02DD, sdsnew("hungarumlaut")); + GlyphOrder.setByGID(map, 0x002D, sdsnew("hyphen")); + GlyphOrder.setByGID(map, 0x0069, sdsnew("i")); + GlyphOrder.setByGID(map, 0x00ED, sdsnew("iacute")); + GlyphOrder.setByGID(map, 0x012D, sdsnew("ibreve")); + GlyphOrder.setByGID(map, 0x00EE, sdsnew("icircumflex")); + GlyphOrder.setByGID(map, 0x00EF, sdsnew("idieresis")); + GlyphOrder.setByGID(map, 0x00EC, sdsnew("igrave")); + GlyphOrder.setByGID(map, 0x0133, sdsnew("ij")); + GlyphOrder.setByGID(map, 0x012B, sdsnew("imacron")); + GlyphOrder.setByGID(map, 0x221E, sdsnew("infinity")); + GlyphOrder.setByGID(map, 0x222B, sdsnew("integral")); + GlyphOrder.setByGID(map, 0x2321, sdsnew("integralbt")); + GlyphOrder.setByGID(map, 0x2320, sdsnew("integraltp")); + GlyphOrder.setByGID(map, 0x2229, sdsnew("intersection")); + GlyphOrder.setByGID(map, 0x25D8, sdsnew("invbullet")); + GlyphOrder.setByGID(map, 0x25D9, sdsnew("invcircle")); + GlyphOrder.setByGID(map, 0x263B, sdsnew("invsmileface")); + GlyphOrder.setByGID(map, 0x012F, sdsnew("iogonek")); + GlyphOrder.setByGID(map, 0x03B9, sdsnew("iota")); + GlyphOrder.setByGID(map, 0x03CA, sdsnew("iotadieresis")); + GlyphOrder.setByGID(map, 0x0390, sdsnew("iotadieresistonos")); + GlyphOrder.setByGID(map, 0x03AF, sdsnew("iotatonos")); + GlyphOrder.setByGID(map, 0x0129, sdsnew("itilde")); + GlyphOrder.setByGID(map, 0x006A, sdsnew("j")); + GlyphOrder.setByGID(map, 0x0135, sdsnew("jcircumflex")); + GlyphOrder.setByGID(map, 0x006B, sdsnew("k")); + GlyphOrder.setByGID(map, 0x03BA, sdsnew("kappa")); + GlyphOrder.setByGID(map, 0x0138, sdsnew("kgreenlandic")); + GlyphOrder.setByGID(map, 0x006C, sdsnew("l")); + GlyphOrder.setByGID(map, 0x013A, sdsnew("lacute")); + GlyphOrder.setByGID(map, 0x03BB, sdsnew("lambda")); + GlyphOrder.setByGID(map, 0x013E, sdsnew("lcaron")); + GlyphOrder.setByGID(map, 0x0140, sdsnew("ldot")); + GlyphOrder.setByGID(map, 0x003C, sdsnew("less")); + GlyphOrder.setByGID(map, 0x2264, sdsnew("lessequal")); + GlyphOrder.setByGID(map, 0x258C, sdsnew("lfblock")); + GlyphOrder.setByGID(map, 0x20A4, sdsnew("lira")); + GlyphOrder.setByGID(map, 0x2227, sdsnew("logicaland")); + GlyphOrder.setByGID(map, 0x00AC, sdsnew("logicalnot")); + GlyphOrder.setByGID(map, 0x2228, sdsnew("logicalor")); + GlyphOrder.setByGID(map, 0x017F, sdsnew("longs")); + GlyphOrder.setByGID(map, 0x25CA, sdsnew("lozenge")); + GlyphOrder.setByGID(map, 0x0142, sdsnew("lslash")); + GlyphOrder.setByGID(map, 0x2591, sdsnew("ltshade")); + GlyphOrder.setByGID(map, 0x006D, sdsnew("m")); + GlyphOrder.setByGID(map, 0x00AF, sdsnew("macron")); + GlyphOrder.setByGID(map, 0x2642, sdsnew("male")); + GlyphOrder.setByGID(map, 0x2212, sdsnew("minus")); + GlyphOrder.setByGID(map, 0x2032, sdsnew("minute")); + GlyphOrder.setByGID(map, 0x00B5, sdsnew("mu")); + GlyphOrder.setByGID(map, 0x00D7, sdsnew("multiply")); + GlyphOrder.setByGID(map, 0x266A, sdsnew("musicalnote")); + GlyphOrder.setByGID(map, 0x266B, sdsnew("musicalnotedbl")); + GlyphOrder.setByGID(map, 0x006E, sdsnew("n")); + GlyphOrder.setByGID(map, 0x0144, sdsnew("nacute")); + GlyphOrder.setByGID(map, 0x0149, sdsnew("napostrophe")); + GlyphOrder.setByGID(map, 0x0148, sdsnew("ncaron")); + GlyphOrder.setByGID(map, 0x0039, sdsnew("nine")); + GlyphOrder.setByGID(map, 0x2209, sdsnew("notelement")); + GlyphOrder.setByGID(map, 0x2260, sdsnew("notequal")); + GlyphOrder.setByGID(map, 0x2284, sdsnew("notsubset")); + GlyphOrder.setByGID(map, 0x00F1, sdsnew("ntilde")); + GlyphOrder.setByGID(map, 0x03BD, sdsnew("nu")); + GlyphOrder.setByGID(map, 0x0023, sdsnew("numbersign")); + GlyphOrder.setByGID(map, 0x006F, sdsnew("o")); + GlyphOrder.setByGID(map, 0x00F3, sdsnew("oacute")); + GlyphOrder.setByGID(map, 0x014F, sdsnew("obreve")); + GlyphOrder.setByGID(map, 0x00F4, sdsnew("ocircumflex")); + GlyphOrder.setByGID(map, 0x00F6, sdsnew("odieresis")); + GlyphOrder.setByGID(map, 0x0153, sdsnew("oe")); + GlyphOrder.setByGID(map, 0x02DB, sdsnew("ogonek")); + GlyphOrder.setByGID(map, 0x00F2, sdsnew("ograve")); + GlyphOrder.setByGID(map, 0x01A1, sdsnew("ohorn")); + GlyphOrder.setByGID(map, 0x0151, sdsnew("ohungarumlaut")); + GlyphOrder.setByGID(map, 0x014D, sdsnew("omacron")); + GlyphOrder.setByGID(map, 0x03C9, sdsnew("omega")); + GlyphOrder.setByGID(map, 0x03D6, sdsnew("omega1")); + GlyphOrder.setByGID(map, 0x03CE, sdsnew("omegatonos")); + GlyphOrder.setByGID(map, 0x03BF, sdsnew("omicron")); + GlyphOrder.setByGID(map, 0x03CC, sdsnew("omicrontonos")); + GlyphOrder.setByGID(map, 0x0031, sdsnew("one")); + GlyphOrder.setByGID(map, 0x2024, sdsnew("onedotenleader")); + GlyphOrder.setByGID(map, 0x215B, sdsnew("oneeighth")); + GlyphOrder.setByGID(map, 0x00BD, sdsnew("onehalf")); + GlyphOrder.setByGID(map, 0x00BC, sdsnew("onequarter")); + GlyphOrder.setByGID(map, 0x2153, sdsnew("onethird")); + GlyphOrder.setByGID(map, 0x25E6, sdsnew("openbullet")); + GlyphOrder.setByGID(map, 0x00AA, sdsnew("ordfeminine")); + GlyphOrder.setByGID(map, 0x00BA, sdsnew("ordmasculine")); + GlyphOrder.setByGID(map, 0x221F, sdsnew("orthogonal")); + GlyphOrder.setByGID(map, 0x00F8, sdsnew("oslash")); + GlyphOrder.setByGID(map, 0x01FF, sdsnew("oslashacute")); + GlyphOrder.setByGID(map, 0x00F5, sdsnew("otilde")); + GlyphOrder.setByGID(map, 0x0070, sdsnew("p")); + GlyphOrder.setByGID(map, 0x00B6, sdsnew("paragraph")); + GlyphOrder.setByGID(map, 0x0028, sdsnew("parenleft")); + GlyphOrder.setByGID(map, 0x0029, sdsnew("parenright")); + GlyphOrder.setByGID(map, 0x2202, sdsnew("partialdiff")); + GlyphOrder.setByGID(map, 0x0025, sdsnew("percent")); + GlyphOrder.setByGID(map, 0x002E, sdsnew("period")); + GlyphOrder.setByGID(map, 0x00B7, sdsnew("periodcentered")); + GlyphOrder.setByGID(map, 0x22A5, sdsnew("perpendicular")); + GlyphOrder.setByGID(map, 0x2030, sdsnew("perthousand")); + GlyphOrder.setByGID(map, 0x20A7, sdsnew("peseta")); + GlyphOrder.setByGID(map, 0x03C6, sdsnew("phi")); + GlyphOrder.setByGID(map, 0x03D5, sdsnew("phi1")); + GlyphOrder.setByGID(map, 0x03C0, sdsnew("pi")); + GlyphOrder.setByGID(map, 0x002B, sdsnew("plus")); + GlyphOrder.setByGID(map, 0x00B1, sdsnew("plusminus")); + GlyphOrder.setByGID(map, 0x211E, sdsnew("prescription")); + GlyphOrder.setByGID(map, 0x220F, sdsnew("product")); + GlyphOrder.setByGID(map, 0x2282, sdsnew("propersubset")); + GlyphOrder.setByGID(map, 0x2283, sdsnew("propersuperset")); + GlyphOrder.setByGID(map, 0x221D, sdsnew("proportional")); + GlyphOrder.setByGID(map, 0x03C8, sdsnew("psi")); + GlyphOrder.setByGID(map, 0x0071, sdsnew("q")); + GlyphOrder.setByGID(map, 0x003F, sdsnew("question")); + GlyphOrder.setByGID(map, 0x00BF, sdsnew("questiondown")); + GlyphOrder.setByGID(map, 0x0022, sdsnew("quotedbl")); + GlyphOrder.setByGID(map, 0x201E, sdsnew("quotedblbase")); + GlyphOrder.setByGID(map, 0x201C, sdsnew("quotedblleft")); + GlyphOrder.setByGID(map, 0x201D, sdsnew("quotedblright")); + GlyphOrder.setByGID(map, 0x2018, sdsnew("quoteleft")); + GlyphOrder.setByGID(map, 0x201B, sdsnew("quotereversed")); + GlyphOrder.setByGID(map, 0x2019, sdsnew("quoteright")); + GlyphOrder.setByGID(map, 0x201A, sdsnew("quotesinglbase")); + GlyphOrder.setByGID(map, 0x0027, sdsnew("quotesingle")); + GlyphOrder.setByGID(map, 0x0072, sdsnew("r")); + GlyphOrder.setByGID(map, 0x0155, sdsnew("racute")); + GlyphOrder.setByGID(map, 0x221A, sdsnew("radical")); + GlyphOrder.setByGID(map, 0x0159, sdsnew("rcaron")); + GlyphOrder.setByGID(map, 0x2286, sdsnew("reflexsubset")); + GlyphOrder.setByGID(map, 0x2287, sdsnew("reflexsuperset")); + GlyphOrder.setByGID(map, 0x00AE, sdsnew("registered")); + GlyphOrder.setByGID(map, 0x2310, sdsnew("revlogicalnot")); + GlyphOrder.setByGID(map, 0x03C1, sdsnew("rho")); + GlyphOrder.setByGID(map, 0x02DA, sdsnew("ring")); + GlyphOrder.setByGID(map, 0x2590, sdsnew("rtblock")); + GlyphOrder.setByGID(map, 0x0073, sdsnew("s")); + GlyphOrder.setByGID(map, 0x015B, sdsnew("sacute")); + GlyphOrder.setByGID(map, 0x0161, sdsnew("scaron")); + GlyphOrder.setByGID(map, 0x015F, sdsnew("scedilla")); + GlyphOrder.setByGID(map, 0x015D, sdsnew("scircumflex")); + GlyphOrder.setByGID(map, 0x2033, sdsnew("second")); + GlyphOrder.setByGID(map, 0x00A7, sdsnew("section")); + GlyphOrder.setByGID(map, 0x003B, sdsnew("semicolon")); + GlyphOrder.setByGID(map, 0x0037, sdsnew("seven")); + GlyphOrder.setByGID(map, 0x215E, sdsnew("seveneighths")); + GlyphOrder.setByGID(map, 0x2592, sdsnew("shade")); + GlyphOrder.setByGID(map, 0x03C3, sdsnew("sigma")); + GlyphOrder.setByGID(map, 0x03C2, sdsnew("sigma1")); + GlyphOrder.setByGID(map, 0x223C, sdsnew("similar")); + GlyphOrder.setByGID(map, 0x0036, sdsnew("six")); + GlyphOrder.setByGID(map, 0x002F, sdsnew("slash")); + GlyphOrder.setByGID(map, 0x263A, sdsnew("smileface")); + GlyphOrder.setByGID(map, 0x0020, sdsnew("space")); + GlyphOrder.setByGID(map, 0x2660, sdsnew("spade")); + GlyphOrder.setByGID(map, 0x00A3, sdsnew("sterling")); + GlyphOrder.setByGID(map, 0x220B, sdsnew("suchthat")); + GlyphOrder.setByGID(map, 0x2211, sdsnew("summation")); + GlyphOrder.setByGID(map, 0x263C, sdsnew("sun")); + GlyphOrder.setByGID(map, 0x0074, sdsnew("t")); + GlyphOrder.setByGID(map, 0x03C4, sdsnew("tau")); + GlyphOrder.setByGID(map, 0x0167, sdsnew("tbar")); + GlyphOrder.setByGID(map, 0x0165, sdsnew("tcaron")); + GlyphOrder.setByGID(map, 0x2234, sdsnew("therefore")); + GlyphOrder.setByGID(map, 0x03B8, sdsnew("theta")); + GlyphOrder.setByGID(map, 0x03D1, sdsnew("theta1")); + GlyphOrder.setByGID(map, 0x00FE, sdsnew("thorn")); + GlyphOrder.setByGID(map, 0x0033, sdsnew("three")); + GlyphOrder.setByGID(map, 0x215C, sdsnew("threeeighths")); + GlyphOrder.setByGID(map, 0x00BE, sdsnew("threequarters")); + GlyphOrder.setByGID(map, 0x02DC, sdsnew("tilde")); + GlyphOrder.setByGID(map, 0x0303, sdsnew("tildecomb")); + GlyphOrder.setByGID(map, 0x0384, sdsnew("tonos")); + GlyphOrder.setByGID(map, 0x2122, sdsnew("trademark")); + GlyphOrder.setByGID(map, 0x25BC, sdsnew("triagdn")); + GlyphOrder.setByGID(map, 0x25C4, sdsnew("triaglf")); + GlyphOrder.setByGID(map, 0x25BA, sdsnew("triagrt")); + GlyphOrder.setByGID(map, 0x25B2, sdsnew("triagup")); + GlyphOrder.setByGID(map, 0x0032, sdsnew("two")); + GlyphOrder.setByGID(map, 0x2025, sdsnew("twodotenleader")); + GlyphOrder.setByGID(map, 0x2154, sdsnew("twothirds")); + GlyphOrder.setByGID(map, 0x0075, sdsnew("u")); + GlyphOrder.setByGID(map, 0x00FA, sdsnew("uacute")); + GlyphOrder.setByGID(map, 0x016D, sdsnew("ubreve")); + GlyphOrder.setByGID(map, 0x00FB, sdsnew("ucircumflex")); + GlyphOrder.setByGID(map, 0x00FC, sdsnew("udieresis")); + GlyphOrder.setByGID(map, 0x00F9, sdsnew("ugrave")); + GlyphOrder.setByGID(map, 0x01B0, sdsnew("uhorn")); + GlyphOrder.setByGID(map, 0x0171, sdsnew("uhungarumlaut")); + GlyphOrder.setByGID(map, 0x016B, sdsnew("umacron")); + GlyphOrder.setByGID(map, 0x005F, sdsnew("underscore")); + GlyphOrder.setByGID(map, 0x2017, sdsnew("underscoredbl")); + GlyphOrder.setByGID(map, 0x222A, sdsnew("union")); + GlyphOrder.setByGID(map, 0x2200, sdsnew("universal")); + GlyphOrder.setByGID(map, 0x0173, sdsnew("uogonek")); + GlyphOrder.setByGID(map, 0x2580, sdsnew("upblock")); + GlyphOrder.setByGID(map, 0x03C5, sdsnew("upsilon")); + GlyphOrder.setByGID(map, 0x03CB, sdsnew("upsilondieresis")); + GlyphOrder.setByGID(map, 0x03B0, sdsnew("upsilondieresistonos")); + GlyphOrder.setByGID(map, 0x03CD, sdsnew("upsilontonos")); + GlyphOrder.setByGID(map, 0x016F, sdsnew("uring")); + GlyphOrder.setByGID(map, 0x0169, sdsnew("utilde")); + GlyphOrder.setByGID(map, 0x0076, sdsnew("v")); + GlyphOrder.setByGID(map, 0x0077, sdsnew("w")); + GlyphOrder.setByGID(map, 0x1E83, sdsnew("wacute")); + GlyphOrder.setByGID(map, 0x0175, sdsnew("wcircumflex")); + GlyphOrder.setByGID(map, 0x1E85, sdsnew("wdieresis")); + GlyphOrder.setByGID(map, 0x2118, sdsnew("weierstrass")); + GlyphOrder.setByGID(map, 0x1E81, sdsnew("wgrave")); + GlyphOrder.setByGID(map, 0x0078, sdsnew("x")); + GlyphOrder.setByGID(map, 0x03BE, sdsnew("xi")); + GlyphOrder.setByGID(map, 0x0079, sdsnew("y")); + GlyphOrder.setByGID(map, 0x00FD, sdsnew("yacute")); + GlyphOrder.setByGID(map, 0x0177, sdsnew("ycircumflex")); + GlyphOrder.setByGID(map, 0x00FF, sdsnew("ydieresis")); + GlyphOrder.setByGID(map, 0x00A5, sdsnew("yen")); + GlyphOrder.setByGID(map, 0x1EF3, sdsnew("ygrave")); + GlyphOrder.setByGID(map, 0x007A, sdsnew("z")); + GlyphOrder.setByGID(map, 0x017A, sdsnew("zacute")); + GlyphOrder.setByGID(map, 0x017E, sdsnew("zcaron")); + GlyphOrder.setByGID(map, 0x017C, sdsnew("zdotaccent")); + GlyphOrder.setByGID(map, 0x0030, sdsnew("zero")); + GlyphOrder.setByGID(map, 0x03B6, sdsnew("zeta")); +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.h new file mode 100644 index 00000000000..98f854b6f49 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aglfn/aglfn.h @@ -0,0 +1,6 @@ +#ifndef CARYLL_SUPPORT_AGLFN_H +#define CARYLL_SUPPORT_AGLFN_H +#include "otfcc/glyph-order.h" + +void aglfn_setupNames(otfcc_GlyphOrder *map); +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aliases.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aliases.h new file mode 100644 index 00000000000..25cd8e5e672 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/aliases.h @@ -0,0 +1,60 @@ +#ifndef CARYLL_SUPPORT_ALIASES_H +#define CARYLL_SUPPORT_ALIASES_H + +#include <stdint.h> + +#define loggedStep(...) \ + for (bool ___loggedstep_v = (options->logger->startSDS(options->logger, \ + sdscatprintf(sdsempty(), __VA_ARGS__)), \ + true); \ + ___loggedstep_v; ___loggedstep_v = false, options->logger->finish(options->logger)) +#define logError(...) \ + options->logger->logSDS(options->logger, log_vl_critical, log_type_error, \ + sdscatprintf(sdsempty(), __VA_ARGS__)); +#define logWarning(...) \ + options->logger->logSDS(options->logger, log_vl_important, log_type_warning, \ + sdscatprintf(sdsempty(), __VA_ARGS__)); +#define logNotice(...) \ + options->logger->logSDS(options->logger, log_vl_notice, log_type_info, \ + sdscatprintf(sdsempty(), __VA_ARGS__)); +#define logProgress(...) \ + options->logger->logSDS(options->logger, log_vl_progress, log_type_progress, \ + sdscatprintf(sdsempty(), __VA_ARGS__)); + +#define FOR_TABLE_SILENT(name, table) \ + for (int __fortable_keep = 1, __fortable_count = 0, __notfound = 1; \ + __notfound && __fortable_keep && __fortable_count < packet.numTables; \ + __fortable_keep = !__fortable_keep, __fortable_count++) \ + for (otfcc_PacketPiece table = (packet.pieces)[__fortable_count]; __fortable_keep; \ + __fortable_keep = !__fortable_keep) \ + if (table.tag == (name)) \ + for (int __fortable_k2 = 1; __fortable_k2; __fortable_k2 = 0, __notfound = 0) + +#define FOR_TABLE(name, table) FOR_TABLE_SILENT(name, table) + +#define foreach_index(item, index, vector) \ + for (size_t index = 0, keep = 1; keep && index < (vector).length; keep = !keep, index++) \ + for (item = (vector).items + index; keep; keep = !keep) +#define foreach(item, vector) foreach_index(item, __caryll_index, vector) +#define foreach_hash(id, range) for (id = (range); id != NULL; id = id->hh.next) + +typedef uint8_t *font_file_pointer; + +// alias "package" otfcc_pHandle to Handle +#include "otfcc/handle.h" +#define Handle otfcc_iHandle +typedef otfcc_GlyphHandle glyph_handle; +typedef otfcc_FDHandle fd_handle; +typedef otfcc_LookupHandle lookup_handle; + +// alias "package" otfcc_pkgGlyphOrder to GlyphOrder +#include "otfcc/glyph-order.h" +#define GlyphOrder otfcc_pkgGlyphOrder + +#include "otfcc/table/otl/classdef.h" +#define ClassDef otl_iClassDef + +#include "otfcc/table/otl/coverage.h" +#define Coverage otl_iCoverage + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.c new file mode 100644 index 00000000000..b57a0e156cf --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.c @@ -0,0 +1,89 @@ +#include "base64.h" +#include "../otfcc-alloc.h" + +static const uint8_t base64_table[64] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +uint8_t *base64_encode(const uint8_t *src, size_t len, size_t *out_len) { + uint8_t *out, *pos; + const uint8_t *end, *in; + size_t olen; + + olen = (len + 3 - 1) / 3 * 4; /* 3-byte blocks to 4-byte */ + olen++; /* nul termination */ + out = __caryll_malloc(sizeof(uint8_t) * olen); + if (out == NULL) return NULL; + + end = src + len; + in = src; + pos = out; + while (end - in >= 3) { + *pos++ = base64_table[in[0] >> 2]; + *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)]; + *pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)]; + *pos++ = base64_table[in[2] & 0x3f]; + in += 3; + } + + if (end - in) { + *pos++ = base64_table[in[0] >> 2]; + if (end - in == 1) { + *pos++ = base64_table[(in[0] & 0x03) << 4]; + *pos++ = '='; + } else { + *pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)]; + *pos++ = base64_table[(in[1] & 0x0f) << 2]; + } + *pos++ = '='; + } + + *pos = '\0'; + if (out_len) *out_len = pos - out; + return out; +} + +uint8_t *base64_decode(const uint8_t *src, size_t len, size_t *out_len) { + uint8_t dtable[256], *out, *pos, in[4], block[4], tmp; + size_t i, count; + + memset(dtable, 0x80, 256); + for (i = 0; i < sizeof(base64_table); i++) + dtable[base64_table[i]] = i; + dtable['='] = 0; + + count = 0; + for (i = 0; i < len; i++) { + if (dtable[src[i]] != 0x80) count++; + } + + if (count % 4) return NULL; + + pos = out = __caryll_malloc(sizeof(uint8_t) * count); + if (out == NULL) return NULL; + + count = 0; + for (i = 0; i < len; i++) { + tmp = dtable[src[i]]; + if (tmp == 0x80) continue; + + in[count] = src[i]; + block[count] = tmp; + count++; + if (count == 4) { + *pos++ = (block[0] << 2) | (block[1] >> 4); + *pos++ = (block[1] << 4) | (block[2] >> 2); + *pos++ = (block[2] << 6) | block[3]; + count = 0; + } + } + + if (pos > out) { + if (in[2] == '=') + pos -= 2; + else if (in[3] == '=') + pos--; + } + + *out_len = pos - out; + return out; +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.h new file mode 100644 index 00000000000..36d4702dd90 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/base64/base64.h @@ -0,0 +1,10 @@ +#ifndef CARYLL_SUPPORT_BASE64_H +#define CARYLL_SUPPORT_BASE64_H + +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +uint8_t *base64_encode(const uint8_t *src, size_t len, size_t *out_len); +uint8_t *base64_decode(const uint8_t *src, size_t len, size_t *out_len); + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/bin-io.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/bin-io.h new file mode 100644 index 00000000000..2df14b4506b --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/bin-io.h @@ -0,0 +1,171 @@ +#ifndef CARYLL_SUPPORT_BIN_IO_H +#define CARYLL_SUPPORT_BIN_IO_H + +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +#ifndef INLINE +#ifdef _MSC_VER +#define INLINE __forceinline /* use __forceinline (VC++ specific) */ +#else +#define INLINE inline /* use standard inline */ +#endif +#endif + +static INLINE bool otfcc_check_endian(void) { + union { + uint8_t i1[2]; + uint16_t i2; + } check_union = {.i2 = 1}; // if you don't have a new VC, upgrade it + + return (check_union.i1[0] == 1); +} + +static INLINE uint16_t otfcc_endian_convert16(uint16_t i) { + if (otfcc_check_endian()) { + union { + uint8_t i1[2]; + uint16_t i2; + } src, des; + + src.i2 = i; + + des.i1[0] = src.i1[1]; + des.i1[1] = src.i1[0]; + + return des.i2; + } else { + return i; + } +} + +static INLINE uint32_t otfcc_endian_convert32(uint32_t i) { + if (otfcc_check_endian()) { + union { + uint8_t i1[4]; + uint32_t i4; + } src, des; + + src.i4 = i; + + des.i1[0] = src.i1[3]; + des.i1[1] = src.i1[2]; + des.i1[2] = src.i1[1]; + des.i1[3] = src.i1[0]; + + return des.i4; + } else { + return i; + } +} + +static INLINE uint64_t otfcc_endian_convert64(uint64_t i) { + if (otfcc_check_endian()) { + union { + uint8_t i1[8]; + uint64_t i8; + } src, des; + + src.i8 = i; + + des.i1[0] = src.i1[7]; + des.i1[1] = src.i1[6]; + des.i1[2] = src.i1[5]; + des.i1[3] = src.i1[4]; + des.i1[4] = src.i1[3]; + des.i1[5] = src.i1[2]; + des.i1[6] = src.i1[1]; + des.i1[7] = src.i1[0]; + + return des.i8; + } else { + return i; + } +} + +static INLINE uint16_t otfcc_get16u(FILE *file) { + uint16_t tmp; + size_t sizeRead = fread(&tmp, 2, 1, file); + if (!sizeRead) { + fprintf(stderr, "File corruption of terminated unexpectedly.\n"); + exit(EXIT_FAILURE); + } + return otfcc_endian_convert16(tmp); +} + +static INLINE uint32_t otfcc_get32u(FILE *file) { + uint32_t tmp; + size_t sizeRead = fread(&tmp, 4, 1, file); + if (!sizeRead) { + fprintf(stderr, "File corruption of terminated unexpectedly.\n"); + exit(EXIT_FAILURE); + } + return otfcc_endian_convert32(tmp); +} + +static INLINE uint64_t otfcc_get64u(FILE *file) { + uint64_t tmp; + size_t sizeRead = fread(&tmp, 8, 1, file); + if (!sizeRead) { + fprintf(stderr, "File corruption of terminated unexpectedly.\n"); + exit(EXIT_FAILURE); + } + return otfcc_endian_convert64(tmp); +} + +// data reader +static INLINE uint8_t read_8u(const uint8_t *src) { + return src[0]; +} +static INLINE uint16_t read_16u(const uint8_t *src) { + uint16_t b0 = ((uint16_t)src[0]) << 8; + uint16_t b1 = ((uint16_t)src[1]); + return (b0 | b1); +} +static INLINE uint32_t read_24u(const uint8_t *src) { + uint32_t b0 = ((uint32_t)src[0]) << 16; + uint32_t b1 = ((uint32_t)src[1]) << 8; + uint32_t b2 = ((uint32_t)src[2]); + return (b0 | b1 | b2); +} +static INLINE uint32_t read_32u(const uint8_t *src) { + uint32_t b0 = ((uint32_t)src[0]) << 24; + uint32_t b1 = ((uint32_t)src[1]) << 16; + uint32_t b2 = ((uint32_t)src[2]) << 8; + uint32_t b3 = ((uint32_t)src[3]); + return (b0 | b1 | b2 | b3); +} +static INLINE uint64_t read_64u(const uint8_t *src) { + uint64_t b0 = ((uint64_t)src[0]) << 56; + uint64_t b1 = ((uint64_t)src[1]) << 48; + uint64_t b2 = ((uint64_t)src[2]) << 40; + uint64_t b3 = ((uint64_t)src[3]) << 32; + uint64_t b4 = ((uint64_t)src[4]) << 24; + uint64_t b5 = ((uint64_t)src[5]) << 16; + uint64_t b6 = ((uint64_t)src[6]) << 8; + uint64_t b7 = ((uint64_t)src[7]); + return (b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7); +} +static INLINE int8_t read_8s(const uint8_t *src) { + return (int8_t)read_8u(src); +} +static INLINE int16_t read_16s(const uint8_t *src) { + return (int16_t)read_16u(src); +} +static INLINE int32_t read_32s(const uint8_t *src) { + return (int32_t)read_32u(src); +} +static INLINE int64_t read_64s(const uint8_t *src) { + return (int64_t)read_64u(src); +} + +static INLINE uint16_t be16(uint16_t x) { + return ((x & 0xff) << 8) | ((x & 0xFF00) >> 8); +} +static INLINE uint32_t be32(uint32_t x) { + return ((x & 0x000000ff) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) | + ((x & 0xFF000000) >> 24); +} + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/buffer/buffer.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/buffer/buffer.c new file mode 100644 index 00000000000..0fd855b1706 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/buffer/buffer.c @@ -0,0 +1,231 @@ +#include "caryll/buffer.h" +#include "support/otfcc-alloc.h" + +caryll_Buffer *bufnew() { + caryll_Buffer *buf; + NEW(buf); + buf->size = buf->free = 0; + return buf; +} +void buffree(caryll_Buffer *buf) { + if (!buf) return; + if (buf->data) FREE(buf->data); + FREE(buf); +} +size_t buflen(caryll_Buffer *buf) { + return buf->size; +} +size_t bufpos(caryll_Buffer *buf) { + return buf->cursor; +} +void bufseek(caryll_Buffer *buf, size_t pos) { + buf->cursor = pos; +} +void bufclear(caryll_Buffer *buf) { + buf->cursor = 0; + buf->free = buf->size + buf->free; + buf->size = 0; +} + +static void bufbeforewrite(caryll_Buffer *buf, size_t towrite) { + size_t currentSize = buf->size; + size_t allocated = buf->size + buf->free; + size_t required = buf->cursor + towrite; + if (required < currentSize) { + // Completely overlap. + return; + } else if (required <= allocated) { + // Within range without reallocation + buf->size = required; + buf->free = allocated - buf->size; + } else { + // Needs realloc + buf->size = required; + buf->free = required; // Double growth + if (buf->free > 0x1000000) { buf->free = 0x1000000; } + RESIZE(buf->data, buf->size + buf->free); + } +} +void bufwrite8(caryll_Buffer *buf, uint8_t byte) { + bufbeforewrite(buf, 1); + buf->data[buf->cursor++] = byte; +} +void bufwrite16l(caryll_Buffer *buf, uint16_t x) { + bufbeforewrite(buf, 2); + buf->data[buf->cursor++] = x & 0xFF; + buf->data[buf->cursor++] = (x >> 8) & 0xFF; +} +void bufwrite16b(caryll_Buffer *buf, uint16_t x) { + bufbeforewrite(buf, 2); + buf->data[buf->cursor++] = (x >> 8) & 0xFF; + buf->data[buf->cursor++] = x & 0xFF; +} +void bufwrite24l(caryll_Buffer *buf, uint32_t x) { + bufbeforewrite(buf, 3); + buf->data[buf->cursor++] = x & 0xFF; + buf->data[buf->cursor++] = (x >> 8) & 0xFF; + buf->data[buf->cursor++] = (x >> 16) & 0xFF; +} +void bufwrite24b(caryll_Buffer *buf, uint32_t x) { + bufbeforewrite(buf, 3); + buf->data[buf->cursor++] = (x >> 16) & 0xFF; + buf->data[buf->cursor++] = (x >> 8) & 0xFF; + buf->data[buf->cursor++] = x & 0xFF; +} +void bufwrite32l(caryll_Buffer *buf, uint32_t x) { + bufbeforewrite(buf, 4); + buf->data[buf->cursor++] = x & 0xFF; + buf->data[buf->cursor++] = (x >> 8) & 0xFF; + buf->data[buf->cursor++] = (x >> 16) & 0xFF; + buf->data[buf->cursor++] = (x >> 24) & 0xFF; +} +void bufwrite32b(caryll_Buffer *buf, uint32_t x) { + bufbeforewrite(buf, 4); + buf->data[buf->cursor++] = (x >> 24) & 0xFF; + buf->data[buf->cursor++] = (x >> 16) & 0xFF; + buf->data[buf->cursor++] = (x >> 8) & 0xFF; + buf->data[buf->cursor++] = x & 0xFF; +} +void bufwrite64l(caryll_Buffer *buf, uint64_t x) { + bufbeforewrite(buf, 8); + buf->data[buf->cursor++] = x & 0xFF; + buf->data[buf->cursor++] = (x >> 8) & 0xFF; + buf->data[buf->cursor++] = (x >> 16) & 0xFF; + buf->data[buf->cursor++] = (x >> 24) & 0xFF; + buf->data[buf->cursor++] = (x >> 32) & 0xFF; + buf->data[buf->cursor++] = (x >> 40) & 0xFF; + buf->data[buf->cursor++] = (x >> 48) & 0xFF; + buf->data[buf->cursor++] = (x >> 56) & 0xFF; +} +void bufwrite64b(caryll_Buffer *buf, uint64_t x) { + bufbeforewrite(buf, 8); + buf->data[buf->cursor++] = (x >> 56) & 0xFF; + buf->data[buf->cursor++] = (x >> 48) & 0xFF; + buf->data[buf->cursor++] = (x >> 40) & 0xFF; + buf->data[buf->cursor++] = (x >> 32) & 0xFF; + buf->data[buf->cursor++] = (x >> 24) & 0xFF; + buf->data[buf->cursor++] = (x >> 16) & 0xFF; + buf->data[buf->cursor++] = (x >> 8) & 0xFF; + buf->data[buf->cursor++] = x & 0xFF; +} + +caryll_Buffer *bufninit(uint32_t n, ...) { + caryll_Buffer *buf = bufnew(); + bufbeforewrite(buf, n); + va_list ap; + va_start(ap, n); + for (uint16_t j = 0; j < n; j++) { + bufwrite8(buf, (uint8_t)va_arg(ap, int)); + } + va_end(ap); + return buf; +} +void bufnwrite8(caryll_Buffer *buf, uint32_t n, ...) { + bufbeforewrite(buf, n); + va_list ap; + va_start(ap, n); + for (uint16_t j = 0; j < n; j++) { + bufwrite8(buf, (uint8_t)va_arg(ap, int)); + } + va_end(ap); +} + +void bufwrite_sds(caryll_Buffer *buf, sds str) { + if (!str) return; + size_t len = sdslen(str); + if (!len) return; + bufbeforewrite(buf, len); + memcpy(buf->data + buf->cursor, str, len); + buf->cursor += len; +} +void bufwrite_str(caryll_Buffer *buf, const char *str) { + if (!str) return; + size_t len = strlen(str); + if (!len) return; + bufbeforewrite(buf, len); + memcpy(buf->data + buf->cursor, str, len); + buf->cursor += len; +} +void bufwrite_bytes(caryll_Buffer *buf, size_t len, const uint8_t *str) { + if (!str) return; + if (!len) return; + bufbeforewrite(buf, len); + memcpy(buf->data + buf->cursor, str, len); + buf->cursor += len; +} +void bufwrite_buf(caryll_Buffer *buf, caryll_Buffer *that) { + if (!that || !that->data) return; + size_t len = buflen(that); + bufbeforewrite(buf, len); + memcpy(buf->data + buf->cursor, that->data, len); + buf->cursor += len; +} +void bufwrite_bufdel(caryll_Buffer *buf, caryll_Buffer *that) { + if (!that) return; + if (!that->data) { + buffree(that); + return; + } + size_t len = buflen(that); + bufbeforewrite(buf, len); + memcpy(buf->data + buf->cursor, that->data, len); + buffree(that); + buf->cursor += len; +} + +void buflongalign(caryll_Buffer *buf) { + size_t cp = buf->cursor; + bufseek(buf, buflen(buf)); + if (buflen(buf) % 4 == 1) { + bufwrite8(buf, 0); + bufwrite8(buf, 0); + bufwrite8(buf, 0); + } else if (buflen(buf) % 4 == 2) { + bufwrite8(buf, 0); + bufwrite8(buf, 0); + } else if (buflen(buf) % 4 == 3) { + bufwrite8(buf, 0); + } + bufseek(buf, cp); +} + +// bufpingpong16b writes a buffer and an offset towards it. +// [ ^ ] + ###### that +// ^cp ^offset +// | +// V +// [ @^ ###### ] , and the value of [@] equals to the former +// offset. +// ^cp ^offset +// Common in writing OpenType features. +void bufping16b(caryll_Buffer *buf, size_t *offset, size_t *cp) { + bufwrite16b(buf, *offset); + *cp = buf->cursor; + bufseek(buf, *offset); +} +void bufping16bd(caryll_Buffer *buf, size_t *offset, size_t *shift, size_t *cp) { + bufwrite16b(buf, *offset - *shift); + *cp = buf->cursor; + bufseek(buf, *offset); +} +void bufpong(caryll_Buffer *buf, size_t *offset, size_t *cp) { + *offset = buf->cursor; + bufseek(buf, *cp); +} +void bufpingpong16b(caryll_Buffer *buf, caryll_Buffer *that, size_t *offset, size_t *cp) { + bufwrite16b(buf, *offset); + *cp = buf->cursor; + bufseek(buf, *offset); + bufwrite_bufdel(buf, that); + *offset = buf->cursor; + bufseek(buf, *cp); +} + +void bufprint(caryll_Buffer *buf) { + for (size_t j = 0; j < buf->size; j++) { + if (j % 16) fprintf(stderr, " "); + fprintf(stderr, "%02X", buf->data[j]); + if (j % 16 == 15) fprintf(stderr, "\n"); + } + fprintf(stderr, "\n"); +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/element-impl.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/element-impl.h new file mode 100644 index 00000000000..b65a403fe5d --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/element-impl.h @@ -0,0 +1,275 @@ +#ifndef CARYLL_SUPPORT_ELEMENT_IMPL_H +#define CARYLL_SUPPORT_ELEMENT_IMPL_H + +#include "caryll/element.h" +#include "otfcc-alloc.h" + +#ifndef __CARYLL_INLINE__ +#ifdef _MSC_VER +#define __CARYLL_INLINE__ __forceinline /* use __forceinline (VC++ specific) */ +#else +#define __CARYLL_INLINE__ inline /* use standard inline */ +#endif +#endif + +#define __NARG__(...) __NARG_I_(__VA_ARGS__, __RSEQ_N()) +#define __NARG_I_(...) __ARG_N(__VA_ARGS__) +#define __ARG_N(_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, N, ...) \ + N +#define __RSEQ_N() \ + 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \ + 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, \ + 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 + +// general definition for any function name +#define __CARYLL_VFUNC__2(name, n) name##n +#define __CARYLL_VFUNC__1(name, n) __CARYLL_VFUNC__2(name, n) +#define __CARYLLVFUNC(func, ...) __CARYLL_VFUNC__1(func, __NARG__(__VA_ARGS__))(__VA_ARGS__) + +#define caryll_trivialInit(T) \ + static __CARYLL_INLINE__ void T##_init(MODIFY T *x) { \ + memset(x, 0, sizeof(T)); \ + } +#define caryll_nonTrivialInit(T, __fn_init) \ + static __CARYLL_INLINE__ void T##_init(MODIFY T *x) { \ + (__fn_init)(x); \ + } +#define caryll_trivialEmpty(T) \ + static __CARYLL_INLINE__ T T##_empty() { \ + T x; \ + T##_init(&x); \ + return x; \ + } +#define caryll_trivialCreate(T) \ + static __CARYLL_INLINE__ T *T##_create() { \ + T *x = (T *)malloc(sizeof(T)); \ + T##_init(x); \ + return x; \ + } +#define caryll_trivialCopy(T) \ + static __CARYLL_INLINE__ void T##_copy(MODIFY T *dst, const T *src) { \ + memcpy(dst, src, sizeof(T)); \ + } +#define caryll_nonTrivialCopy(T, __fn_copy) \ + static __CARYLL_INLINE__ void T##_copy(MODIFY T *dst, const T *src) { \ + (__fn_copy)(dst, src); \ + } +#define caryll_trivialMove(T) \ + static __CARYLL_INLINE__ void T##_move(MODIFY T *dst, T *src) { \ + memcpy(dst, src, sizeof(T)); \ + T##_init(src); \ + } +#define caryll_nonTrivialMove(T, __fn_move) \ + static __CARYLL_INLINE__ void T##_move(MODIFY T *dst, T *src) { \ + (__fn_move)(dst, src); \ + T##_init(src); \ + } +#define caryll_trivialDispose(T) \ + static __CARYLL_INLINE__ void T##_dispose(MODIFY T *x) { \ + /* trivial */ \ + } +#define caryll_nonTrivialDispose(T, __fn_dispose) \ + static __CARYLL_INLINE__ void T##_dispose(MODIFY T *x) { \ + (__fn_dispose)(x); \ + } +#define caryll_trivialFree(T) \ + static __CARYLL_INLINE__ void T##_free(MOVE T *x) { \ + if (!x) return; \ + T##_dispose(x); \ + __caryll_free(x); \ + } +#define caryll_trivialDup(T) \ + static __CARYLL_INLINE__ T T##_dup(const T src) { \ + T dst; \ + T##_copy(&dst, &src); \ + return dst; \ + } +#define caryll_trivialReplace(T) \ + static __CARYLL_INLINE__ void T##_replace(MODIFY T *dst, MOVE const T src) { \ + T##_dispose(dst); \ + memcpy(dst, &src, sizeof(T)); \ + } \ + static __CARYLL_INLINE__ void T##_copyReplace(MODIFY T *dst, const T src) { \ + T##_dispose(dst); \ + T##_copy(dst, &src); \ + } + +#define caryll_standardTypeFn1(T) \ + caryll_trivialInit(T); \ + caryll_trivialCopy(T); \ + caryll_trivialDispose(T); \ + caryll_trivialMove(T); \ + caryll_trivialReplace(T); +#define caryll_standardTypeFn2(T, __fn_dispose) \ + caryll_trivialInit(T); \ + caryll_trivialCopy(T); \ + caryll_nonTrivialDispose(T, __fn_dispose); \ + caryll_trivialMove(T); \ + caryll_trivialReplace(T); +#define caryll_standardTypeFn3(T, __fn_init, __fn_dispose) \ + caryll_nonTrivialInit(T, __fn_init); \ + caryll_trivialCopy(T); \ + caryll_nonTrivialDispose(T, __fn_dispose); \ + caryll_trivialMove(T); \ + caryll_trivialReplace(T); +#define caryll_standardTypeFn4(T, __fn_init, __fn_copy, __fn_dispose) \ + caryll_nonTrivialInit(T, __fn_init); \ + caryll_nonTrivialCopy(T, __fn_copy); \ + caryll_nonTrivialDispose(T, __fn_dispose); \ + caryll_trivialMove(T); \ + caryll_trivialReplace(T); +#define caryll_standardTypeFn5(T, __fn_init, __fn_copy, __fn_dispose, __fn_move) \ + caryll_nonTrivialInit(T, __fn_init); \ + caryll_nonTrivialCopy(T, __fn_copy); \ + caryll_nonTrivialDispose(T, __fn_dispose); \ + caryll_nonTrivialMove(T, __fn_move); \ + caryll_trivialReplace(T); + +#define caryll_standardTypeMethods(T) \ + .init = T##_init, .copy = T##_copy, .dispose = T##_dispose, .move = T##_move, \ + .replace = T##_replace, .copyReplace = T##_copyReplace +#define caryll_standardRefTypeMethods(T) \ + caryll_standardTypeMethods(T), .create = T##_create, .free = T##_free +#define caryll_standardValTypeMethods(T) \ + caryll_standardTypeMethods(T), .empty = T##_empty, .dup = T##_dup + +#define caryll_standardTypeFn(...) __CARYLLVFUNC(caryll_standardTypeFn, __VA_ARGS__) + +#ifdef __GNUC__ + +// GCC requires adding ## before __VA_ARGS__. +// Make it happy. + +#define caryll_standardRefTypeFn(T, ...) \ + caryll_standardTypeFn(T, ##__VA_ARGS__); \ + caryll_trivialCreate(T); \ + caryll_trivialFree(T); +#define caryll_standardValTypeFn(T, ...) \ + caryll_standardTypeFn(T, ##__VA_ARGS__); \ + caryll_trivialEmpty(T); \ + caryll_trivialDup(T); + +#define caryll_standardType(T, __name, ...) \ + caryll_standardTypeFn(T, ##__VA_ARGS__); \ + caryll_ElementInterfaceOf(T) __name = {caryll_standardTypeMethods(T)}; +#define caryll_standardRefType(T, __name, ...) \ + caryll_standardRefTypeFn(T, ##__VA_ARGS__); \ + caryll_ElementInterfaceOf(T) __name = {caryll_standardRefTypeMethods(T)}; +#define caryll_standardValType(T, __name, ...) \ + caryll_standardValTypeFn(T, ##__VA_ARGS__); \ + caryll_ElementInterfaceOf(T) __name = {caryll_standardValTypeMethods(T)}; + +#else + +#define caryll_standardRefTypeFn(T, ...) \ + caryll_standardTypeFn(T, __VA_ARGS__); \ + caryll_trivialCreate(T); \ + caryll_trivialFree(T); +#define caryll_standardValTypeFn(T, ...) \ + caryll_standardTypeFn(T, __VA_ARGS__); \ + caryll_trivialEmpty(T); \ + caryll_trivialDup(T); + +#define caryll_standardType(T, __name, ...) \ + caryll_standardTypeFn(T, __VA_ARGS__); \ + caryll_ElementInterfaceOf(T) __name = {caryll_standardTypeMethods(T)}; +#define caryll_standardRefType(T, __name, ...) \ + caryll_standardRefTypeFn(T, __VA_ARGS__); \ + caryll_ElementInterfaceOf(T) __name = {caryll_standardRefTypeMethods(T)}; +#define caryll_standardValType(T, __name, ...) \ + caryll_standardValTypeFn(T, __VA_ARGS__); \ + caryll_ElementInterfaceOf(T) __name = {caryll_standardValTypeMethods(T)}; + +#endif + +//// Traits + +// Show +#define caryll_ShowFns(T, _fn_Show) \ + static __CARYLL_INLINE__ void T##_show(const T a) { \ + return (_fn_Show)(a); \ + } +#define caryll_ShowAssigns(T) .show = T##_show + +// Ord +#define caryll_OrdFns(T, _fnCompare) \ + static __CARYLL_INLINE__ int T##_compare(const T a, const T b) { \ + return (_fnCompare)(a, b); \ + } \ + static __CARYLL_INLINE__ int T##_compareRef(const T *a, const T *b) { \ + return (_fnCompare)(*a, *b); \ + } +#define caryll_OrdEqFns(T, _fnCompare) \ + caryll_OrdFns(T, _fnCompare); \ + static __CARYLL_INLINE__ bool T##_equal(const T a, const T b) { \ + return !(_fnCompare)(a, b); \ + } +#define caryll_OrdEqAssigns(T) \ + .compare = T##_compare, .compareRef = T##_compareRef, .equal = T##_equal + +// Monoid +#define caryll_MonoidFns(T, _fn_neutral, _fn_inplacePlus) \ + static __CARYLL_INLINE__ T T##_neutral() { \ + return (_fn_neutral)(); \ + } \ + static __CARYLL_INLINE__ void T##_inplacePlus(MODIFY T *a, const T b) { \ + (_fn_inplacePlus)(a, b); \ + } \ + static __CARYLL_INLINE__ T T##_plus(const T a, const T b) { \ + T result = (_fn_neutral)(); \ + (_fn_inplacePlus)(&result, a); \ + (_fn_inplacePlus)(&result, b); \ + return result; \ + } +#define caryll_MonoidAssigns(T) \ + .neutral = T##_neutral, .inplacePlus = T##_inplacePlus, .plus = T##_plus + +// Group +#define caryll_GroupFns(T, _fn_inplaceNegate) \ + static __CARYLL_INLINE__ void T##_inplaceNegate(MODIFY T *a) { \ + (_fn_inplaceNegate)(a); \ + } \ + static __CARYLL_INLINE__ T T##_negate(const T a) { \ + T result; \ + T##_copy(&result, &a); \ + T##_inplaceNegate(&result); \ + return result; \ + } \ + static __CARYLL_INLINE__ void T##_inplaceMinus(MODIFY T *a, const T b) { \ + T tb = T##_negate(b); \ + (T##_inplacePlus)(a, tb); \ + T##_dispose(&tb); \ + } \ + static __CARYLL_INLINE__ T T##_minus(const T a, const T b) { \ + T result = (T##_neutral)(); \ + (T##_inplacePlus)(&result, a); \ + (T##_inplaceMinus)(&result, b); \ + return result; \ + } +#define caryll_GroupAssigns(T) \ + .inplaceNegate = T##_inplaceNegate, .negate = T##_negate, .inplaceMinus = T##_inplaceMinus, \ + .minus = T##_minus + +// Module +#define caryll_ModuleFns(T, TS, _fn_inplaceScale) \ + static __CARYLL_INLINE__ void T##_inplaceScale(MODIFY T *a, TS b) { \ + (_fn_inplaceScale)(a, b); \ + } \ + static __CARYLL_INLINE__ T T##_scale(const T a, TS b) { \ + T result; \ + T##_copy(&result, &a); \ + T##_inplaceScale(&result, b); \ + return result; \ + } \ + static __CARYLL_INLINE__ void T##_inplacePlusScale(MODIFY T *a, TS b, const T c) { \ + T x = T##_scale(c, b); \ + T##_inplacePlus(a, x); \ + T##_dispose(&x); \ + } +#define caryll_ModuleAssigns(T) \ + .inplaceScale = T##_inplaceScale, .scale = T##_scale, .inplacePlusScale = T##_inplacePlusScale + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/glyph-order.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/glyph-order.c new file mode 100644 index 00000000000..3a30c702806 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/glyph-order.c @@ -0,0 +1,117 @@ +#include "util.h" +#include "otfcc/glyph-order.h" + +static INLINE void initGlyphOrder(otfcc_GlyphOrder *go) { + go->byGID = NULL; + go->byName = NULL; +} +static INLINE void disposeGlyphOrder(otfcc_GlyphOrder *go) { + otfcc_GlyphOrderEntry *current, *temp; + HASH_ITER(hhID, go->byGID, current, temp) { + if (current->name) sdsfree(current->name); + HASH_DELETE(hhID, go->byGID, current); + HASH_DELETE(hhName, go->byName, current); + FREE(current); + } +} +caryll_standardRefTypeFn(otfcc_GlyphOrder, initGlyphOrder, disposeGlyphOrder); + +// Register a gid->name map +static sds otfcc_setGlyphOrderByGID(otfcc_GlyphOrder *go, glyphid_t gid, sds name) { + otfcc_GlyphOrderEntry *s = NULL; + HASH_FIND(hhID, go->byGID, &gid, sizeof(glyphid_t), s); + if (s) { + // gid is already in the order table. + // reject this naming suggestion. + sdsfree(name); + return s->name; + } else { + otfcc_GlyphOrderEntry *t = NULL; + HASH_FIND(hhName, go->byName, name, sdslen(name), t); + if (t) { + // The name is already in-use. + sdsfree(name); + name = sdscatprintf(sdsempty(), "$$gid%d", gid); + } + NEW(s); + s->gid = gid; + s->name = name; + HASH_ADD(hhID, go->byGID, gid, sizeof(glyphid_t), s); + HASH_ADD(hhName, go->byName, name[0], sdslen(s->name), s); + } + return name; +} + +// Register a name->gid map +static bool otfcc_setGlyphOrderByName(otfcc_GlyphOrder *go, sds name, glyphid_t gid) { + otfcc_GlyphOrderEntry *s = NULL; + HASH_FIND(hhName, go->byName, name, sdslen(name), s); + if (s) { + // name is already mapped to a glyph + // reject this naming suggestion + return false; + } else { + NEW(s); + s->gid = gid; + s->name = name; + HASH_ADD(hhID, go->byGID, gid, sizeof(glyphid_t), s); + HASH_ADD(hhName, go->byName, name[0], sdslen(s->name), s); + return true; + } +} + +static bool otfcc_gordNameAFieldShared(otfcc_GlyphOrder *go, glyphid_t gid, sds *field) { + otfcc_GlyphOrderEntry *t; + HASH_FIND(hhID, go->byGID, &gid, sizeof(glyphid_t), t); + if (t != NULL) { + *field = t->name; + return true; + } else { + *field = NULL; + return false; + } +} + +static bool otfcc_gordConsolidateHandle(otfcc_GlyphOrder *go, glyph_handle *h) { + if (h->state == HANDLE_STATE_CONSOLIDATED) { + otfcc_GlyphOrderEntry *t; + HASH_FIND(hhName, go->byName, h->name, sdslen(h->name), t); + if (t) { + Handle.consolidateTo(h, t->gid, t->name); + return true; + } + HASH_FIND(hhName, go->byGID, &(h->index), sizeof(glyphid_t), t); + if (t) { + Handle.consolidateTo(h, t->gid, t->name); + return true; + } + } else if (h->state == HANDLE_STATE_NAME) { + otfcc_GlyphOrderEntry *t; + HASH_FIND(hhName, go->byName, h->name, sdslen(h->name), t); + if (t) { + Handle.consolidateTo(h, t->gid, t->name); + return true; + } + } else if (h->state == HANDLE_STATE_INDEX) { + sds name = NULL; + otfcc_gordNameAFieldShared(go, h->index, &name); + if (name) { + Handle.consolidateTo(h, h->index, name); + return true; + } + } + return false; +} + +static bool gordLookupName(otfcc_GlyphOrder *go, sds name) { + otfcc_GlyphOrderEntry *t; + HASH_FIND(hhName, go->byName, name, sdslen(name), t); + if (t) return true; + return false; +} + +const struct otfcc_GlyphOrderPackage otfcc_pkgGlyphOrder = { + caryll_standardRefTypeMethods(otfcc_GlyphOrder), .setByGID = otfcc_setGlyphOrderByGID, + .setByName = otfcc_setGlyphOrderByName, .nameAField_Shared = otfcc_gordNameAFieldShared, + .consolidateHandle = otfcc_gordConsolidateHandle, .lookupName = gordLookupName, +}; diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/handle.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/handle.c new file mode 100644 index 00000000000..a6657ee4371 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/handle.c @@ -0,0 +1,63 @@ +#include "otfcc/handle.h" +#include "element-impl.h" +#include "support/otfcc-alloc.h" + +// default constructors +static INLINE void initHandle(otfcc_Handle *h) { + h->state = HANDLE_STATE_EMPTY; + h->index = 0; + h->name = NULL; +} +static INLINE void disposeHandle(struct otfcc_Handle *h) { + if (h->name) { + sdsfree(h->name); + h->name = NULL; + } + h->index = 0; + h->state = HANDLE_STATE_EMPTY; +} +static void copyHandle(otfcc_Handle *dst, const otfcc_Handle *src) { + dst->state = src->state; + dst->index = src->index; + if (src->name) { + dst->name = sdsdup(src->name); + } else { + dst->name = NULL; + } +} + +caryll_standardValTypeFn(otfcc_Handle, initHandle, copyHandle, disposeHandle); + +// custom constructors +static struct otfcc_Handle handle_fromIndex(glyphid_t id) { + struct otfcc_Handle h = {HANDLE_STATE_INDEX, id, NULL}; + return h; +} +static struct otfcc_Handle handle_fromName(MOVE sds s) { + struct otfcc_Handle h = {HANDLE_STATE_EMPTY, 0, NULL}; + if (s) { + h.state = HANDLE_STATE_NAME; + h.name = s; + } + return h; +} +static struct otfcc_Handle handle_fromConsolidated(glyphid_t id, sds s) { + struct otfcc_Handle h = {HANDLE_STATE_CONSOLIDATED, id, sdsdup(s)}; + return h; +} + +// consolidation +static void handle_consolidateTo(struct otfcc_Handle *h, glyphid_t id, sds name) { + otfcc_iHandle.dispose(h); + h->state = HANDLE_STATE_CONSOLIDATED; + h->index = id; + h->name = sdsdup(name); +} + +const struct otfcc_HandlePackage otfcc_iHandle = { + caryll_standardValTypeMethods(otfcc_Handle), // VT + .fromIndex = handle_fromIndex, // custom constructor, from index + .fromName = handle_fromName, // custom constructor, from name + .fromConsolidated = handle_fromConsolidated, // custom constructor, from consolidated + .consolidateTo = handle_consolidateTo, +}; diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-funcs.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-funcs.h new file mode 100644 index 00000000000..55e2d98ecd1 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-funcs.h @@ -0,0 +1,203 @@ +#ifndef CARYLL_SUPPORT_JSON_FUNCS_H +#define CARYLL_SUPPORT_JSON_FUNCS_H + +#include <stdint.h> +#include <math.h> + +#include "dep/json-builder.h" +#include "dep/json.h" +#include "dep/sds.h" + +#include "caryll/ownership.h" +#include "otfcc/primitives.h" +#include "otfcc/vf/vq.h" +#include "otfcc/table/fvar.h" + +#ifndef INLINE +#ifdef _MSC_VER +#define INLINE __forceinline /* use __forceinline (VC++ specific) */ +#else +#define INLINE inline /* use standard inline */ +#endif +#endif + +static INLINE json_value *preserialize(MOVE json_value *x); + +static INLINE json_value *json_obj_get(const json_value *obj, const char *key) { + if (!obj || obj->type != json_object) return NULL; + for (uint32_t _k = 0; _k < obj->u.object.length; _k++) { + char *ck = obj->u.object.values[_k].name; + if (strcmp(ck, key) == 0) return obj->u.object.values[_k].value; + } + return NULL; +} +static INLINE json_value *json_obj_get_type(const json_value *obj, const char *key, + const json_type type) { + json_value *v = json_obj_get(obj, key); + if (v && v->type == type) return v; + return NULL; +} +static INLINE sds json_obj_getsds(const json_value *obj, const char *key) { + json_value *v = json_obj_get_type(obj, key, json_string); + if (!v) + return NULL; + else + return sdsnewlen(v->u.string.ptr, v->u.string.length); +} +static INLINE char *json_obj_getstr_share(const json_value *obj, const char *key) { + json_value *v = json_obj_get_type(obj, key, json_string); + if (!v) + return NULL; + else + return v->u.string.ptr; +} + +static INLINE json_value *json_object_push_tag(json_value *a, uint32_t tag, json_value *b) { + char tags[4] = {(tag & 0xff000000) >> 24, (tag & 0xff0000) >> 16, (tag & 0xff00) >> 8, + (tag & 0xff)}; + return json_object_push_length(a, 4, tags, b); +} + +// Coordinates, VV and VQ +static INLINE double json_numof(const json_value *cv) { + if (cv && cv->type == json_integer) return cv->u.integer; + if (cv && cv->type == json_double) return cv->u.dbl; + return 0; +} +static INLINE json_value *json_new_position(pos_t z) { + if (round(z) == z) { + return json_integer_new(z); + } else { + return json_double_new(z); + } +} +json_value *json_new_VQRegion_Explicit(const vq_Region *rs, const table_fvar *fvar); +json_value *json_new_VQRegion(const vq_Region *rs, const table_fvar *fvar); +json_value *json_new_VQ(const VQ z, const table_fvar *fvar); +json_value *json_new_VV(const VV x, const table_fvar *fvar); +json_value *json_new_VVp(const VV *x, const table_fvar *fvar); +VQ json_vqOf(const json_value *cv, const table_fvar *fvar); + +static INLINE double json_obj_getnum(const json_value *obj, const char *key) { + if (!obj || obj->type != json_object) return 0.0; + for (uint32_t _k = 0; _k < obj->u.object.length; _k++) { + char *ck = obj->u.object.values[_k].name; + json_value *cv = obj->u.object.values[_k].value; + if (strcmp(ck, key) == 0) { + if (cv && cv->type == json_integer) return cv->u.integer; + if (cv && cv->type == json_double) return cv->u.dbl; + } + } + return 0.0; +} +static INLINE int32_t json_obj_getint(const json_value *obj, const char *key) { + if (!obj || obj->type != json_object) return 0; + for (uint32_t _k = 0; _k < obj->u.object.length; _k++) { + char *ck = obj->u.object.values[_k].name; + json_value *cv = obj->u.object.values[_k].value; + if (strcmp(ck, key) == 0) { + if (cv && cv->type == json_integer) return (int32_t)cv->u.integer; + if (cv && cv->type == json_double) return cv->u.dbl; + } + } + return 0; +} +static INLINE double json_obj_getnum_fallback(const json_value *obj, const char *key, + double fallback) { + if (!obj || obj->type != json_object) return fallback; + for (uint32_t _k = 0; _k < obj->u.object.length; _k++) { + char *ck = obj->u.object.values[_k].name; + json_value *cv = obj->u.object.values[_k].value; + if (strcmp(ck, key) == 0) { + if (cv && cv->type == json_integer) return cv->u.integer; + if (cv && cv->type == json_double) return cv->u.dbl; + } + } + return fallback; +} +static INLINE int32_t json_obj_getint_fallback(const json_value *obj, const char *key, + int32_t fallback) { + if (!obj || obj->type != json_object) return fallback; + for (uint32_t _k = 0; _k < obj->u.object.length; _k++) { + char *ck = obj->u.object.values[_k].name; + json_value *cv = obj->u.object.values[_k].value; + if (strcmp(ck, key) == 0) { + if (cv && cv->type == json_integer) return (int32_t)cv->u.integer; + if (cv && cv->type == json_double) return cv->u.dbl; + } + } + return fallback; +} +static INLINE bool json_boolof(const json_value *cv) { + if (cv && cv->type == json_boolean) return cv->u.boolean; + return false; +} +static INLINE bool json_obj_getbool(const json_value *obj, const char *key) { + if (!obj || obj->type != json_object) return false; + for (uint32_t _k = 0; _k < obj->u.object.length; _k++) { + char *ck = obj->u.object.values[_k].name; + json_value *cv = obj->u.object.values[_k].value; + if (strcmp(ck, key) == 0) { + if (cv && cv->type == json_boolean) return cv->u.boolean; + } + } + return false; +} +static INLINE bool json_obj_getbool_fallback(const json_value *obj, const char *key, + bool fallback) { + if (!obj || obj->type != json_object) return fallback; + for (uint32_t _k = 0; _k < obj->u.object.length; _k++) { + char *ck = obj->u.object.values[_k].name; + json_value *cv = obj->u.object.values[_k].value; + if (strcmp(ck, key) == 0) { + if (cv && cv->type == json_boolean) return cv->u.boolean; + } + } + return fallback; +} + +static INLINE json_value *json_from_sds(const sds str) { + return json_string_new_length((uint32_t)sdslen(str), str); +} + +// flags reader and writer +static INLINE json_value *otfcc_dump_flags(int flags, const char *labels[]) { + json_value *v = json_object_new(0); + for (uint16_t j = 0; labels[j]; j++) + if (flags & (1 << j)) { json_object_push(v, labels[j], json_boolean_new(true)); } + return v; +} +static INLINE uint32_t otfcc_parse_flags(const json_value *v, const char *labels[]) { + if (!v) return 0; + if (v->type == json_integer) { + return (uint32_t)v->u.integer; + } else if (v->type == json_double) { + return (uint32_t)v->u.dbl; + } else if (v->type == json_object) { + uint32_t flags = 0; + for (uint16_t j = 0; labels[j]; j++) { + if (json_obj_getbool(v, labels[j])) { flags |= (1 << j); } + } + return flags; + } else { + return 0; + } +} + +static INLINE json_value *preserialize(MOVE json_value *x) { +#ifdef CARYLL_USE_PRE_SERIALIZED + json_serialize_opts opts = {.mode = json_serialize_mode_packed}; + size_t preserialize_len = json_measure_ex(x, opts); + char *buf = (char *)malloc(preserialize_len); + json_serialize_ex(buf, x, opts); + json_builder_free(x); + + json_value *xx = json_string_new_nocopy((uint32_t)(preserialize_len - 1), buf); + xx->type = json_pre_serialized; + return xx; +#else + return x; +#endif +} + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.c new file mode 100644 index 00000000000..9969e2a57c2 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.c @@ -0,0 +1,86 @@ +#include "json-ident.h" +#include "support/otfcc-alloc.h" + +#ifdef _MSC_VER +#include "winfns.h" +#endif + +static bool compare_json_arrays(const json_value *a, const json_value *b) { + for (uint16_t j = 0; j < a->u.array.length; j++) { + if (!json_ident(a->u.array.values[j], b->u.array.values[j])) { return false; } + } + return true; +} + +typedef struct { + char *key; + json_value *val; + bool check; + UT_hash_handle hh; +} json_obj_entry; +static bool compare_json_objects(const json_value *a, const json_value *b) { + json_obj_entry *h = NULL; + for (uint32_t j = 0; j < a->u.object.length; j++) { + char *k = a->u.object.values[j].name; + json_obj_entry *e = NULL; + HASH_FIND_STR(h, k, e); + if (!e) { + NEW(e); + e->key = strdup(k); + e->val = a->u.object.values[j].value; + e->check = false; + HASH_ADD_STR(h, key, e); + } + } + bool allcheck = true; + for (uint32_t j = 0; j < b->u.object.length; j++) { + char *k = b->u.object.values[j].name; + json_obj_entry *e = NULL; + HASH_FIND_STR(h, k, e); + if (!e) { + allcheck = false; + break; + } else { + bool check = json_ident(e->val, b->u.object.values[j].value); + if (!check) { + allcheck = false; + break; + } else { + e->check = true; + } + } + } + json_obj_entry *e, *tmp; + HASH_ITER(hh, h, e, tmp) { + allcheck = allcheck && e->check; + HASH_DEL(h, e); + FREE(e->key); + FREE(e); + } + return allcheck; +} + +bool json_ident(const json_value *a, const json_value *b) { + if (!a && !b) return true; + if (!a || !b) return false; + if (a->type != b->type) return false; + switch (a->type) { + case json_none: + case json_null: + return true; + case json_integer: + return a->u.integer == b->u.integer; + case json_double: + return a->u.dbl == b->u.dbl; + case json_boolean: + return a->u.boolean == b->u.boolean; + case json_string: + return a->u.string.length == b->u.string.length && strcmp(a->u.string.ptr, b->u.string.ptr) == 0; + case json_array: + return a->u.array.length == b->u.array.length && compare_json_arrays(a, b); + case json_object: + return a->u.object.length == b->u.object.length && compare_json_objects(a, b); + default: + return false; + } +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.h new file mode 100644 index 00000000000..c48fd1b6421 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/json/json-ident.h @@ -0,0 +1,12 @@ +#ifndef CARYLL_SUPPORT_JSON_IDENT_H +#define CARYLL_SUPPORT_JSON_IDENT_H + +#include "dep/json.h" +#include "dep/uthash.h" +#include <inttypes.h> +#include <stdbool.h> +#include <stdint.h> + +bool json_ident(const json_value *a, const json_value *b); + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/options.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/options.c new file mode 100644 index 00000000000..d32e7c082b3 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/options.c @@ -0,0 +1,38 @@ +#include "otfcc/options.h" +#include "support/otfcc-alloc.h" + +otfcc_Options *otfcc_newOptions() { + otfcc_Options *options; + NEW(options); + return options; +} +void otfcc_deleteOptions(otfcc_Options *options) { + if (options) { + FREE(options->glyph_name_prefix); + if (options->logger) options->logger->dispose(options->logger); + } + FREE(options); +} +void otfcc_Options_optimizeTo(otfcc_Options *options, uint8_t level) { + options->cff_rollCharString = false; + options->short_post = false; + options->ignore_glyph_order = false; + options->cff_short_vmtx = false; + options->merge_features = false; + options->force_cid = false; + options->cff_doSubroutinize = false; + + if (level >= 1) { + options->cff_rollCharString = true; + options->cff_short_vmtx = true; + } + if (level >= 2) { + options->short_post = true; + options->cff_doSubroutinize = true; + options->merge_features = true; + } + if (level >= 3) { + options->ignore_glyph_order = true; + options->force_cid = true; + } +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/otfcc-alloc.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/otfcc-alloc.h new file mode 100644 index 00000000000..51b57442f5f --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/otfcc-alloc.h @@ -0,0 +1,83 @@ +#ifndef CARYLL_SUPPORT_OTFCC_ALLOC_H +#define CARYLL_SUPPORT_OTFCC_ALLOC_H + +#include <stdio.h> +#include <stdlib.h> + +#ifndef INLINE +#ifdef _MSC_VER +#define INLINE __forceinline /* use __forceinline (VC++ specific) */ +#else +#define INLINE inline /* use standard inline */ +#endif +#endif + +// Allocators +// Change this if you prefer other allocators +#define __caryll_malloc malloc +#define __caryll_calloc calloc +#define __caryll_realloc realloc +#define __caryll_free free + +static INLINE void *__caryll_allocate_dirty(size_t n, unsigned long line) { + if (!n) return NULL; + void *p = __caryll_malloc(n); + if (!p) { + fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n); + exit(EXIT_FAILURE); + } + return p; +} +static INLINE void *__caryll_allocate_clean(size_t n, unsigned long line) { + if (!n) return NULL; + void *p = __caryll_calloc(n, 1); + if (!p) { + fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n); + exit(EXIT_FAILURE); + } + return p; +} +static INLINE void *__caryll_reallocate(void *ptr, size_t n, unsigned long line) { + if (!n) { + __caryll_free(ptr); + return NULL; + } + if (!ptr) { + return __caryll_allocate_clean(n, line); + } else { + void *p = __caryll_realloc(ptr, n); + if (!p) { + fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n); + exit(EXIT_FAILURE); + } + return p; + } +} +#ifdef __cplusplus +#define NEW_CLEAN_S(ptr, size) ptr = __caryll_allocate_clean((size), __LINE__) +#define NEW_CLEAN_1(ptr) \ + ptr = (decltype(ptr))__caryll_allocate_clean(sizeof(decltype(*ptr)), __LINE__) +#define NEW_CLEAN_N(ptr, n) \ + ptr = (decltype(ptr))__caryll_allocate_clean(sizeof(decltype(*ptr)) * (n), __LINE__) +#define NEW_DIRTY(ptr) \ + ptr = (decltype(ptr))__caryll_allocate_dirty(sizeof(decltype(*ptr)), __LINE__) +#define NEW_DIRTY_N(ptr, n) \ + ptr = (decltype(ptr))__caryll_allocate_dirty(sizeof(decltype(*ptr)) * (n), __LINE__) +#define FREE(ptr) (__caryll_free(ptr), ptr = nullptr) +#define DELETE(fn, ptr) (fn(ptr), ptr = nullptr) +#define RESIZE(ptr, n) ptr = (decltype(ptr))__caryll_reallocate(ptr, sizeof(*ptr) * (n), __LINE__) +#else +#define NEW_CLEAN_S(ptr, size) ptr = __caryll_allocate_clean((size), __LINE__) +#define NEW_CLEAN_1(ptr) ptr = __caryll_allocate_clean(sizeof(*ptr), __LINE__) +#define NEW_CLEAN_N(ptr, n) ptr = __caryll_allocate_clean(sizeof(*ptr) * (n), __LINE__) +#define NEW_DIRTY(ptr) ptr = __caryll_allocate_dirty(sizeof(*ptr), __LINE__) +#define NEW_DIRTY_N(ptr, n) ptr = __caryll_allocate_dirty(sizeof(*ptr) * (n), __LINE__) +#define FREE(ptr) (__caryll_free(ptr), ptr = NULL) +#define DELETE(fn, ptr) (fn(ptr), ptr = NULL) +#define RESIZE(ptr, n) ptr = __caryll_reallocate(ptr, sizeof(*ptr) * (n), __LINE__) +#endif + +#define __GET_MACRO_OTFCC_ALLOC_2(_1, _2, NAME, ...) NAME +#define NEW(...) __GET_MACRO_OTFCC_ALLOC_2(__VA_ARGS__, NEW_CLEAN_N, NEW_CLEAN_1)(__VA_ARGS__) + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/primitives.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/primitives.c new file mode 100644 index 00000000000..2f2ad360979 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/primitives.c @@ -0,0 +1,66 @@ +#include "otfcc/primitives.h" +#include "bin-io.h" +#include <math.h> + +// f2dot14 type +double otfcc_from_f2dot14(const f2dot14 x) { + return x / 16384.0; +} +int16_t otfcc_to_f2dot14(const double x) { + return round(x * 16384.0); +} + +// F16.16 (fixed) type +double otfcc_from_fixed(const f16dot16 x) { + return x / 65536.0; +} +f16dot16 otfcc_to_fixed(const double x) { + return round(x * 65536.0); +} + +// F16.16 arith +// Clamp: remove too-large values +static INLINE f16dot16 clamp(int64_t value) { + int64_t tmp = value; + if (tmp < (int64_t)f16dot16_negativeIntinity) tmp = (int64_t)f16dot16_negativeIntinity; + if (tmp > (int64_t)f16dot16_infinity) tmp = (int64_t)f16dot16_infinity; + return (f16dot16)tmp; +} + +f16dot16 otfcc_f1616_add(f16dot16 a, f16dot16 b) { + return a + b; +} +f16dot16 otfcc_f1616_minus(f16dot16 a, f16dot16 b) { + return a - b; +} + +f16dot16 otfcc_f1616_multiply(f16dot16 a, f16dot16 b) { + int64_t tmp = (int64_t)a * (int64_t)b + f16dot16_k; + f16dot16 product = clamp(tmp >> f16dot16_precision); + return product; +} + +static INLINE f16dot16 divide(int64_t a, int32_t b) { + if (b == 0) { + if (a < 0) + return f16dot16_negativeIntinity; + else + return f16dot16_infinity; + } + + if ((a < 0 != b < 0)) { + a -= b / 2; + } else { + a += b / 2; + } + + return (f16dot16)(clamp(a / b)); +} + +f16dot16 otfcc_f1616_muldiv(f16dot16 a, f16dot16 b, f16dot16 c) { + int64_t tmp = (int64_t)a * (int64_t)b + f16dot16_k; + return divide(tmp, c); +} +f16dot16 otfcc_f1616_divide(f16dot16 a, f16dot16 b) { + return divide((int64_t)a << f16dot16_precision, b); +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.c new file mode 100644 index 00000000000..9efa794e73a --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.c @@ -0,0 +1,144 @@ +/********************************************************************* +* Filename: sha1.c +* Author: Brad Conte (brad AT bradconte.com) +* Copyright: +* Disclaimer: This code is presented "as is" without any guarantees. +* Details: Implementation of the SHA1 hashing algorithm. + Algorithm specification can be found here: + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf + This implementation uses little endian byte order. +*********************************************************************/ + +/*************************** HEADER FILES ***************************/ +#include <stdlib.h> +#include <memory.h> +#include "sha1.h" + +/****************************** MACROS ******************************/ +#define ROTLEFT(a, b) ((a << b) | (a >> (32 - b))) + +/*********************** FUNCTION DEFINITIONS ***********************/ +static void sha1_transform(SHA1_CTX *ctx, const BYTE data[]) { + WORD a, b, c, d, e, i, j, t, m[80]; + + for (i = 0, j = 0; i < 16; ++i, j += 4) + m[i] = (data[j] << 24) + (data[j + 1] << 16) + (data[j + 2] << 8) + (data[j + 3]); + for (; i < 80; ++i) { + m[i] = (m[i - 3] ^ m[i - 8] ^ m[i - 14] ^ m[i - 16]); + m[i] = (m[i] << 1) | (m[i] >> 31); + } + + a = ctx->state[0]; + b = ctx->state[1]; + c = ctx->state[2]; + d = ctx->state[3]; + e = ctx->state[4]; + + for (i = 0; i < 20; ++i) { + t = ROTLEFT(a, 5) + ((b & c) ^ (~b & d)) + e + ctx->k[0] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + for (; i < 40; ++i) { + t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[1] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + for (; i < 60; ++i) { + t = ROTLEFT(a, 5) + ((b & c) ^ (b & d) ^ (c & d)) + e + ctx->k[2] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + for (; i < 80; ++i) { + t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[3] + m[i]; + e = d; + d = c; + c = ROTLEFT(b, 30); + b = a; + a = t; + } + + ctx->state[0] += a; + ctx->state[1] += b; + ctx->state[2] += c; + ctx->state[3] += d; + ctx->state[4] += e; +} + +void sha1_init(SHA1_CTX *ctx) { + ctx->datalen = 0; + ctx->bitlen = 0; + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; + ctx->state[4] = 0xc3d2e1f0; + ctx->k[0] = 0x5a827999; + ctx->k[1] = 0x6ed9eba1; + ctx->k[2] = 0x8f1bbcdc; + ctx->k[3] = 0xca62c1d6; +} + +void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len) { + size_t i; + + for (i = 0; i < len; ++i) { + ctx->data[ctx->datalen] = data[i]; + ctx->datalen++; + if (ctx->datalen == 64) { + sha1_transform(ctx, ctx->data); + ctx->bitlen += 512; + ctx->datalen = 0; + } + } +} + +void sha1_final(SHA1_CTX *ctx, BYTE hash[]) { + WORD i; + + i = ctx->datalen; + + // Pad whatever data is left in the buffer. + if (ctx->datalen < 56) { + ctx->data[i++] = 0x80; + while (i < 56) + ctx->data[i++] = 0x00; + } else { + ctx->data[i++] = 0x80; + while (i < 64) + ctx->data[i++] = 0x00; + sha1_transform(ctx, ctx->data); + memset(ctx->data, 0, 56); + } + + // Append to the padding the total message's length in bits and transform. + ctx->bitlen += ctx->datalen * 8; + ctx->data[63] = ctx->bitlen; + ctx->data[62] = ctx->bitlen >> 8; + ctx->data[61] = ctx->bitlen >> 16; + ctx->data[60] = ctx->bitlen >> 24; + ctx->data[59] = ctx->bitlen >> 32; + ctx->data[58] = ctx->bitlen >> 40; + ctx->data[57] = ctx->bitlen >> 48; + ctx->data[56] = ctx->bitlen >> 56; + sha1_transform(ctx, ctx->data); + + // Since this implementation uses little endian byte ordering and MD uses big endian, + // reverse all the bytes when copying the final state to the output hash. + for (i = 0; i < 4; ++i) { + hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff; + hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff; + hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff; + hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff; + hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff; + } +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.h new file mode 100644 index 00000000000..47db579d6d2 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/sha1/sha1.h @@ -0,0 +1,35 @@ +/********************************************************************* +* Filename: sha1.h +* Author: Brad Conte (brad AT bradconte.com) +* Copyright: +* Disclaimer: This code is presented "as is" without any guarantees. +* Details: Defines the API for the corresponding SHA1 implementation. +*********************************************************************/ + +#ifndef SHA1_H +#define SHA1_H + +/*************************** HEADER FILES ***************************/ +#include <stddef.h> + +/****************************** MACROS ******************************/ +#define SHA1_BLOCK_SIZE 20 // SHA1 outputs a 20 byte digest + +/**************************** DATA TYPES ****************************/ +typedef unsigned char BYTE; // 8-bit byte +typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines + +typedef struct { + BYTE data[64]; + WORD datalen; + unsigned long long bitlen; + WORD state[5]; + WORD k[4]; +} SHA1_CTX; + +/*********************** FUNCTION DECLARATIONS **********************/ +void sha1_init(SHA1_CTX *ctx); +void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len); +void sha1_final(SHA1_CTX *ctx, BYTE hash[]); + +#endif // SHA1_H diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/tag.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/tag.h new file mode 100644 index 00000000000..e2a339d3b61 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/tag.h @@ -0,0 +1,36 @@ +#ifndef CARYLL_SUPPORT_TAG_H +#define CARYLL_SUPPORT_TAG_H + +#include <stdint.h> +#include <stdlib.h> + +#ifndef INLINE +#ifdef _MSC_VER +#define INLINE __forceinline /* use __forceinline (VC++ specific) */ +#else +#define INLINE inline /* use standard inline */ +#endif +#endif + +// Tag handler +static INLINE void tag2str(uint32_t tag, char tags[4]) { + tags[0] = (tag >> 24) & 0xFF; + tags[1] = (tag >> 16) & 0xFF; + tags[2] = (tag >> 8) & 0xFF; + tags[3] = tag & 0xFF; +} + +static INLINE uint32_t str2tag(const char *tags) { + if (!tags) return 0; + uint32_t tag = 0; + uint8_t len = 0; + while (*tags && len < 4) { + tag = (tag << 8) | (*tags), tags++, len++; + } + while (len < 4) { + tag = (tag << 8) | ' ', len++; + } + return tag; +} + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.c new file mode 100644 index 00000000000..3fc3e043b56 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.c @@ -0,0 +1,701 @@ +/* Copyright (C) 2001-2012 by George Williams */ +/* Copyright (C) 2016 by Belleve Invis */ + +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ttinstr.h" +#include <ctype.h> + +enum ttf_instructions { + ttf_npushb = 0x40, + ttf_npushw = 0x41, + ttf_pushb = 0xb0, + ttf_pushw = 0xb8, + ttf_aa = 0x7f, + ttf_abs = 0x64, + ttf_add = 0x60, + ttf_alignpts = 0x27, + ttf_alignrp = 0x3c, + ttf_and = 0x5a, + ttf_call = 0x2b, + ttf_ceiling = 0x67, + ttf_cindex = 0x25, + ttf_clear = 0x22, + ttf_debug = 0x4f, + ttf_deltac1 = 0x73, + ttf_deltac2 = 0x74, + ttf_deltac3 = 0x75, + ttf_deltap1 = 0x5d, + ttf_deltap2 = 0x71, + ttf_deltap3 = 0x72, + ttf_depth = 0x24, + ttf_div = 0x62, + ttf_dup = 0x20, + ttf_eif = 0x59, + ttf_else = 0x1b, + ttf_endf = 0x2d, + ttf_eq = 0x54, + ttf_even = 0x57, + ttf_fdef = 0x2c, + ttf_flipoff = 0x4e, + ttf_flipon = 0x4d, + ttf_flippt = 0x80, + ttf_fliprgoff = 0x82, + ttf_fliprgon = 0x81, + ttf_floor = 0x66, + ttf_gc = 0x46, + ttf_getinfo = 0x88, + ttf_gfv = 0x0d, + ttf_gpv = 0x0c, + ttf_gt = 0x52, + ttf_gteq = 0x53, + ttf_idef = 0x89, + ttf_if = 0x58, + ttf_instctrl = 0x8e, + ttf_ip = 0x39, + ttf_isect = 0x0f, + ttf_iup = 0x30, + ttf_jmpr = 0x1c, + ttf_jrof = 0x79, + ttf_jrot = 0x78, + ttf_loopcall = 0x2a, + ttf_lt = 0x50, + ttf_lteq = 0x51, + ttf_max = 0x8b, + ttf_md = 0x49, + ttf_mdap = 0x2e, + ttf_mdrp = 0xc0, + ttf_miap = 0x3e, + ttf_min = 0x8c, + ttf_mindex = 0x26, + ttf_mirp = 0xe0, + ttf_mppem = 0x4b, + ttf_mps = 0x4c, + ttf_msirp = 0x3a, + ttf_mul = 0x63, + ttf_neg = 0x65, + ttf_neq = 0x55, + ttf_not = 0x5c, + ttf_nround = 0x6c, + ttf_odd = 0x56, + ttf_or = 0x5b, + ttf_pop = 0x21, + ttf_rcvt = 0x45, + ttf_rdtg = 0x7d, + ttf_roff = 0x7a, + ttf_roll = 0x8a, + ttf_round = 0x68, + ttf_rs = 0x43, + ttf_rtdg = 0x3d, + ttf_rtg = 0x18, + ttf_rthg = 0x19, + ttf_rutg = 0x7c, + ttf_s45round = 0x77, + ttf_sangw = 0x7e, + ttf_scanctrl = 0x85, + ttf_scantype = 0x8d, + ttf_scfs = 0x48, + ttf_scvtci = 0x1d, + ttf_sdb = 0x5e, + ttf_sdpvtl = 0x86, + ttf_sds = 0x5f, + ttf_sfvfs = 0x0b, + ttf_sfvtca = 0x04, + ttf_sfvtl = 0x08, + ttf_sfvtpv = 0x0e, + ttf_shc = 0x34, + ttf_shp = 0x32, + ttf_shpix = 0x38, + ttf_shz = 0x36, + ttf_sloop = 0x17, + ttf_smd = 0x1a, + ttf_spvfs = 0x0a, + ttf_spvtca = 0x02, + ttf_spvtl = 0x06, + ttf_sround = 0x76, + ttf_srp0 = 0x10, + ttf_srp1 = 0x11, + ttf_srp2 = 0x12, + ttf_ssw = 0x1f, + ttf_sswci = 0x1e, + ttf_sub = 0x61, + ttf_svtca = 0x00, + ttf_swap = 0x23, + ttf_szp0 = 0x13, + ttf_szp1 = 0x14, + ttf_szp2 = 0x15, + ttf_szps = 0x16, + ttf_utp = 0x29, + ttf_wcvtf = 0x70, + ttf_wcvtp = 0x44, + ttf_ws = 0x42, + ttf_getvariation = 0x91 +}; +enum byte_types { bt_instr, bt_cnt, bt_byte, bt_wordhi, bt_wordlo, bt_impliedreturn }; + +struct instrdata { + uint8_t *instrs; + uint32_t instr_cnt; + uint8_t *bts; +}; + +const char *ff_ttf_instrnames[] = {"SVTCA[y-axis]", + "SVTCA[x-axis]", + "SPVTCA[y-axis]", + "SPVTCA[x-axis]", + "SFVTCA[y-axis]", + "SFVTCA[x-axis]", + "SPVTL[parallel]", + "SPVTL[orthog]", + "SFVTL[parallel]", + "SFVTL[orthog]", + "SPVFS", + "SFVFS", + "GPV", + "GFV", + "SFVTPV", + "ISECT", + "SRP0", + "SRP1", + "SRP2", + "SZP0", + "SZP1", + "SZP2", + "SZPS", + "SLOOP", + "RTG", + "RTHG", + "SMD", + "ELSE", + "JMPR", + "SCVTCI", + "SSWCI", + "SSW", + "DUP", + "POP", + "CLEAR", + "SWAP", + "DEPTH", + "CINDEX", + "MINDEX", + "ALIGNPTS", + "Unknown28", + "UTP", + "LOOPCALL", + "CALL", + "FDEF", + "ENDF", + "MDAP[no-rnd]", + "MDAP[rnd]", + "IUP[y]", + "IUP[x]", + "SHP[rp2]", + "SHP[rp1]", + "SHC[rp2]", + "SHC[rp1]", + "SHZ[rp2]", + "SHZ[rp1]", + "SHPIX", + "IP", + "MSIRP[no-rp0]", + "MSIRP[rp0]", + "ALIGNRP", + "RTDG", + "MIAP[no-rnd]", + "MIAP[rnd]", + "NPUSHB", + "NPUSHW", + "WS", + "RS", + "WCVTP", + "RCVT", + "GC[cur]", + "GC[orig]", + "SCFS", + "MD[grid]", + "MD[orig]", + "MPPEM", + "MPS", + "FLIPON", + "FLIPOFF", + "DEBUG", + "LT", + "LTEQ", + "GT", + "GTEQ", + "EQ", + "NEQ", + "ODD", + "EVEN", + "IF", + "EIF", + "AND", + "OR", + "NOT", + "DELTAP1", + "SDB", + "SDS", + "ADD", + "SUB", + "DIV", + "MUL", + "ABS", + "NEG", + "FLOOR", + "CEILING", + "ROUND[Grey]", + "ROUND[Black]", + "ROUND[White]", + "ROUND[Undef4]", + "NROUND[Grey]", + "NROUND[Black]", + "NROUND[White]", + "NROUND[Undef4]", + "WCVTF", + "DELTAP2", + "DELTAP3", + "DELTAC1", + "DELTAC2", + "DELTAC3", + "SROUND", + "S45ROUND", + "JROT", + "JROF", + "ROFF", + "Unknown7B", + "RUTG", + "RDTG", + "SANGW", + "AA", + "FLIPPT", + "FLIPRGON", + "FLIPRGOFF", + "Unknown83", + "Unknown84", + "SCANCTRL", + "SDPVTL[parallel]", + "SDPVTL[orthog]", + "GETINFO", + "IDEF", + "ROLL", + "MAX", + "MIN", + "SCANTYPE", + "INSTCTRL", + "Unknown8F", + "Unknown90", + "GETVARIATION", + "Unknown92", + "Unknown93", + "Unknown94", + "Unknown95", + "Unknown96", + "Unknown97", + "Unknown98", + "Unknown99", + "Unknown9A", + "Unknown9B", + "Unknown9C", + "Unknown9D", + "Unknown9E", + "Unknown9F", + "UnknownA0", + "UnknownA1", + "UnknownA2", + "UnknownA3", + "UnknownA4", + "UnknownA5", + "UnknownA6", + "UnknownA7", + "UnknownA8", + "UnknownA9", + "UnknownAA", + "UnknownAB", + "UnknownAC", + "UnknownAD", + "UnknownAE", + "UnknownAF", + "PUSHB_1", + "PUSHB_2", + "PUSHB_3", + "PUSHB_4", + "PUSHB_5", + "PUSHB_6", + "PUSHB_7", + "PUSHB_8", + "PUSHW_1", + "PUSHW_2", + "PUSHW_3", + "PUSHW_4", + "PUSHW_5", + "PUSHW_6", + "PUSHW_7", + "PUSHW_8", + "MDRP[grey]", + "MDRP[black]", + "MDRP[white]", + "MDRP03", + "MDRP[rnd,grey]", + "MDRP[rnd,black]", + "MDRP[rnd,white]", + "MDRP07", + "MDRP[min,grey]", + "MDRP[min,black]", + "MDRP[min,white]", + "MDRP0b", + "MDRP[min,rnd,grey]", + "MDRP[min,rnd,black]", + "MDRP[min,rnd,white]", + "MDRP0f", + "MDRP[rp0,grey]", + "MDRP[rp0,black]", + "MDRP[rp0,white]", + "MDRP13", + "MDRP[rp0,rnd,grey]", + "MDRP[rp0,rnd,black]", + "MDRP[rp0,rnd,white]", + "MDRP17", + "MDRP[rp0,min,grey]", + "MDRP[rp0,min,black]", + "MDRP[rp0,min,white]", + "MDRP1b", + "MDRP[rp0,min,rnd,grey]", + "MDRP[rp0,min,rnd,black]", + "MDRP[rp0,min,rnd,white]", + "MDRP1f", + "MIRP[grey]", + "MIRP[black]", + "MIRP[white]", + "MIRP03", + "MIRP[rnd,grey]", + "MIRP[rnd,black]", + "MIRP[rnd,white]", + "MIRP07", + "MIRP[min,grey]", + "MIRP[min,black]", + "MIRP[min,white]", + "MIRP0b", + "MIRP[min,rnd,grey]", + "MIRP[min,rnd,black]", + "MIRP[min,rnd,white]", + "MIRP0f", + "MIRP[rp0,grey]", + "MIRP[rp0,black]", + "MIRP[rp0,white]", + "MIRP13", + "MIRP[rp0,rnd,grey]", + "MIRP[rp0,rnd,black]", + "MIRP[rp0,rnd,white]", + "MIRP17", + "MIRP[rp0,min,grey]", + "MIRP[rp0,min,black]", + "MIRP[rp0,min,white]", + "MIRP1b", + "MIRP[rp0,min,rnd,grey]", + "MIRP[rp0,min,rnd,black]", + "MIRP[rp0,min,rnd,white]", + "MIRP1f"}; + +static int strnmatch(const char *str1, const char *str2, int n) { + int ch1, ch2; + for (; n-- > 0;) { + ch1 = *str1++; + ch2 = *str2++; + ch1 = tolower(ch1); + ch2 = tolower(ch2); + if (ch1 != ch2 || ch1 == '\0') return (ch1 - ch2); + } + return (0); +} + +static uint8_t *parse_instrs(char *text, int *len, void *context, + void (*IVError)(void *context, const char *, int)) { + short numberstack[256]; + int npos = 0, nread, i; + int push_left = 0, push_size = 0; + char *pt; + char *end, *bend, *brack; + int icnt = 0, imax = (int)(strlen(text)), val; + uint8_t *instrs; + NEW(instrs, imax); + + for (pt = text; *pt; ++pt) { + npos = 0; + while (npos < 256) { + while (*pt == ' ' || *pt == '\t') + ++pt; + if (isdigit(*pt) || *pt == '-') { + val = strtol(pt, &end, 0); + if (val > 32767 || val < -32768) { + IVError(context, "A value must be between [-32768,32767]", (int)(pt - text)); + return (NULL); + } + pt = end; + numberstack[npos++] = val; + } else + break; + } + while (*pt == ' ' || *pt == '\t') + ++pt; + if (npos == 0 && (*pt == '\r' || *pt == '\n' || *pt == '\0')) continue; + nread = 0; + if (push_left == -1) { + /* we need a push count */ + if (npos == 0) + IVError(context, "Expected a number for a push count", (int)(pt - text)); + else if (numberstack[0] > 255 || numberstack[0] <= 0) { + IVError(context, "The push count must be a number between 0 and 255", + (int)(pt - text)); + return (NULL); + } else { + nread = 1; + instrs[icnt++] = numberstack[0]; + push_left = numberstack[0]; + } + } + if (push_left != 0 && push_left < npos - nread && + (*pt == '\r' || *pt == '\n' || *pt == '\0')) { + IVError(context, "More pushes specified than needed", (int)(pt - text)); + return (NULL); + } + while (push_left > 0 && nread < npos) { + if (push_size == 2) { + instrs[icnt++] = numberstack[nread] >> 8; + instrs[icnt++] = numberstack[nread++] & 0xff; + } else if (numberstack[0] > 255 || numberstack[0] < 0) { + IVError(context, "A value to be pushed by a byte push must be between 0 and 255", + (int)(pt - text)); + return (NULL); + } else + instrs[icnt++] = numberstack[nread++]; + --push_left; + } + if (nread < npos && push_left == 0 && (*pt == '\r' || *pt == '\n' || *pt == '\0')) { + IVError(context, "Unexpected number", (int)(pt - text)); + return (NULL); + } + if (*pt == '\r' || *pt == '\n' || *pt == '\0') continue; + if (push_left > 0) { + IVError(context, "Missing pushes", (int)(pt - text)); + return (NULL); + } + while (nread < npos) { + i = nread; + if (numberstack[nread] >= 0 && numberstack[nread] <= 255) { + while (i < npos && numberstack[i] >= 0 && numberstack[i] <= 255) + ++i; + if (i - nread <= 8) + instrs[icnt++] = ttf_pushb + (i - nread) - 1; + else { + instrs[icnt++] = ttf_npushb; + instrs[icnt++] = i - nread; + } + while (nread < i) + instrs[icnt++] = numberstack[nread++]; + } else { + while (i < npos && (numberstack[i] < 0 || numberstack[i] > 255)) + ++i; + if (i - nread <= 8) + instrs[icnt++] = ttf_pushw + (i - nread) - 1; + else { + instrs[icnt++] = ttf_npushw; + instrs[icnt++] = i - nread; + } + while (nread < i) { + instrs[icnt++] = numberstack[nread] >> 8; + instrs[icnt++] = numberstack[nread++] & 0xff; + } + } + } + brack = NULL; + for (end = pt; *end != '\r' && *end != '\n' && *end != ' ' && *end != '\0'; ++end) + if (*end == '[' || *end == '_') brack = end; + for (i = 0; i < 256; ++i) + if (strnmatch(pt, ff_ttf_instrnames[i], (int)(end - pt)) == 0 && + sizeof(char) * (end - pt) == strlen(ff_ttf_instrnames[i])) + break; + if (i == 256 && brack != NULL) { + for (i = 0; i < 256; ++i) + if (strnmatch(pt, ff_ttf_instrnames[i], (int)(brack - pt + 1)) == 0) break; + val = strtol(brack + 1, &bend, 2); /* Stuff in brackets should be in binary */ + while (*bend == ' ' || *bend == '\t') + ++bend; + if (*bend != ']') { + IVError(context, + "Missing right bracket in command (or bad binary value in bracket)", + (int)(pt - text)); + return (NULL); + } + if (val >= 32) { + IVError(context, "Bracketted value is too large", (int)(pt - text)); + return (NULL); + } + i += val; + } + pt = end; + instrs[icnt++] = i; + if (i == ttf_npushb || i == ttf_npushw || (i >= ttf_pushb && i <= ttf_pushw + 7)) { + push_size = (i == ttf_npushb || (i >= ttf_pushb && i <= ttf_pushb + 7)) ? 1 : 2; + if (i == ttf_npushb || i == ttf_npushw) + push_left = -1; + else if (i >= ttf_pushb && i <= ttf_pushb + 7) + push_left = i - ttf_pushb + 1; + else + push_left = i - ttf_pushw + 1; + } + if (*pt == '\0') break; + } + *len = icnt; + RESIZE(instrs, icnt == 0 ? 1 : icnt); + return instrs; /* some versions of realloc abort on 0 */ +} + +static int instr_typify(struct instrdata *id) { + int i, len = id->instr_cnt, cnt, j, lh; + uint8_t *instrs = id->instrs; + uint8_t *bts; + + if (id->bts == NULL) NEW(id->bts, len + 1); + bts = id->bts; + for (i = lh = 0; i < len; ++i) { + bts[i] = bt_instr; + ++lh; + if (instrs[i] == ttf_npushb) { + /* NPUSHB */ + bts[++i] = bt_cnt; + cnt = instrs[i]; + for (j = 0; j < cnt; ++j) + bts[++i] = bt_byte; + lh += 1 + cnt; + } else if (instrs[i] == ttf_npushw) { + /* NPUSHW */ + bts[++i] = bt_cnt; + ++lh; + cnt = instrs[i]; + for (j = 0; j < cnt; ++j) { + bts[++i] = bt_wordhi; + bts[++i] = bt_wordlo; + } + lh += 1 + cnt; + } else if ((instrs[i] & 0xf8) == 0xb0) { + /* PUSHB[n] */ + cnt = (instrs[i] & 7) + 1; + for (j = 0; j < cnt; ++j) + bts[++i] = bt_byte; + lh += cnt; + } else if ((instrs[i] & 0xf8) == 0xb8) { + /* PUSHW[n] */ + cnt = (instrs[i] & 7) + 1; + for (j = 0; j < cnt; ++j) { + bts[++i] = bt_wordhi; + bts[++i] = bt_wordlo; + } + lh += cnt; + } + } + bts[i] = bt_impliedreturn; + return (lh); +} + +json_value *dump_ttinstr(uint8_t *instructions, uint32_t length, const otfcc_Options *options) { + if (options->instr_as_bytes) { + size_t len = 0; + uint8_t *buf = base64_encode(instructions, length, &len); + return json_string_new_length((uint32_t)len, (char *)buf); + FREE(buf); + } else { + struct instrdata id; + + memset(&id, 0, sizeof(id)); + id.instr_cnt = length; + id.instrs = instructions; + instr_typify(&id); + json_value *ret = json_array_new(id.instr_cnt); + for (uint32_t i = 0; i < id.instr_cnt; ++i) { + if (id.bts[i] == bt_wordhi) { + json_array_push( + ret, json_integer_new((int16_t)((id.instrs[i] << 8) | id.instrs[i + 1]))); + ++i; + } else if (id.bts[i] == bt_cnt || id.bts[i] == bt_byte) { + json_array_push(ret, json_integer_new(id.instrs[i])); + } else { + json_array_push(ret, json_string_new(ff_ttf_instrnames[id.instrs[i]])); + } + } + FREE(id.bts); + return preserialize(ret); + } +} + +void parse_ttinstr(json_value *col, void *context, void (*Make)(void *, uint8_t *, uint32_t), + void (*Wrong)(void *, const char *, int)) { + if (!col) { + Make(context, NULL, 0); + } else if (col->type == json_string) { + size_t instrlen; + uint8_t *instructions = + base64_decode((uint8_t *)col->u.string.ptr, col->u.string.length, &instrlen); + Make(context, instructions, (uint32_t)instrlen); + } else if (col->type == json_array) { + size_t istrlen = 0; + for (uint32_t j = 0; j < col->u.array.length; j++) { + json_value *record = col->u.array.values[j]; + if (record->type == json_string) { + istrlen += record->u.string.length + 1; + } else if (record->type == json_integer) { + istrlen += 1 + 20; + } else { + Make(context, NULL, 0); + return; + } + } + sds instrString = sdsnewlen(NULL, istrlen + 1); + char *head = instrString; + for (uint32_t j = 0; j < col->u.array.length; j++) { + json_value *record = col->u.array.values[j]; + if (record->type == json_string) { + memcpy(head, record->u.string.ptr, sizeof(char) * record->u.string.length); + head += record->u.string.length; + } else if (record->type == json_integer) { + int n = snprintf(head, 20, "%d", (int)record->u.integer); + head += n; + } + *head = '\n'; + head++; + } + int instrLength = 0; + uint8_t *instructions = parse_instrs(instrString, &instrLength, context, Wrong); + sdsfree(instrString); + if (instructions && instrLength) { + Make(context, instructions, instrLength); + } else { + Make(context, NULL, 0); + } + } else { + Make(context, NULL, 0); + } +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.h new file mode 100644 index 00000000000..3bf56832f3b --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/ttinstr/ttinstr.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2001-2012 by George Williams */ +/* Copyright (C) 2016 by Belleve Invis */ + +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CARYLL_SUPPORT_TTINSTR_H +#define CARYLL_SUPPORT_TTINSTR_H +#include "../util.h" + +void parse_ttinstr(json_value *col, void *context, void (*Make)(void *, uint8_t *, uint32_t), + void (*Wrong)(void *, const char *, int)); +json_value *dump_ttinstr(uint8_t *instructions, uint32_t length, const otfcc_Options *options); + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c new file mode 100644 index 00000000000..a2c2e1ec85e --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.c @@ -0,0 +1,291 @@ +#include "unicodeconv.h" + +// Brought from libXML2. +sds utf16le_to_utf8(const uint8_t *inbyte, int inlenb) { + uint8_t *inb; + uint16_t *in ; + uint16_t *inend; + uint32_t c, d, inlen; + int bits; + + if(inlenb<0) { + fprintf(stderr,"! error utf16le_to_utf8: inlenb negative.\n"); + return NULL; + } + inb = malloc(inlenb); + if(inb==NULL && inlenb>0){ + fprintf(stderr,"! error utf16le_to_utf8: allocating inb failed.\n"); + exit(1); + } + memcpy(inb, inbyte, (size_t)(inlenb)); + + in = (uint16_t *)inb; + + if ((inlenb % 2) == 1) (inlenb)--; + inlen = inlenb / 2; + inend = in + inlen; + // pass 1: calculate bytes used for output + uint32_t bytesNeeded = 0; + while (in < inend) { + c = *in++; + if ((c & 0xFC00) == 0xD800) { // surrogates + if (in >= inend) { // (in > inend) shouldn't happens + break; + } + d = *in++; + if ((d & 0xFC00) == 0xDC00) { + c &= 0x03FF; + c <<= 10; + c |= d & 0x03FF; + c += 0x10000; + } + } + if (c < 0x80) { + bytesNeeded += 1; + } else if (c < 0x800) { + bytesNeeded += 2; + } else if (c < 0x10000) { + bytesNeeded += 3; + } else { + bytesNeeded += 4; + } + } + in = (uint16_t *)inb; + sds out = sdsnewlen(NULL, bytesNeeded); + sds out0 = out; + + while (in < inend) { + c = *in++; + if ((c & 0xFC00) == 0xD800) { + if (in >= inend) { break; } + d = *in++; + if ((d & 0xFC00) == 0xDC00) { + c &= 0x03FF; + c <<= 10; + c |= d & 0x03FF; + c += 0x10000; + } + } + + if (c < 0x80) { + *out++ = c; + bits = -6; + } else if (c < 0x800) { + *out++ = ((c >> 6) & 0x1F) | 0xC0; + bits = 0; + } else if (c < 0x10000) { + *out++ = ((c >> 12) & 0x0F) | 0xE0; + bits = 6; + } else { + *out++ = ((c >> 18) & 0x07) | 0xF0; + bits = 12; + } + + for (; bits >= 0; bits -= 6) { + *out++ = ((c >> bits) & 0x3F) | 0x80; + } + } + if (inb) { + free(inb); + } + return out0; +} + +sds utf16be_to_utf8(const uint8_t *inbyte, int inlenb) { + uint8_t *inb; + uint16_t *in ; //= (uint16_t *)inb; + uint16_t *inend; + uint32_t c, d, inlen; + uint8_t *tmp; + int bits; + + if(inlenb<0) { + fprintf(stderr,"! error utf16be_to_utf8: inlenb negative.\n"); + return NULL; + } + inb = malloc(inlenb); + if(inb==NULL && inlenb>0){ + fprintf(stderr,"! error utf16be_to_utf8: allocating inb failed.\n"); + exit(1); + } + memcpy(inb, inbyte, (size_t)(inlenb)); + + in = (uint16_t *)inb; + + if ((inlenb % 2) == 1) (inlenb)--; + inlen = inlenb / 2; + inend = in + inlen; + uint32_t bytesNeeded = 0; + while (in < inend) { + { + tmp = (uint8_t *)in; + c = *tmp++; + c = c << 8; + c = c | (uint32_t)*tmp; + in++; + } + if ((c & 0xFC00) == 0xD800) { + if (in >= inend) { break; } + { + tmp = (uint8_t *)in; + d = *tmp++; + d = d << 8; + d = d | (uint32_t)*tmp; + in++; + } + if ((d & 0xFC00) == 0xDC00) { + c &= 0x03FF; + c <<= 10; + c |= d & 0x03FF; + c += 0x10000; + } + } + if (c < 0x80) { + bytesNeeded += 1; + } else if (c < 0x800) { + bytesNeeded += 2; + } else if (c < 0x10000) { + bytesNeeded += 3; + } else { + bytesNeeded += 4; + } + } + in = (uint16_t *)inb; + sds out = sdsnewlen(NULL, bytesNeeded); + sds out0 = out; + + while (in < inend) { + { + tmp = (uint8_t *)in; + c = *tmp++; + c = c << 8; + c = c | (uint32_t)*tmp; + in++; + } + if ((c & 0xFC00) == 0xD800) { + if (in >= inend) { break; } + { + tmp = (uint8_t *)in; + d = *tmp++; + d = d << 8; + d = d | (uint32_t)*tmp; + in++; + } + if ((d & 0xFC00) == 0xDC00) { + c &= 0x03FF; + c <<= 10; + c |= d & 0x03FF; + c += 0x10000; + } + } + + if (c < 0x80) { + *out++ = c; + bits = -6; + } else if (c < 0x800) { + *out++ = ((c >> 6) & 0x1F) | 0xC0; + bits = 0; + } else if (c < 0x10000) { + *out++ = ((c >> 12) & 0x0F) | 0xE0; + bits = 6; + } else { + *out++ = ((c >> 18) & 0x07) | 0xF0; + bits = 12; + } + + for (; bits >= 0; bits -= 6) { + *out++ = ((c >> bits) & 0x3F) | 0x80; + } + } + if (inb) { + free(inb); + } + return out0; +} + +uint8_t *utf8toutf16be(sds _in, size_t *out_bytes) { + if (!_in) { + *out_bytes = 0; + return NULL; + } + sds in = _in; + size_t inlen = sdslen(in); + char *inend = in + inlen; + + uint32_t wordsNeeded = 0; + uint8_t trailing = 0; + uint32_t c = 0; + while (in < inend) { + uint8_t d = *in++; + if (d < 0x80) { + c = d; + trailing = 0; + } else if (d < 0xC0) { + break; // trailing byte in leading position + } else if (d < 0xE0) { + c = d & 0x1F; + trailing = 1; + } else if (d < 0xF0) { + c = d & 0x0F; + trailing = 2; + } else if (d < 0xF8) { + c = d & 0x07; + trailing = 3; + } else { + break; + } + if (inend - in < trailing) { break; } + for (; trailing; trailing--) { + if ((in >= inend) || (((d = *in++) & 0xC0) != 0x80)) break; + c <<= 6; + c |= d & 0x3F; + } + if (c < 0x10000) { + wordsNeeded += 1; + } else if (c < 0x110000) { + wordsNeeded += 2; + } + } + uint8_t *_out = malloc(2 * wordsNeeded * sizeof(uint8_t)); + uint8_t *out = _out; + in = _in; + while (in < inend) { + uint8_t d = *in++; + if (d < 0x80) { + c = d; + trailing = 0; + } else if (d < 0xC0) { + break; // trailing byte in leading position + } else if (d < 0xE0) { + c = d & 0x1F; + trailing = 1; + } else if (d < 0xF0) { + c = d & 0x0F; + trailing = 2; + } else if (d < 0xF8) { + c = d & 0x07; + trailing = 3; + } else { + break; + } + if (inend - in < trailing) { break; } + for (; trailing; trailing--) { + if ((in >= inend) || (((d = *in++) & 0xC0) != 0x80)) break; + c <<= 6; + c |= d & 0x3F; + } + if (c < 0x10000) { + *(out++) = (c >> 8) & 0xFF; + *(out++) = c & 0xFF; + } else if (c < 0x110000) { + uint16_t tmp1 = 0xD800 | (c >> 10); + *(out++) = (tmp1 >> 8) & 0xFF; + *(out++) = tmp1 & 0xFF; + uint16_t tmp2 = 0xDC00 | (c & 0x03FF); + *(out++) = (tmp2 >> 8) & 0xFF; + *(out++) = tmp2 & 0xFF; + } + } + *out_bytes = wordsNeeded * 2; + return _out; +} diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h new file mode 100644 index 00000000000..2d22e4ac466 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/unicodeconv/unicodeconv.h @@ -0,0 +1,11 @@ +#ifndef CARYLL_SUPPORT_UNICODECONV_H +#define CARYLL_SUPPORT_UNICODECONV_H +#include <stdio.h> +#include <stdint.h> +#include <string.h> +#include <stdlib.h> +#include "dep/sds.h" +sds utf16le_to_utf8(const uint8_t *inb, int inlenb); +sds utf16be_to_utf8(const uint8_t *inb, int inlenb); +uint8_t *utf8toutf16be(sds _in, size_t *out_bytes); +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/util.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/util.h new file mode 100644 index 00000000000..a68b3e0ab74 --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/util.h @@ -0,0 +1,41 @@ +#ifndef CARYLL_SUPPORT_UTIL_H +#define CARYLL_SUPPORT_UTIL_H + +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif + +#include <inttypes.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include "dep/json-builder.h" +#include "dep/json.h" +#include "dep/sds.h" +#include "dep/uthash.h" + +#include "caryll/ownership.h" +#include "caryll/buffer.h" + +#include "otfcc/handle.h" +#include "otfcc/primitives.h" +#include "otfcc/options.h" + +#include "aliases.h" +#include "otfcc-alloc.h" +#include "element-impl.h" +#include "vector-impl.h" + +#include "base64/base64.h" +#include "json/json-ident.h" +#include "json/json-funcs.h" +#include "bin-io.h" +#include "tag.h" + +#define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) ) + +#endif diff --git a/Build/source/texk/web2c/mfluadir/otfcc/lib/support/vector-impl.h b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/vector-impl.h new file mode 100644 index 00000000000..f38153d68ec --- /dev/null +++ b/Build/source/texk/web2c/mfluadir/otfcc/lib/support/vector-impl.h @@ -0,0 +1,190 @@ +#ifndef CARYLL_SUPPORT_VECTOR_IMPL_H +#define CARYLL_SUPPORT_VECTOR_IMPL_H + +#include "caryll/vector.h" +#include "element-impl.h" + +#ifndef __CARYLL_INLINE__ +#ifdef _MSC_VER +#define __CARYLL_INLINE__ __forceinline /* use __forceinline (VC++ specific) */ +#else +#define __CARYLL_INLINE__ inline /* use standard inline */ +#endif +#endif + +#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define __CARYLL_MAY_UNUSED__ __attribute__((__unused__)) +#elif (__clang_major__ > 2) +#define __CARYLL_MAY_UNUSED__ __attribute__((__unused__)) +#else +#define __CARYLL_MAY_UNUSED__ +#endif + +#define __CARYLL_VECTOR_INITIAL_SIZE 2 + +#define caryll_VectorImplFreeIndependent(__TV, __T, __ti) \ + static __CARYLL_INLINE__ void __TV##_dispose(__TV *arr) { \ + if (!arr) return; \ + if ((__ti).dispose) { \ + for (size_t j = arr->length; j--;) { \ + (__ti).dispose(&arr->items[j]); \ + } \ + } \ + __caryll_free(arr->items); \ + arr->items = NULL; \ + arr->length = 0; \ + arr->capacity = 0; \ + } + +#define caryll_VectorImplFreeDependent(__TV, __T, __TX, fn) \ + static __CARYLL_INLINE__ void __TV##_disposeDependent(__TV *arr, const __TX *enclosure) { \ + if (!arr) return; \ + for (size_t j = arr->length; j--;) { \ + fn(&arr->items[j], enclosure); \ + } \ + __caryll_free(arr->items); \ + arr->items = NULL; \ + arr->length = 0; \ + arr->capacity = 0; \ + } + +#define caryll_VectorImplFunctionsCommon(__TV, __T, __ti) \ + static __CARYLL_INLINE__ void __TV##_init(MODIFY __TV *arr) { \ + arr->length = 0; \ + arr->capacity = 0; \ + arr->items = NULL; \ + } \ + caryll_trivialCreate(__TV); \ + caryll_trivialFree(__TV); \ + static __CARYLL_INLINE__ void __TV##_growTo(MODIFY __TV *arr, size_t target) { \ + if (target <= arr->capacity) return; \ + if (arr->capacity < __CARYLL_VECTOR_INITIAL_SIZE) \ + arr->capacity = __CARYLL_VECTOR_INITIAL_SIZE; \ + while (arr->capacity < target) { \ + arr->capacity += arr->capacity / 2; \ + } \ + if (arr->items) { \ + arr->items = __caryll_realloc(arr->items, arr->capacity * sizeof(__T)); \ + } else { \ + arr->items = __caryll_calloc(arr->capacity, sizeof(__T)); \ + } \ + } \ + static __CARYLL_INLINE__ void __TV##_growToN(MODIFY __TV *arr, size_t target) { \ + if (target <= arr->capacity) return; \ + if (arr->capacity < __CARYLL_VECTOR_INITIAL_SIZE) \ + arr->capacity = __CARYLL_VECTOR_INITIAL_SIZE; \ + if (arr->capacity < target) { arr->capacity = target + 1; } \ + if (arr->items) { \ + arr->items = __caryll_realloc(arr->items, arr->capacity * sizeof(__T)); \ + } else { \ + arr->items = __caryll_calloc(arr->capacity, sizeof(__T)); \ + } \ + } \ + static __CARYLL_INLINE__ void __TV##_resizeTo(MODIFY __TV *arr, size_t target) { \ + arr->capacity = target; \ + if (arr->items) { \ + arr->items = __caryll_realloc(arr->items, arr->capacity * sizeof(__T)); \ + } else { \ + arr->items = __caryll_calloc(arr->capacity, sizeof(__T)); \ + } \ + } \ + static __CARYLL_INLINE__ void __TV##_shrinkToFit(MODIFY __TV *arr) { \ + __TV##_resizeTo(arr, arr->length); \ + } \ + static __CARYLL_INLINE__ void __TV##_grow(MODIFY __TV *arr) { \ + __TV##_growTo(arr, arr->length + 1); \ + } \ + static __CARYLL_INLINE__ void __TV##_push(MODIFY __TV *arr, MOVE __T elem) { \ + __TV##_grow(arr); \ + (arr)->items[(arr)->length++] = (elem); \ + } \ + static __CARYLL_INLINE__ __T __TV##_pop(MODIFY __TV *arr) { \ + __T t = arr->items[arr->length - 1]; \ + arr->length -= 1; \ + return t; \ + } \ + static __CARYLL_INLINE__ void __TV##_fill(MODIFY __TV *arr, size_t n) { \ + while (arr->length < n) { \ + __T x; \ + if ((__ti).init) { \ + (__ti).init(&x); \ + } else { \ + memset(&x, 0, sizeof(x)); \ + } \ + __TV##_push(arr, x); \ + } \ + } \ + static __CARYLL_INLINE__ void __TV##_initN(MODIFY __TV *arr, size_t n) { \ + __TV##_init(arr); \ + __TV##_growToN(arr, n); \ + __TV##_fill(arr, n); \ + } \ + static __CARYLL_INLINE__ void __TV##_initCapN(MODIFY __TV *arr, size_t n) { \ + __TV##_init(arr); \ + __TV##_growToN(arr, n); \ + } \ + static __CARYLL_INLINE__ __TV *__TV##_createN(size_t n) { \ + __TV *t = __caryll_malloc(sizeof(__TV)); \ + __TV##_initN(t, n); \ + return t; \ + } \ + static __CARYLL_INLINE__ void __TV##_move(MODIFY __TV *dst, MOVE __TV *src) { \ + *dst = *src; \ + __TV##_init(src); \ + } \ + static __CARYLL_INLINE__ void __TV##_copy(MODIFY __TV *dst, const __TV *src) { \ + __TV##_init(dst); \ + __TV##_growTo(dst, src->length); \ + dst->length = src->length; \ + if ((__ti).copy) { \ + for (size_t j = 0; j < src->length; j++) { \ + (__ti).copy(&dst->items[j], (const __T *)&src->items[j]); \ + } \ + } else { \ + for (size_t j = 0; j < src->length; j++) { \ + dst->items[j] = src->items[j]; \ + } \ + } \ + } \ + static __CARYLL_INLINE__ void __TV##_sort(MODIFY __TV *arr, \ + int (*fn)(const __T *a, const __T *b)) { \ + qsort(arr->items, arr->length, sizeof(arr->items[0]), \ + (int (*)(const void *, const void *))fn); \ + } \ + static __CARYLL_INLINE__ void __TV##_filterEnv( \ + MODIFY __TV *arr, bool (*fn)(const __T *a, void *env), void *env) { \ + size_t j = 0; \ + for (size_t k = 0; k < arr->length; k++) { \ + if (fn(&arr->items[k], env)) { \ + if (j != k) arr->items[j] = arr->items[k]; \ + j++; \ + } else { \ + (__ti).dispose ? (__ti).dispose(&((arr)->items[k])) : (void)0; \ + } \ + }; \ + arr->length = j; \ + } \ + static __CARYLL_INLINE__ void __TV##_disposeItem(MODIFY __TV *arr, size_t n) { \ + (__ti).dispose ? (__ti).dispose(&((arr)->items[n])) : (void)0; \ + } \ + caryll_trivialReplace(__TV); + +#define caryll_VectorImplFunctions(__TV, __T, __ti) \ + caryll_VectorImplFreeIndependent(__TV, __T, __ti); \ + caryll_VectorImplFunctionsCommon(__TV, __T, __ti); + +#define caryll_VectorImplAssignments(__TV, __T, __ti) \ + .init = __TV##_init, .copy = __TV##_copy, .dispose = __TV##_dispose, .create = __TV##_create, \ + .createN = __TV##_createN, .free = __TV##_free, .initN = __TV##_initN, \ + .initCapN = __TV##_initCapN, .clear = __TV##_dispose, .replace = __TV##_replace, \ + .copyReplace = __TV##_copyReplace, .push = __TV##_push, .pop = __TV##_pop, \ + .fill = __TV##_fill, .sort = __TV##_sort, .disposeItem = __TV##_disposeItem, \ + .filterEnv = __TV##_filterEnv, .move = __TV##_move, .shrinkToFit = __TV##_shrinkToFit + +#define caryll_standardVectorImpl(__TV, __T, __ti, __name) \ + caryll_VectorImplFunctions(__TV, __T, __ti); \ + caryll_VectorInterfaceTypeName(__TV) __name = { \ + caryll_VectorImplAssignments(__TV, __T, __ti), \ + }; + +#endif |