2 * Copyright (c) 2003 Ben Harris
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * macenc.c -- Convert a Mac OS script/region/font combination to our
28 * internal charset code.
37 * These are defined by Mac OS's <Script.h>, but we'd like to be
38 * independent of that.
43 #define smTradChinese 2
48 #define smDevenagari 9
52 #define smSimpChinese 25
55 #define smCentralEuroRoman 29
60 #define verYugoCroatian 25
62 #define verFaroeIsl 47
65 #define verSlovenian 66
67 #define verBulgaria 72
68 #define verScottishGaelic 75
69 #define verManxGaelic 76
73 #define verIrishGaelicScript 81
82 { smRoman, -1, 0x850, "VT100", CS_MAC_VT100 },
83 { smRoman, -1, 0, "VT100", CS_MAC_VT100_OLD },
85 * From here on, this table is largely derived from
86 * <http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/README.TXT>,
87 * with _OLD version added based on the comments in individual
90 { smRoman, -1, 0, "Symbol", CS_MAC_SYMBOL },
91 { smRoman, -1, 0, "Zapf Dingbats", CS_MAC_DINGBATS },
92 { smRoman, verTurkey, 0, NULL, CS_MAC_TURKISH },
93 { smRoman, verYugoCroatian, 0x850, NULL, CS_MAC_CROATIAN },
94 { smRoman, verYugoCroatian, 0, NULL, CS_MAC_CROATIAN_OLD },
95 { smRoman, verSlovenian, 0x850, NULL, CS_MAC_CROATIAN },
96 { smRoman, verSlovenian, 0, NULL, CS_MAC_CROATIAN_OLD },
97 { smRoman, verCroatia, 0x850, NULL, CS_MAC_CROATIAN },
98 { smRoman, verCroatia, 0, NULL, CS_MAC_CROATIAN_OLD },
99 { smRoman, verIceland, 0x850, NULL, CS_MAC_ICELAND },
100 { smRoman, verIceland, 0, NULL, CS_MAC_ICELAND_OLD },
101 { smRoman, verFaroeIsl, 0x850, NULL, CS_MAC_ICELAND },
102 { smRoman, verFaroeIsl, 0, NULL, CS_MAC_ICELAND_OLD },
103 { smRoman, verRomania, 0x850, NULL, CS_MAC_ROMANIAN },
104 { smRoman, verRomania, 0, NULL, CS_MAC_ROMANIAN_OLD },
105 #if 0 /* No mapping table on ftp.unicode.org */
106 { smRoman, verIreland, 0x850, NULL, CS_MAC_CELTIC },
107 { smRoman, verIreland, 0, NULL, CS_MAC_CELTIC_OLD },
108 { smRoman, verScottishGaelic, 0x850, NULL, CS_MAC_CELTIC },
109 { smRoman, verScottishGaelic, 0, NULL, CS_MAC_CELTIC_OLD },
110 { smRoman, verManxGaelic, 0x850, NULL, CS_MAC_CELTIC },
111 { smRoman, verManxGaelic, 0, NULL, CS_MAC_CELTIC_OLD },
112 { smRoman, verBreton, 0x850, NULL, CS_MAC_CELTIC },
113 { smRoman, verBreton, 0, NULL, CS_MAC_CELTIC_OLD },
114 { smRoman, verWelsh, 0x850, NULL, CS_MAC_CELTIC },
115 { smRoman, verWelsh, 0, NULL, CS_MAC_CELTIC_OLD },
116 { smRoman, verIrishGaelicScript, 0x850, NULL, CS_MAC_GAELIC },
117 { smRoman, verIrishGaelicScript, 0, NULL, CS_MAC_GAELIC_OLD },
119 { smRoman, verGreece, 0x922, NULL, CS_MAC_GREEK },
120 { smRoman, verGreece, 0, NULL, CS_MAC_GREEK_OLD },
121 { smRoman, -1, 0x850, NULL, CS_MAC_ROMAN },
122 { smRoman, -1, 0, NULL, CS_MAC_ROMAN_OLD },
123 #if 0 /* Multi-byte encodings, not yet supported */
124 { smJapanese, -1, 0, NULL, CS_MAC_JAPANESE },
125 { smTradChinese, -1, 0, NULL, CS_MAC_CHINTRAD },
126 { smKorean, -1, 0, NULL, CS_MAC_KOREAN },
128 #if 0 /* Bidirectional encodings, not yet supported */
129 { smArabic, verIran, 0, NULL, CS_MAC_FARSI },
130 { smArabic, -1, 0, NULL, CS_MAC_ARABIC },
131 { smHebrew, -1, 0, NULL, CS_MAC_HEBREW },
133 { smCyrillic, -1, 0x900, NULL, CS_MAC_CYRILLIC },
134 { smCyrillic, verRussia, 0, NULL, CS_MAC_CYRILLIC_OLD },
135 { smCyrillic, verBulgaria, 0, NULL, CS_MAC_CYRILLIC_OLD },
136 { smCyrillic, -1, 0, NULL, CS_MAC_UKRAINE },
137 #if 0 /* Complex Indic scripts, not yet supported */
138 { smDevanagari, -1, 0, NULL, CS_MAC_DEVENAGA },
139 { smGurmukhi, -1, 0, NULL, CS_MAC_GURMUKHI },
140 { smGujurati, -1, 0, NULL, CS_MAC_GUJURATI },
142 { smThai, -1, 0, NULL, CS_MAC_THAI },
143 #if 0 /* Multi-byte encoding, not yet supported */
144 { smSimpChinese, -1, 0, NULL, CS_MAC_CHINSIMP },
146 #if 0 /* No mapping table on ftp.unicode.org */
147 { smTibetan, -1, 0, NULL, CS_MAC_TIBETAN },
148 { smEthiopic, -1, 0, NULL, CS_MAC_ETHIOPIC },
149 { smEthiopic, verNanavut, 0, NULL, CS_MAC_INUIT },
151 { smCentralEuroRoman, -1, 0, NULL, CS_MAC_CENTEURO },
154 int charset_from_macenc(int script, int region, int sysvers,
155 char const *fontname)
159 for (i = 0; i < (int)lenof(macencs); i++)
160 if ((macencs[i].script == script) &&
161 (macencs[i].region < 0 || macencs[i].region == region) &&
162 (macencs[i].sysvermin <= sysvers) &&
163 (macencs[i].fontname == NULL ||
164 (fontname != NULL && strcmp(macencs[i].fontname, fontname) == 0)))
165 return macencs[i].charset;