📄 ttfenc.c
字号:
{0x2212, "minus"}, {0x2215, "fraction"}, /* cf U+2044 */ {0x2219, "periodcentered"}, {0x221a, "radical"}, {0x221e, "infinity"}, {0x221f, "orthogonal"}, {0x2229, "intersection"}, {0x222b, "integral"}, {0x2248, "approxequal"}, {0x2260, "notequal"}, {0x2261, "equivalence"}, {0x2264, "lessequal"}, {0x2265, "greaterequal"}, {0x2302, "house"}, {0x2310, "revlogicalnot"}, {0x2320, "integraltp"}, {0x2321, "integralbt"}, {0x2500, "SF100000"}, {0x2502, "SF110000"}, {0x250c, "SF010000"}, {0x2510, "SF030000"}, {0x2514, "SF020000"}, {0x2518, "SF040000"}, {0x251c, "SF080000"}, {0x2524, "SF090000"}, {0x252c, "SF060000"}, {0x2534, "SF070000"}, {0x253c, "SF050000"}, {0x2550, "SF430000"}, {0x2551, "SF240000"}, {0x2552, "SF510000"}, {0x2553, "SF520000"}, {0x2554, "SF390000"}, {0x2555, "SF220000"}, {0x2556, "SF210000"}, {0x2557, "SF250000"}, {0x2558, "SF500000"}, {0x2559, "SF490000"}, {0x255a, "SF380000"}, {0x255b, "SF280000"}, {0x255c, "SF270000"}, {0x255d, "SF260000"}, {0x255e, "SF360000"}, {0x255f, "SF370000"}, {0x2560, "SF420000"}, {0x2561, "SF190000"}, {0x2562, "SF200000"}, {0x2563, "SF230000"}, {0x2564, "SF470000"}, {0x2565, "SF480000"}, {0x2566, "SF410000"}, {0x2567, "SF450000"}, {0x2568, "SF460000"}, {0x2569, "SF400000"}, {0x256a, "SF540000"}, {0x256b, "SF530000"}, {0x256c, "SF440000"}, {0x2580, "upblock"}, {0x2584, "dnblock"}, {0x2588, "block"}, {0x258c, "lfblock"}, {0x2590, "rtblock"}, {0x2591, "ltshade"}, {0x2592, "shade"}, {0x2593, "dkshade"}, {0x25a0, "filledbox"}, {0x25a1, "H22073"}, {0x25aa, "H18543"}, {0x25ab, "H18551"}, {0x25ac, "filledrect"}, {0x25b2, "triagup"}, {0x25ba, "triagrt"}, {0x25bc, "triagdn"}, {0x25c4, "triaglf"}, {0x25ca, "lozenge"}, {0x25cb, "circle"}, {0x25cf, "H18533"}, {0x25d8, "invbullet"}, {0x25d9, "invcircle"}, {0x25e6, "openbullet"}, {0x263a, "smileface"}, {0x263b, "invsmileface"}, {0x263c, "sun"}, {0x2640, "female"}, {0x2642, "male"}, {0x2660, "spade"}, {0x2663, "club"}, {0x2665, "heart"}, {0x2666, "diamond"}, {0x266a, "musicalnote"}, {0x266b, "musicalnotedbl"}, {0xf000, "applelogo"}, {0xf001, "fi"}, {0xf002, "fl"}, {0xf004, "commaaccent"}, {0xf005, "undercommaaccent"}, {0xfb01, "fi"}, {0xfb02, "fl"},};struct encoding_table mac_table[] ={ {-1, ".notdef"}, {0x0000, ".notdef"}, /* null */ {0x0008, ".notdef"}, /* backspace */ {0x0009, ".notdef"}, /* horizontal tabulation */ {0x000d, ".notdef"}, /* carriage return */ {0x001d, ".notdef"}, /* group separator */ {0x0020, "space"}, {0x0021, "exclam"}, {0x0022, "quotedbl"}, {0x0023, "numbersign"}, {0x0024, "dollar"}, {0x0025, "percent"}, {0x0026, "ampersand"}, {0x0027, "quotesingle"}, {0x0028, "parenleft"}, {0x0029, "parenright"}, {0x002a, "asterisk"}, {0x002b, "plus"}, {0x002c, "comma"}, {0x002d, "hyphen"}, {0x002e, "period"}, {0x002f, "slash"}, {0x0030, "zero"}, {0x0031, "one"}, {0x0032, "two"}, {0x0033, "three"}, {0x0034, "four"}, {0x0035, "five"}, {0x0036, "six"}, {0x0037, "seven"}, {0x0038, "eight"}, {0x0039, "nine"}, {0x003a, "colon"}, {0x003b, "semicolon"}, {0x003c, "less"}, {0x003d, "equal"}, {0x003e, "greater"}, {0x003f, "question"}, {0x0040, "at"}, {0x0041, "A"}, {0x0042, "B"}, {0x0043, "C"}, {0x0044, "D"}, {0x0045, "E"}, {0x0046, "F"}, {0x0047, "G"}, {0x0048, "H"}, {0x0049, "I"}, {0x004a, "J"}, {0x004b, "K"}, {0x004c, "L"}, {0x004d, "M"}, {0x004e, "N"}, {0x004f, "O"}, {0x0050, "P"}, {0x0051, "Q"}, {0x0052, "R"}, {0x0053, "S"}, {0x0054, "T"}, {0x0055, "U"}, {0x0056, "V"}, {0x0057, "W"}, {0x0058, "X"}, {0x0059, "Y"}, {0x005a, "Z"}, {0x005b, "bracketleft"}, {0x005c, "backslash"}, {0x005d, "bracketright"}, {0x005e, "asciicircum"}, {0x005f, "underscore"}, {0x0060, "grave"}, {0x0061, "a"}, {0x0062, "b"}, {0x0063, "c"}, {0x0064, "d"}, {0x0065, "e"}, {0x0066, "f"}, {0x0067, "g"}, {0x0068, "h"}, {0x0069, "i"}, {0x006a, "j"}, {0x006b, "k"}, {0x006c, "l"}, {0x006d, "m"}, {0x006e, "n"}, {0x006f, "o"}, {0x0070, "p"}, {0x0071, "q"}, {0x0072, "r"}, {0x0073, "s"}, {0x0074, "t"}, {0x0075, "u"}, {0x0076, "v"}, {0x0077, "w"}, {0x0078, "x"}, {0x0079, "y"}, {0x007a, "z"}, {0x007b, "braceleft"}, {0x007c, "bar"}, {0x007d, "braceright"}, {0x007e, "asciitilde"}, {0x0080, "Adieresis"}, {0x0081, "Aring"}, {0x0082, "Ccedilla"}, {0x0083, "Eacute"}, {0x0084, "Ntilde"}, {0x0085, "Odieresis"}, {0x0086, "Udieresis"}, {0x0087, "aacute"}, {0x0088, "agrave"}, {0x0089, "acircumflex"}, {0x008a, "adieresis"}, {0x008b, "atilde"}, {0x008c, "aring"}, {0x008d, "ccedilla"}, {0x008e, "eacute"}, {0x008f, "egrave"}, {0x0090, "ecircumflex"}, {0x0091, "edieresis"}, {0x0092, "iacute"}, {0x0093, "igrave"}, {0x0094, "icircumflex"}, {0x0095, "idieresis"}, {0x0096, "ntilde"}, {0x0097, "oacute"}, {0x0098, "ograve"}, {0x0099, "ocircumflex"}, {0x009a, "odieresis"}, {0x009b, "otilde"}, {0x009c, "uacute"}, {0x009d, "ugrave"}, {0x009e, "ucircumflex"}, {0x009f, "udieresis"}, {0x00a0, "dagger"}, {0x00a1, "degree"}, {0x00a2, "cent"}, {0x00a3, "sterling"}, {0x00a4, "section"}, {0x00a5, "bullet"}, {0x00a6, "paragraph"}, {0x00a7, "germandbls"}, {0x00a8, "registered"}, {0x00a9, "copyright"}, {0x00aa, "trademark"}, {0x00ab, "acute"}, {0x00ac, "dieresis"}, {0x00ad, "notequal"}, {0x00ae, "AE"}, {0x00af, "Oslash"}, {0x00b0, "infinity"}, {0x00b1, "plusminus"}, {0x00b2, "lessequal"}, {0x00b3, "greaterequal"}, {0x00b4, "yen"}, {0x00b5, "mu"}, {0x00b6, "partialdiff"}, {0x00b7, "summation"}, {0x00b8, "product"}, {0x00b9, "pi"}, {0x00ba, "integral"}, {0x00bb, "ordfeminine"}, {0x00bc, "ordmasculine"}, {0x00bd, "Omega"}, {0x00be, "ae"}, {0x00bf, "oslash"}, {0x00c0, "questiondown"}, {0x00c1, "exclamdown"}, {0x00c2, "logicalnot"}, {0x00c3, "radical"}, {0x00c4, "florin"}, {0x00c5, "approxequal"}, {0x00c6, "Delta"}, {0x00c7, "guillemotleft"}, {0x00c8, "guillemotright"}, {0x00c9, "ellipsis"}, {0x00ca, "nbspace"}, {0x00cb, "Agrave"}, {0x00cc, "Atilde"}, {0x00cd, "Otilde"}, {0x00ce, "OE"}, {0x00cf, "oe"}, {0x00d0, "endash"}, {0x00d1, "emdash"}, {0x00d2, "quotedblleft"}, {0x00d3, "quotedblright"}, {0x00d4, "quoteleft"}, {0x00d5, "quoteright"}, {0x00d6, "divide"}, {0x00d7, "lozenge"}, {0x00d8, "ydieresis"}, {0x00d9, "Ydieresis"}, {0x00da, "fraction"}, {0x00db, "currency"}, {0x00dc, "guilsinglleft"}, {0x00dd, "guilsinglright"}, {0x00de, "fi"}, {0x00df, "fl"}, {0x00e0, "daggerdbl"}, {0x00e1, "periodcentered"}, {0x00e2, "quotesinglbase"}, {0x00e3, "quotedblbase"}, {0x00e4, "perthousand"}, {0x00e5, "Acircumflex"}, {0x00e6, "Ecircumflex"}, {0x00e7, "Aacute"}, {0x00e8, "Edieresis"}, {0x00e9, "Egrave"}, {0x00ea, "Iacute"}, {0x00eb, "Icircumflex"}, {0x00ec, "Idieresis"}, {0x00ed, "Igrave"}, {0x00ee, "Oacute"}, {0x00ef, "Ocircumflex"}, {0x00f0, "apple"}, {0x00f1, "Ograve"}, {0x00f2, "Uacute"}, {0x00f3, "Ucircumflex"}, {0x00f4, "Ugrave"}, {0x00f5, "dotlessi"}, {0x00f6, "circumflex"}, {0x00f7, "tilde"}, {0x00f8, "macron"}, {0x00f9, "breve"}, {0x00fa, "dotaccent"}, {0x00fb, "ring"}, {0x00fc, "cedilla"}, {0x00fd, "hungarumlaut"}, {0x00fe, "ogonek"}, {0x00ff, "caron"},};struct encoding_table *current_table;size_t current_table_len;void set_encoding_scheme(EncodingScheme e, Font *fnt){ current_encoding_scheme = e; switch (e) { case encUnicode: current_table = unicode_table; current_table_len = sizeof (unicode_table) / sizeof (unicode_table[0]); break; case encMac: current_table = mac_table; current_table_len = sizeof (mac_table) / sizeof (mac_table[0]); break; case encFontSpecific: break; }}/* * We return ".c0x<code point in hexadecimal representation>" * if no name is found. * * We return ".g0x<code point in hexadecimal representation>" * if it's a glyph index (code >= 0x1000000). */char *code_to_adobename(long code){ unsigned int n, n1 = 0, n2 = current_table_len - 1; char *p; if (current_encoding_scheme == encFontSpecific) { p = (char *)mymalloc(9); sprintf(p, ".%c0x%lx", (code >= 0x1000000) ? 'g' : 'c', (code & 0xFFFFFF)); return p; } while (n1 <= n2) { n = (n1 + n2) / 2; if (code < current_table[n].code) n2 = n - 1; else if (code > current_table[n].code) n1 = n + 1; else return current_table[n].adobename; } p = (char *)mymalloc(9); sprintf(p, ".%c0x%lx", (code >= 0x1000000) ? 'g' : 'c', (code & 0xFFFFFF)); return p; }/* * The first of two identical entries will win. */longadobename_to_code(char *s){ size_t i; long j; char p; if (s == NULL) return -1; if (current_encoding_scheme == encFontSpecific) { if (*(s++) != '.') return -1; p = *(s++); if (!(p == 'c' || p == 'g')) return -1; j = strtol(s, &s, 0); if (*s == '\0') return (p == 'g') ? (j | 0x1000000) : j; else return -1; } for (i = 0; i < current_table_len; i++) { if (strcmp(current_table[i].adobename, s) == 0) return current_table[i].code; } if (*(s++) != '.') return -1; p = *(s++); if (!(p == 'c' || p == 'g')) return -1; j = strtol(s, &s, 0); if (*s == '\0') return (p == 'g') ? (j | 0x1000000) : j; else return -1;}ttfinfo *findglyph(unsigned short g, ttfinfo *p){ register ttfinfo *ti; if (!p) return NULL; for (ti = p; ti; ti = ti->next) if (g == ti->glyphindex) return ti; return NULL;}ttfinfo *findadobe(char *p, ttfinfo *ap){ register ttfinfo *ti; register long l = -1; register char c = '\0', d = '\0'; if (!p) return NULL; if (p[0] == '.' && (c = p[1]) && (c == 'c' || c == 'g') && (d = p[2]) && '0' <= d && d <= '9') l = strtol(p + 2, NULL, 0); for (ti = ap; ti; ti = ti->next) { if (l >= 0) { if (c == 'c') { if (ti->charcode == l) return ti; } else { if (ti->glyphindex == l) return ti; } } else if (strcmp(p, ti->adobename) == 0) return ti; } return NULL;}ttfinfo *findmappedadobe(char *p, ttfinfo **array){ register int i; register ttfinfo *ti; register long l = -1; register char c = '\0', d = '\0'; if (!p) return NULL; if (p[0] == '.' && (c = p[1]) && (c == 'c' || c == 'g') && (d = p[2]) && '0' <= d && d <= '9') l = strtol(p + 2, NULL, 0); for (i = 0; i <= 0xFF; i++) if ((ti = array[i])) { if (l >= 0) { if (c == 'c') { if (ti->charcode == l) return ti; } else { if (ti->glyphindex == l) return ti; } } else if (strcmp(p, ti->adobename) == 0) return ti; } return NULL;}voidreplace_glyphs(Font *fnt){ stringlist *sl, *sl_old; ttfinfo *ti; for (sl = fnt->replacements, sl_old = NULL; sl; sl_old = sl, sl = sl->next) { if ((ti = findadobe(sl->old_name, fnt->charlist))) ti->adobename = sl->new_name; else { warning("Glyph name `%s' not found.", sl->old_name); warning("Replacement glyph name `%s' thus ignored.", sl->new_name); if (sl_old == NULL) fnt->replacements = sl->next; else sl_old->next = sl->next; } }}/* the opposite of replace_glyph() */voidrestore_glyph(encoding *enc, Font *fnt){ stringlist *sl; int i; for (sl = fnt->replacements; sl; sl = sl->next) { for (i = 0; i <= 0xFF; i++) { if (strcmp(enc->vec[i], sl->new_name) == 0) { enc->vec[i] = sl->old_name; goto success; } } warning("Glyph name `%s' not found in encoding.", sl->new_name); warning("Replacement for glyph name `%s' thus ignored.", sl->old_name);success: ; }}/* end */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -