diff --git a/stepmania/src/FontCharAliases.cpp b/stepmania/src/FontCharAliases.cpp new file mode 100644 index 0000000000..7ae349378b --- /dev/null +++ b/stepmania/src/FontCharAliases.cpp @@ -0,0 +1,310 @@ +#include "stdafx.h" +#include "FontCharAliases.h" +#include "Font.h" +#include "RageUtil.h" +#include "RageLog.h" + +#include + +/* Map from "&foo;" to a UTF-8 string. */ +typedef map aliasmap; +static aliasmap CharAliases; +static map CharAliasRepl; + +static void InitCharAliases() +{ + if(!CharAliases.empty()) + return; + + /* XXX at least move this to a separate file */ + + CharAliases["default"] = Font::DEFAULT_GLYPH; /* ? */ + CharAliases["invalid"] = INVALID_CHAR; /* 0xFFFF */ + + /* The comments here are UTF-8; they won't show up in VC6 (use your + * imagination). + * + * Kanji: + * + * I've chosen semi-arbitrary names for these kanji. Almost all have other + * readings. Some of the names are just words that use it (大きい -> ookii). + * A character can have more than one alias, but keep aliases separate so + * a list of all named kanji can be made without having to weed dupes. Avoid + * really short names; eg. let's save "me" for め if we make hiragana aliases. */ + CharAliases["kakumei1"] = 0x9769; /* 革 */ + CharAliases["kakumei2"] = 0x547D; /* 命 */ + CharAliases["matsuri"] = 0x796D; /* 祭 */ + CharAliases["sakura"] = 0x685C; /* 桜 */ + CharAliases["kosaka1"] = 0x5C0F; /* 小 */ + CharAliases["kosaka2"] = 0x5742; /* 坂 */ + CharAliases["oni"] = 0x9B3C; /* 鬼 */ + CharAliases["michi"] = 0x9053; /* 道 */ + CharAliases["futatsu"] = 0x5F10; /* 弐 */ + CharAliases["kami"] = 0x795E; /* 神 */ + CharAliases["sama"] = 0x69D8; /* 様 */ + CharAliases["minyou1"] = 0x6C11; /* 民 */ + CharAliases["minyou2"] = 0x8B21; /* 謡 */ + CharAliases["aka"] = 0x660E; /* 明 */ + CharAliases["nichi"] = 0x65E5; /* 日 */ + CharAliases["aoi"] = 0x9752; /* 青 */ + CharAliases["shoudou1"] = 0x885D; /* 衝 */ + CharAliases["shoudou2"] = 0x52D5; /* 動 */ + CharAliases["neko"] = 0x732B; /* 猫 */ + CharAliases["hair"] = 0x6BDB; /* 毛 */ + CharAliases["anettai1"] = 0x5E2F; /* 亜 */ + CharAliases["anettai2"] = 0x71B1; /* 熱 */ + CharAliases["anettai3"] = 0x4E9C; /* 帯 */ + CharAliases["bakudan1"] = 0x7206; /* 爆 */ + CharAliases["bakudan2"] = 0x5F3E; /* 弾 */ + CharAliases["shintani1"] = 0x8C37; /* 谷 */ + CharAliases["shintani2"] = 0x65B0; /* 新 */ + CharAliases["ookii"] = 0x5927; /* 大 */ + CharAliases["kenkai1"] = 0x898B; /* 見 */ + CharAliases["kenkai2"] = 0x89E3; /* 解 */ + CharAliases["mahou1"] = 0x9B54; /* 魔 */ + CharAliases["mahou2"] = 0x6CD5; /* 法 */ + CharAliases["tobira"] = 0x6249; /* 扉 */ + CharAliases["yozora1"] = 0x7A7A; /* 夜 */ + CharAliases["yozora2"] = 0x6249; /* 空 */ + + CharAliases["num-ichi"] = 0x4E00; /* 一 */ + CharAliases["num-ni"] = 0x4E01; /* 二 */ + CharAliases["num-san"] = 0x4E02; /* 三 */ + CharAliases["num-yon"] = 0x4E03; /* 四 */ + CharAliases["num-go"] = 0x4E04; /* 五 */ + CharAliases["num-roku"] = 0x4E05; /* 六 */ + CharAliases["num-nana"] = 0x4E06; /* 七 */ + CharAliases["num-hachi"] = 0x4E07; /* 八 */ + CharAliases["num-kyuu"] = 0x4E08; /* 九 */ + CharAliases["num-juu"] = 0x4E09; /* 十 */ + + /* Hiragana: */ + CharAliases["ha"] = 0x3042; /* あ */ + CharAliases["hi"] = 0x3044; /* い */ + CharAliases["hu"] = 0x3046; /* う */ + CharAliases["he"] = 0x3048; /* え */ + CharAliases["ho"] = 0x304a; /* お */ + CharAliases["hka"] = 0x304b; /* か */ + CharAliases["hki"] = 0x304d; /* き */ + CharAliases["hku"] = 0x304f; /* く */ + CharAliases["hke"] = 0x3051; /* け */ + CharAliases["hko"] = 0x3053; /* こ */ + CharAliases["hga"] = 0x304c; /* が */ + CharAliases["hgi"] = 0x304e; /* ぎ */ + CharAliases["hgu"] = 0x3050; /* ぐ */ + CharAliases["hge"] = 0x3052; /* げ */ + CharAliases["hgo"] = 0x3054; /* ご */ + CharAliases["hza"] = 0x3056; /* ざ */ + CharAliases["hzi"] = 0x3058; /* じ */ + CharAliases["hzu"] = 0x305a; /* ず */ + CharAliases["hze"] = 0x305c; /* ぜ */ + CharAliases["hzo"] = 0x305e; /* ぞ */ + CharAliases["hta"] = 0x305f; /* た */ + CharAliases["hti"] = 0x3061; /* ち */ + CharAliases["htu"] = 0x3064; /* つ */ + CharAliases["hte"] = 0x3066; /* て */ + CharAliases["hto"] = 0x3068; /* と */ + CharAliases["hda"] = 0x3060; /* だ */ + CharAliases["hdi"] = 0x3062; /* ぢ */ + CharAliases["hdu"] = 0x3065; /* づ */ + CharAliases["hde"] = 0x3067; /* で */ + CharAliases["hdo"] = 0x3069; /* ど */ + CharAliases["hna"] = 0x306a; /* な */ + CharAliases["hni"] = 0x306b; /* に */ + CharAliases["hnu"] = 0x306c; /* ぬ */ + CharAliases["hne"] = 0x306d; /* ね */ + CharAliases["hno"] = 0x306e; /* の */ + CharAliases["hha"] = 0x306f; /* は */ + CharAliases["hhi"] = 0x3072; /* ひ */ + CharAliases["hhu"] = 0x3075; /* ふ */ + CharAliases["hhe"] = 0x3078; /* へ */ + CharAliases["hho"] = 0x307b; /* ほ */ + CharAliases["hba"] = 0x3070; /* ば */ + CharAliases["hbi"] = 0x3073; /* び */ + CharAliases["hbu"] = 0x3076; /* ぶ */ + CharAliases["hbe"] = 0x3079; /* べ */ + CharAliases["hbo"] = 0x307c; /* ぼ */ + CharAliases["hpa"] = 0x3071; /* ぱ */ + CharAliases["hpi"] = 0x3074; /* ぴ */ + CharAliases["hpu"] = 0x3077; /* ぷ */ + CharAliases["hpe"] = 0x307a; /* ぺ */ + CharAliases["hpo"] = 0x307d; /* ぽ */ + CharAliases["hma"] = 0x307e; /* ま */ + CharAliases["hmi"] = 0x307f; /* み */ + CharAliases["hmu"] = 0x3080; /* む */ + CharAliases["hme"] = 0x3081; /* め */ + CharAliases["hmo"] = 0x3082; /* も */ + CharAliases["hya"] = 0x3084; /* や */ + CharAliases["hyu"] = 0x3086; /* ゆ */ + CharAliases["hyo"] = 0x3088; /* よ */ + CharAliases["hra"] = 0x3089; /* ら */ + CharAliases["hri"] = 0x308a; /* り */ + CharAliases["hru"] = 0x308b; /* る */ + CharAliases["hre"] = 0x308c; /* れ */ + CharAliases["hro"] = 0x308d; /* ろ */ + CharAliases["hwa"] = 0x308f; /* わ */ + CharAliases["hwi"] = 0x3090; /* ゐ */ + CharAliases["hwe"] = 0x3091; /* ゑ */ + CharAliases["hwo"] = 0x3092; /* を */ + CharAliases["hn"] = 0x3093; /* ん */ + CharAliases["hvu"] = 0x3094; /* ゔ */ + CharAliases["has"] = 0x3041; /* ぁ */ + CharAliases["his"] = 0x3043; /* ぃ */ + CharAliases["hus"] = 0x3045; /* ぅ */ + CharAliases["hes"] = 0x3047; /* ぇ */ + CharAliases["hos"] = 0x3049; /* ぉ */ + CharAliases["hkas"] = 0x3095; /* ゕ */ + CharAliases["hkes"] = 0x3096; /* ゖ */ + CharAliases["hsa"] = 0x3055; /* さ */ + CharAliases["hsi"] = 0x3057; /* し */ + CharAliases["hsu"] = 0x3059; /* す */ + CharAliases["hse"] = 0x305b; /* せ */ + CharAliases["hso"] = 0x305d; /* そ */ + CharAliases["hyas"] = 0x3083; /* ゃ */ + CharAliases["hyus"] = 0x3085; /* ゅ */ + CharAliases["hyos"] = 0x3087; /* ょ */ + CharAliases["hwas"] = 0x308e; /* ゎ */ + + /* Katakana: */ + CharAliases["hq"] = 0x3063; /* っ */ + CharAliases["ka"] = 0x30a2; /* ア */ + CharAliases["ki"] = 0x30a4; /* イ */ + CharAliases["ku"] = 0x30a6; /* ウ */ + CharAliases["ke"] = 0x30a8; /* エ */ + CharAliases["ko"] = 0x30aa; /* オ */ + CharAliases["kka"] = 0x30ab; /* カ */ + CharAliases["kki"] = 0x30ad; /* キ */ + CharAliases["kku"] = 0x30af; /* ク */ + CharAliases["kke"] = 0x30b1; /* ケ */ + CharAliases["kko"] = 0x30b3; /* コ */ + CharAliases["kga"] = 0x30ac; /* ガ */ + CharAliases["kgi"] = 0x30ae; /* ギ */ + CharAliases["kgu"] = 0x30b0; /* グ */ + CharAliases["kge"] = 0x30b2; /* ゲ */ + CharAliases["kgo"] = 0x30b4; /* ゴ */ + CharAliases["kza"] = 0x30b6; /* ザ */ + CharAliases["kzi"] = 0x30b8; /* ジ */ + CharAliases["kzu"] = 0x30ba; /* ズ */ + CharAliases["kze"] = 0x30bc; /* ゼ */ + CharAliases["kzo"] = 0x30be; /* ゾ */ + CharAliases["kta"] = 0x30bf; /* タ */ + CharAliases["kti"] = 0x30c1; /* チ */ + CharAliases["ktu"] = 0x30c4; /* ツ */ + CharAliases["kte"] = 0x30c6; /* テ */ + CharAliases["kto"] = 0x30c8; /* ト */ + CharAliases["kda"] = 0x30c0; /* ダ */ + CharAliases["kdi"] = 0x30c2; /* ヂ */ + CharAliases["kdu"] = 0x30c5; /* ヅ */ + CharAliases["kde"] = 0x30c7; /* デ */ + CharAliases["kdo"] = 0x30c9; /* ド */ + CharAliases["kna"] = 0x30ca; /* ナ */ + CharAliases["kni"] = 0x30cb; /* ニ */ + CharAliases["knu"] = 0x30cc; /* ヌ */ + CharAliases["kne"] = 0x30cd; /* ネ */ + CharAliases["kno"] = 0x30ce; /* ノ */ + CharAliases["kha"] = 0x30cf; /* ハ */ + CharAliases["khi"] = 0x30d2; /* ヒ */ + CharAliases["khu"] = 0x30d5; /* フ */ + CharAliases["khe"] = 0x30d8; /* ヘ */ + CharAliases["kho"] = 0x30db; /* ホ */ + CharAliases["kba"] = 0x30d0; /* バ */ + CharAliases["kbi"] = 0x30d3; /* ビ */ + CharAliases["kbu"] = 0x30d6; /* ブ */ + CharAliases["kbe"] = 0x30d9; /* ベ */ + CharAliases["kbo"] = 0x30dc; /* ボ */ + CharAliases["kpa"] = 0x30d1; /* パ */ + CharAliases["kpi"] = 0x30d4; /* ピ */ + CharAliases["kpu"] = 0x30d7; /* プ */ + CharAliases["kpe"] = 0x30da; /* ペ */ + CharAliases["kpo"] = 0x30dd; /* ポ */ + CharAliases["kma"] = 0x30de; /* マ */ + CharAliases["kmi"] = 0x30df; /* ミ */ + CharAliases["kmu"] = 0x30e0; /* ム */ + CharAliases["kme"] = 0x30e1; /* メ */ + CharAliases["kmo"] = 0x30e2; /* モ */ + CharAliases["kya"] = 0x30e4; /* ヤ */ + CharAliases["kyu"] = 0x30e6; /* ユ */ + CharAliases["kyo"] = 0x30e8; /* ヨ */ + CharAliases["kra"] = 0x30e9; /* ラ */ + CharAliases["kri"] = 0x30ea; /* リ */ + CharAliases["kru"] = 0x30eb; /* ル */ + CharAliases["kre"] = 0x30ec; /* レ */ + CharAliases["kro"] = 0x30ed; /* ロ */ + CharAliases["kwa"] = 0x30ef; /* ワ */ + CharAliases["kwi"] = 0x30f0; /* ヰ */ + CharAliases["kwe"] = 0x30f1; /* ヱ */ + CharAliases["kwo"] = 0x30f2; /* ヲ */ + CharAliases["kn"] = 0x30f3; /* ン */ + CharAliases["kvu"] = 0x30f4; /* ヴ */ + CharAliases["kas"] = 0x30a1; /* ァ */ + CharAliases["kis"] = 0x30a3; /* ィ */ + CharAliases["kus"] = 0x30a5; /* ゥ */ + CharAliases["kes"] = 0x30a7; /* ェ */ + CharAliases["kos"] = 0x30a9; /* ォ */ + CharAliases["kkas"] = 0x30f5; /* ヵ */ + CharAliases["kkes"] = 0x30f6; /* ヶ */ + CharAliases["ksa"] = 0x30b5; /* サ */ + CharAliases["ksi"] = 0x30b7; /* シ */ + CharAliases["ksu"] = 0x30b9; /* ス */ + CharAliases["kse"] = 0x30bb; /* セ */ + CharAliases["kso"] = 0x30bd; /* ソ */ + CharAliases["kyas"] = 0x30e3; /* ャ */ + CharAliases["kyus"] = 0x30e5; /* ュ */ + CharAliases["kyos"] = 0x30e7; /* ョ */ + CharAliases["kwas"] = 0x30ee; /* ヮ */ + CharAliases["kq"] = 0x30c3; /* ッ */ + + CharAliases["kdot"] = 0x30FB; /* ・ */ + CharAliases["kdash"]= 0x30FC; /* ー */ + + /* Symbols: */ + CharAliases["omega"] = 0x03a9; /* Ω */ + CharAliases["whiteheart"] = 0x2661; /* ♡ */ + CharAliases["blackstar"] = 0x2605; /* ★ */ + CharAliases["whitestar"] = 0x2606; /* ☆ */ + CharAliases["flipped-a"] = 0x2200; /* ∀ */ + CharAliases["squared"] = 0x00b2; /* ² */ + CharAliases["cubed"] = 0x00b3; /* ³ */ + CharAliases["oq"] = 0x201c; /* “ */ + CharAliases["cq"] = 0x201d; /* ” */ + + /* These are internal-use glyphs; they don't have real Unicode codepoints. */ + CharAliases["up"] = 0xE000; + CharAliases["down"] = 0xE001; + CharAliases["left"] = 0xE002; + CharAliases["right"] = 0xE003; + CharAliases["menuup"] = 0xE004; + CharAliases["menudown"] = 0xE005; + CharAliases["menuleft"] = 0xE006; + CharAliases["menuright"] = 0xE007; + CharAliases["start"] = 0xE008; + + for(aliasmap::const_iterator i = CharAliases.begin(); i != CharAliases.end(); ++i) + { + CString from = ssprintf("&%s;", i->first.GetString()); + CString to = LcharToUTF8(i->second); + from.MakeUpper(); + CharAliasRepl[from] = to; + LOG->Trace("from '%s' to '%s'", from.GetString(), to.GetString()); + } +} + +/* Replace all &markers; and &#NNNN;s with UTF-8. I'm not really + * sure where to put this; this is used elsewhere, too. */ +void FontCharAliases::ReplaceMarkers( CString &sText ) +{ + InitCharAliases(); + ReplaceText(sText, CharAliasRepl); + Replace_Unicode_Markers(sText); +} + +/* Replace all &markers; and &#NNNN;s with UTF-8. */ +longchar FontCharAliases::GetChar( CString &codepoint ) +{ + InitCharAliases(); + aliasmap::const_iterator i = CharAliases.find(codepoint); + if(i == CharAliases.end()) + return longchar(-1); + + return i->second; +} diff --git a/stepmania/src/FontCharAliases.h b/stepmania/src/FontCharAliases.h new file mode 100644 index 0000000000..057157d823 --- /dev/null +++ b/stepmania/src/FontCharAliases.h @@ -0,0 +1,11 @@ +#ifndef FONT_CHAR_ALIASES +#define FONT_CHAR_ALIASES + +#include "RageUtil.h" + +namespace FontCharAliases { + void ReplaceMarkers( CString &sText ); + longchar GetChar( CString &codepoint ); +}; + +#endif diff --git a/stepmania/src/FontCharmaps.cpp b/stepmania/src/FontCharmaps.cpp new file mode 100644 index 0000000000..67e9b5bcdb --- /dev/null +++ b/stepmania/src/FontCharmaps.cpp @@ -0,0 +1,140 @@ +#include "stdafx.h" +#include "FontCharmaps.h" + +#include + +const wchar_t FontCharmaps::M_SKIP = 0xFEFF; + +static map charmaps; + +using namespace FontCharmaps; + +/* Map ranges of Unicode characters. This is for font mapping; don't try + * to use it for actual conversion (if that's wanted, use iconv). + * + * Use M_SKIP to indicate that a glyph should be skipped, not mapped. Do + * this to skip control codes, for example, while keeping glyphs aligned. */ + +/* Good old-fashioned ASCII. */ +static const wchar_t map_ascii[] = { + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, M_SKIP, + 0 +}; + +/* ISO-8859-1 (Latin1): West Europe, US, others: */ +static const wchar_t map_iso_8859_1[] = { + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, + 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, + 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, + 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, + 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, + 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff, + 0 +}; + +/* Windows codepage 1252; latin1 plus other stuff (including angled quotes): */ +static const wchar_t map_cp1252[] = { + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, M_SKIP, + 0x20AC, M_SKIP, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, M_SKIP, 0x017D, M_SKIP, + M_SKIP, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x017E, M_SKIP, 0x0178, + 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, + 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, + 0 +}; + +/* ISO-8859-2: ISO-8859-2: (cs), Hungarian (hu), Polish (pl), Romanian (ro), Croatian (hr), + * Slovak (sk), Slovenian (sl), Sorbian. */ +static const wchar_t map_iso_8859_2[] = { + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, M_SKIP, + 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, + 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, + 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, + 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, + 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, + 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9, + 0 +}; + +/* Unicode range 30: CJK Symbols and Punctuation, Hiragana, Katakana */ +static const wchar_t map_basic_japanese[] = +{ + 0x3000,0x3001,0x3002,0x3003,0x3004,0x3005,0x3006,0x3007,0x3008,0x3009,0x300a,0x300b,0x300c,0x300d,0x300e,0x300f, + 0x3010,0x3011,0x3012,0x3013,0x3014,0x3015,0x3016,0x3017,0x3018,0x3019,0x301a,0x301b,0x301c,0x301d,0x301e,0x301f, + 0x3020,0x3021,0x3022,0x3023,0x3024,0x3025,0x3026,0x3027,0x3028,0x3029,0x302a,0x302b,0x302c,0x302d,0x302e,0x302f, + 0x3030,0x3031,0x3032,0x3033,0x3034,0x3035,0x3036,0x3037,0x3038,0x3039,0x303a,0x303b,0x303c,0x303d,0x303e,0x303f, + 0x3040,0x3041,0x3042,0x3043,0x3044,0x3045,0x3046,0x3047,0x3048,0x3049,0x304a,0x304b,0x304c,0x304d,0x304e,0x304f, + 0x3050,0x3051,0x3052,0x3053,0x3054,0x3055,0x3056,0x3057,0x3058,0x3059,0x305a,0x305b,0x305c,0x305d,0x305e,0x305f, + 0x3060,0x3061,0x3062,0x3063,0x3064,0x3065,0x3066,0x3067,0x3068,0x3069,0x306a,0x306b,0x306c,0x306d,0x306e,0x306f, + 0x3070,0x3071,0x3072,0x3073,0x3074,0x3075,0x3076,0x3077,0x3078,0x3079,0x307a,0x307b,0x307c,0x307d,0x307e,0x307f, + 0x3080,0x3081,0x3082,0x3083,0x3084,0x3085,0x3086,0x3087,0x3088,0x3089,0x308a,0x308b,0x308c,0x308d,0x308e,0x308f, + 0x3090,0x3091,0x3092,0x3093,0x3094,0x3095,0x3096,0x3097,0x3098,0x3099,0x309a,0x309b,0x309c,0x309d,0x309e,0x309f, + 0x30a0,0x30a1,0x30a2,0x30a3,0x30a4,0x30a5,0x30a6,0x30a7,0x30a8,0x30a9,0x30aa,0x30ab,0x30ac,0x30ad,0x30ae,0x30af, + 0x30b0,0x30b1,0x30b2,0x30b3,0x30b4,0x30b5,0x30b6,0x30b7,0x30b8,0x30b9,0x30ba,0x30bb,0x30bc,0x30bd,0x30be,0x30bf, + 0x30c0,0x30c1,0x30c2,0x30c3,0x30c4,0x30c5,0x30c6,0x30c7,0x30c8,0x30c9,0x30ca,0x30cb,0x30cc,0x30cd,0x30ce,0x30cf, + 0x30d0,0x30d1,0x30d2,0x30d3,0x30d4,0x30d5,0x30d6,0x30d7,0x30d8,0x30d9,0x30da,0x30db,0x30dc,0x30dd,0x30de,0x30df, + 0x30e0,0x30e1,0x30e2,0x30e3,0x30e4,0x30e5,0x30e6,0x30e7,0x30e8,0x30e9,0x30ea,0x30eb,0x30ec,0x30ed,0x30ee,0x30ef, + 0x30f0,0x30f1,0x30f2,0x30f3,0x30f4,0x30f5,0x30f6,0x30f7,0x30f8,0x30f9,0x30fa,0x30fb,0x30fc,0x30fd,0x30fe,0x30ff, + 0 +}; + +static void Init() +{ + if(!charmaps.empty()) + return; + + charmaps["ascii"] = map_ascii; + charmaps["basic-japanese"] = map_basic_japanese; + charmaps["iso-8859-1"] = map_iso_8859_1; + charmaps["cp1252"] = map_cp1252; + charmaps["iso-8859-2"] = map_iso_8859_2; +} + +const wchar_t *FontCharmaps::get_char_map(CString name) +{ + Init(); + + name.MakeLower(); + + map::const_iterator i = charmaps.find(name); + if(i == charmaps.end()) + return NULL; + + return i->second; +} diff --git a/stepmania/src/FontCharmaps.h b/stepmania/src/FontCharmaps.h new file mode 100644 index 0000000000..c78a14a249 --- /dev/null +++ b/stepmania/src/FontCharmaps.h @@ -0,0 +1,10 @@ +#ifndef FONT_CHARMAPS_H +#define FONT_CHARMAPS_H + +namespace FontCharmaps +{ + extern const wchar_t M_SKIP; + const wchar_t *get_char_map(CString name); +}; + +#endif