Code cleanup.

This commit is contained in:
2023-06-22 13:18:34 +08:00
parent 22cb8f0cb4
commit a7aff4d625
8 changed files with 321 additions and 302 deletions

View File

@@ -11,290 +11,290 @@ namespace Cryville.Common.Font {
}
public class FallbackListFontMatcher : FontMatcher {
public Dictionary<string, List<string>> MapScriptToTypefaces = new Dictionary<string, List<string>>();
public void LoadDefaultWindowsFallbackList() {
if (Environment.OSVersion.Platform != PlatformID.Win32NT) return;
MapScriptToTypefaces.Clear();
ScriptUtils.FillKeysWithScripts(MapScriptToTypefaces, () => new List<string>());
public static Dictionary<string, List<string>> GetDefaultWindowsFallbackMap() {
var map = new Dictionary<string, List<string>>();
ScriptUtils.FillKeysWithScripts(map, () => new List<string>());
// Reference: https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/platform/fonts/win/font_fallback_win.cc
MapScriptToTypefaces["zyyy"].Insert(0, "SimSun"); // Custom
MapScriptToTypefaces["zyyy"].Insert(0, "SimHei"); // Custom
MapScriptToTypefaces["zyyy"].Insert(0, "Microsoft YaHei"); // Custom
MapScriptToTypefaces["zyyy"].Insert(0, "Arial");
MapScriptToTypefaces["zyyy"].Insert(0, "Times New Roman");
MapScriptToTypefaces["zyyy"].Insert(0, "Segoe UI"); // Custom
MapScriptToTypefaces["arab"].Insert(0, "Tahoma");
MapScriptToTypefaces["cyrl"].Insert(0, "Times New Roman");
MapScriptToTypefaces["grek"].Insert(0, "Times New Roman");
MapScriptToTypefaces["hebr"].Insert(0, "David");
MapScriptToTypefaces["jpan"].Insert(0, "MS PGothic");
MapScriptToTypefaces["latn"].Insert(0, "Times New Roman");
MapScriptToTypefaces["hans"].Insert(0, "SimSun");
MapScriptToTypefaces["hans"].Insert(0, "SimHei"); // Custom
MapScriptToTypefaces["thai"].Insert(0, "Tahoma");
MapScriptToTypefaces["hans"].Insert(0, "PMingLiU");
map["zyyy"].Insert(0, "SimSun"); // Custom
map["zyyy"].Insert(0, "SimHei"); // Custom
map["zyyy"].Insert(0, "Microsoft YaHei"); // Custom
map["zyyy"].Insert(0, "Arial");
map["zyyy"].Insert(0, "Times New Roman");
map["zyyy"].Insert(0, "Segoe UI"); // Custom
map["arab"].Insert(0, "Tahoma");
map["cyrl"].Insert(0, "Times New Roman");
map["grek"].Insert(0, "Times New Roman");
map["hebr"].Insert(0, "David");
map["jpan"].Insert(0, "MS PGothic");
map["latn"].Insert(0, "Times New Roman");
map["hans"].Insert(0, "SimSun");
map["hans"].Insert(0, "SimHei"); // Custom
map["thai"].Insert(0, "Tahoma");
map["hans"].Insert(0, "PMingLiU");
// Reference: https://learn.microsoft.com/en-us/globalization/input/font-support
var ver = Environment.OSVersion.Version;
if (ver >= new Version(5, 0)) { // Windows 2000
MapScriptToTypefaces["armn"].Insert(0, "Sylfaen");
MapScriptToTypefaces["deva"].Insert(0, "Mangal");
MapScriptToTypefaces["geor"].Insert(0, "Sylfaen");
MapScriptToTypefaces["taml"].Insert(0, "Latha");
map["armn"].Insert(0, "Sylfaen");
map["deva"].Insert(0, "Mangal");
map["geor"].Insert(0, "Sylfaen");
map["taml"].Insert(0, "Latha");
}
if (ver >= new Version(5, 1)) { // Windows XP
MapScriptToTypefaces["gujr"].Insert(0, "Shruti");
MapScriptToTypefaces["guru"].Insert(0, "Raavi");
MapScriptToTypefaces["knda"].Insert(0, "Tunga");
MapScriptToTypefaces["syrc"].Insert(0, "Estrangelo Edessa");
MapScriptToTypefaces["telu"].Insert(0, "Gautami");
MapScriptToTypefaces["thaa"].Insert(0, "MV Boli");
map["gujr"].Insert(0, "Shruti");
map["guru"].Insert(0, "Raavi");
map["knda"].Insert(0, "Tunga");
map["syrc"].Insert(0, "Estrangelo Edessa");
map["telu"].Insert(0, "Gautami");
map["thaa"].Insert(0, "MV Boli");
// SP2
MapScriptToTypefaces["beng"].Insert(0, "Vrinda");
MapScriptToTypefaces["mlym"].Insert(0, "Kartika");
map["beng"].Insert(0, "Vrinda");
map["mlym"].Insert(0, "Kartika");
}
if (ver >= new Version(6, 0)) { // Windows Vista
MapScriptToTypefaces["cans"].Insert(0, "Euphemia");
MapScriptToTypefaces["cher"].Insert(0, "Plantagenet");
MapScriptToTypefaces["ethi"].Insert(0, "Nyala");
MapScriptToTypefaces["khmr"].Insert(0, "DaunPenh MoolBoran");
MapScriptToTypefaces["laoo"].Insert(0, "DokChampa");
MapScriptToTypefaces["mong"].Insert(0, "Mongolian Baiti");
MapScriptToTypefaces["orya"].Insert(0, "Kalinga");
MapScriptToTypefaces["sinh"].Insert(0, "Iskoola Pota");
MapScriptToTypefaces["tibt"].Insert(0, "Microsoft Himalaya");
MapScriptToTypefaces["yiii"].Insert(0, "Microsoft Yi Baiti");
MapScriptToTypefaces["arab"].Insert(0, "Segoe UI");
MapScriptToTypefaces["cyrl"].Insert(0, "Segoe UI");
MapScriptToTypefaces["grek"].Insert(0, "Segoe UI");
MapScriptToTypefaces["latn"].Insert(0, "Segoe UI");
MapScriptToTypefaces["hans"].Add("SimSun-ExtB");
MapScriptToTypefaces["hant"].Add("MingLiU-ExtB");
MapScriptToTypefaces["hant"].Add("MingLiU_HKSCS-ExtB");
MapScriptToTypefaces["arab"].Add("Microsoft Uighur");
MapScriptToTypefaces["zmth"].Insert(0, "Cambria Math");
map["cans"].Insert(0, "Euphemia");
map["cher"].Insert(0, "Plantagenet");
map["ethi"].Insert(0, "Nyala");
map["khmr"].Insert(0, "DaunPenh MoolBoran");
map["laoo"].Insert(0, "DokChampa");
map["mong"].Insert(0, "Mongolian Baiti");
map["orya"].Insert(0, "Kalinga");
map["sinh"].Insert(0, "Iskoola Pota");
map["tibt"].Insert(0, "Microsoft Himalaya");
map["yiii"].Insert(0, "Microsoft Yi Baiti");
map["arab"].Insert(0, "Segoe UI");
map["cyrl"].Insert(0, "Segoe UI");
map["grek"].Insert(0, "Segoe UI");
map["latn"].Insert(0, "Segoe UI");
map["hans"].Add("SimSun-ExtB");
map["hant"].Add("MingLiU-ExtB");
map["hant"].Add("MingLiU_HKSCS-ExtB");
map["arab"].Add("Microsoft Uighur");
map["zmth"].Insert(0, "Cambria Math");
// Reference: https://en.wikipedia.org/wiki/List_of_CJK_fonts
MapScriptToTypefaces["jpan"].Insert(0, "Meiryo");
MapScriptToTypefaces["hans"].Insert(0, "Microsoft YaHei");
map["jpan"].Insert(0, "Meiryo");
map["hans"].Insert(0, "Microsoft YaHei");
}
if (ver >= new Version(6, 1)) { // Windows 7
MapScriptToTypefaces["brai"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["dsrt"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["talu"].Insert(0, "Microsoft New Tai Lue");
MapScriptToTypefaces["ogam"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["osma"].Insert(0, "Ebrima");
MapScriptToTypefaces["phag"].Insert(0, "Microsoft PhagsPa");
MapScriptToTypefaces["runr"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["zsym"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["tale"].Insert(0, "Microsoft Tai Le");
MapScriptToTypefaces["tfng"].Insert(0, "Ebrima");
MapScriptToTypefaces["vaii"].Insert(0, "Ebrima");
map["brai"].Insert(0, "Segoe UI Symbol");
map["dsrt"].Insert(0, "Segoe UI Symbol");
map["talu"].Insert(0, "Microsoft New Tai Lue");
map["ogam"].Insert(0, "Segoe UI Symbol");
map["osma"].Insert(0, "Ebrima");
map["phag"].Insert(0, "Microsoft PhagsPa");
map["runr"].Insert(0, "Segoe UI Symbol");
map["zsym"].Insert(0, "Segoe UI Symbol");
map["tale"].Insert(0, "Microsoft Tai Le");
map["tfng"].Insert(0, "Ebrima");
map["vaii"].Insert(0, "Ebrima");
}
if (ver >= new Version(6, 2)) { // Windows 8
MapScriptToTypefaces["glag"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["goth"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["hang"].Add("Malgun Gothic");
MapScriptToTypefaces["ital"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["lisu"].Insert(0, "Segoe UI");
MapScriptToTypefaces["mymr"].Insert(0, "Myanmar Text");
MapScriptToTypefaces["nkoo"].Insert(0, "Ebrima");
MapScriptToTypefaces["orkh"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["ethi"].Insert(0, "Ebrima");
MapScriptToTypefaces["cans"].Insert(0, "Gadugi");
MapScriptToTypefaces["hant"].Insert(0, "Microsoft JhengHei UI");
MapScriptToTypefaces["hans"].Insert(0, "Microsoft YaHei UI");
MapScriptToTypefaces["beng"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["deva"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["gujr"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["guru"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
MapScriptToTypefaces["knda"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
MapScriptToTypefaces["mlym"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["orya"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["sinh"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
MapScriptToTypefaces["taml"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
MapScriptToTypefaces["telu"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["armn"].Insert(0, "Segoe UI");
MapScriptToTypefaces["geor"].Insert(0, "Segoe UI");
MapScriptToTypefaces["hebr"].Insert(0, "Segoe UI");
map["glag"].Insert(0, "Segoe UI Symbol");
map["goth"].Insert(0, "Segoe UI Symbol");
map["hang"].Add("Malgun Gothic");
map["ital"].Insert(0, "Segoe UI Symbol");
map["lisu"].Insert(0, "Segoe UI");
map["mymr"].Insert(0, "Myanmar Text");
map["nkoo"].Insert(0, "Ebrima");
map["orkh"].Insert(0, "Segoe UI Symbol");
map["ethi"].Insert(0, "Ebrima");
map["cans"].Insert(0, "Gadugi");
map["hant"].Insert(0, "Microsoft JhengHei UI");
map["hans"].Insert(0, "Microsoft YaHei UI");
map["beng"].Insert(0, "Nirmala UI");
map["deva"].Insert(0, "Nirmala UI");
map["gujr"].Insert(0, "Nirmala UI");
map["guru"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
map["knda"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
map["mlym"].Insert(0, "Nirmala UI");
map["orya"].Insert(0, "Nirmala UI");
map["sinh"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
map["taml"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
map["telu"].Insert(0, "Nirmala UI");
map["armn"].Insert(0, "Segoe UI");
map["geor"].Insert(0, "Segoe UI");
map["hebr"].Insert(0, "Segoe UI");
}
if (ver >= new Version(6, 3)) { // Windows 8.1
MapScriptToTypefaces["bugi"].Insert(0, "Leelawadee UI");
MapScriptToTypefaces["copt"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["java"].Insert(0, "Javanese Text");
MapScriptToTypefaces["merc"].Insert(0, "Segoe UI Symbol");
MapScriptToTypefaces["olck"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["sora"].Insert(0, "Nirmala UI");
MapScriptToTypefaces["khmr"].Insert(0, "Leelawadee UI");
MapScriptToTypefaces["laoo"].Insert(0, "Leelawadee UI");
MapScriptToTypefaces["thai"].Insert(0, "Leelawadee UI");
MapScriptToTypefaces["zsye"].Insert(0, "Segoe UI Emoji");
map["bugi"].Insert(0, "Leelawadee UI");
map["copt"].Insert(0, "Segoe UI Symbol");
map["java"].Insert(0, "Javanese Text");
map["merc"].Insert(0, "Segoe UI Symbol");
map["olck"].Insert(0, "Nirmala UI");
map["sora"].Insert(0, "Nirmala UI");
map["khmr"].Insert(0, "Leelawadee UI");
map["laoo"].Insert(0, "Leelawadee UI");
map["thai"].Insert(0, "Leelawadee UI");
map["zsye"].Insert(0, "Segoe UI Emoji");
}
if (ver >= new Version(10, 0)) { // Windows 10
MapScriptToTypefaces["brah"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["cari"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["cprt"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["egyp"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["armi"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["phli"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["prti"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["khar"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["lyci"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["lydi"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["phnx"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["xpeo"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["sarb"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["shaw"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["xsux"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["ugar"].Insert(0, "Segoe UI Historic");
map["brah"].Insert(0, "Segoe UI Historic");
map["cari"].Insert(0, "Segoe UI Historic");
map["cprt"].Insert(0, "Segoe UI Historic");
map["egyp"].Insert(0, "Segoe UI Historic");
map["armi"].Insert(0, "Segoe UI Historic");
map["phli"].Insert(0, "Segoe UI Historic");
map["prti"].Insert(0, "Segoe UI Historic");
map["khar"].Insert(0, "Segoe UI Historic");
map["lyci"].Insert(0, "Segoe UI Historic");
map["lydi"].Insert(0, "Segoe UI Historic");
map["phnx"].Insert(0, "Segoe UI Historic");
map["xpeo"].Insert(0, "Segoe UI Historic");
map["sarb"].Insert(0, "Segoe UI Historic");
map["shaw"].Insert(0, "Segoe UI Historic");
map["xsux"].Insert(0, "Segoe UI Historic");
map["ugar"].Insert(0, "Segoe UI Historic");
// Segoe UI Symbol -> Segoe UI Historic
MapScriptToTypefaces["glag"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["goth"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["merc"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["ogam"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["ital"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["orkh"].Insert(0, "Segoe UI Historic");
MapScriptToTypefaces["runr"].Insert(0, "Segoe UI Historic");
map["glag"].Insert(0, "Segoe UI Historic");
map["goth"].Insert(0, "Segoe UI Historic");
map["merc"].Insert(0, "Segoe UI Historic");
map["ogam"].Insert(0, "Segoe UI Historic");
map["ital"].Insert(0, "Segoe UI Historic");
map["orkh"].Insert(0, "Segoe UI Historic");
map["runr"].Insert(0, "Segoe UI Historic");
//
MapScriptToTypefaces["jpan"].Insert(0, "Yu Gothic UI");
MapScriptToTypefaces["zsym"].Add("Segoe MDL2 Assets");
map["jpan"].Insert(0, "Yu Gothic UI");
map["zsym"].Add("Segoe MDL2 Assets");
}
return map;
}
public void LoadDefaultAndroidFallbackList() {
if (Environment.OSVersion.Platform != PlatformID.Unix) return;
MapScriptToTypefaces.Clear();
ScriptUtils.FillKeysWithScripts(MapScriptToTypefaces, () => new List<string>());
MapScriptToTypefaces["zyyy"].Insert(0, "Noto Sans CJK TC"); // TODO Modify default fallback
MapScriptToTypefaces["zyyy"].Insert(0, "Noto Sans CJK JP");
MapScriptToTypefaces["zyyy"].Insert(0, "Noto Sans CJK SC");
MapScriptToTypefaces["zyyy"].Insert(0, "Roboto");
MapScriptToTypefaces["zsye"].Insert(0, "Noto Color Emoji");
MapScriptToTypefaces["zsye"].Add("Noto Color Emoji Flags");
MapScriptToTypefaces["arab"].Insert(0, "Noto Naskh Arabic");
MapScriptToTypefaces["adlm"].Insert(0, "Noto Sans Adlam");
MapScriptToTypefaces["ahom"].Insert(0, "Noto Sans Ahom");
MapScriptToTypefaces["hluw"].Insert(0, "Noto Sans Anatolian Hieroglyphs");
MapScriptToTypefaces["armn"].Insert(0, "Noto Sans Armenian");
MapScriptToTypefaces["avst"].Insert(0, "Noto Sans Avestan");
MapScriptToTypefaces["bali"].Insert(0, "Noto Sans Balinese");
MapScriptToTypefaces["bamu"].Insert(0, "Noto Sans Bamum");
MapScriptToTypefaces["bass"].Insert(0, "Noto Sans Bassa Vah");
MapScriptToTypefaces["batk"].Insert(0, "Noto Sans Batak");
MapScriptToTypefaces["beng"].Insert(0, "Noto Sans Bengali");
MapScriptToTypefaces["bhks"].Insert(0, "Noto Sans Bhaiksuki");
MapScriptToTypefaces["brah"].Insert(0, "Noto Sans Brahmi");
MapScriptToTypefaces["bugi"].Insert(0, "Noto Sans Buginese");
MapScriptToTypefaces["buhd"].Insert(0, "Noto Sans Buhid");
MapScriptToTypefaces["jpan"].Insert(0, "Noto Sans CJK JP");
MapScriptToTypefaces["kore"].Insert(0, "Noto Sans CJK KR");
MapScriptToTypefaces["hans"].Insert(0, "Noto Sans CJK SC");
MapScriptToTypefaces["hant"].Insert(0, "Noto Sans CJK TC");
MapScriptToTypefaces["hant"].Add("Noto Sans CJK HK");
MapScriptToTypefaces["cans"].Insert(0, "Noto Sans Canadian Aboriginal");
MapScriptToTypefaces["cari"].Insert(0, "Noto Sans Carian");
MapScriptToTypefaces["cakm"].Insert(0, "Noto Sans Chakma");
MapScriptToTypefaces["cham"].Insert(0, "Noto Sans Cham");
MapScriptToTypefaces["cher"].Insert(0, "Noto Sans Cherokee");
MapScriptToTypefaces["copt"].Insert(0, "Noto Sans Coptic");
MapScriptToTypefaces["xsux"].Insert(0, "Noto Sans Cuneiform");
MapScriptToTypefaces["cprt"].Insert(0, "Noto Sans Cypriot");
MapScriptToTypefaces["dsrt"].Insert(0, "Noto Sans Deseret");
MapScriptToTypefaces["deva"].Insert(0, "Noto Sans Devanagari");
MapScriptToTypefaces["egyp"].Insert(0, "Noto Sans Egyptian Hieroglyphs");
MapScriptToTypefaces["elba"].Insert(0, "Noto Sans Elbasan");
MapScriptToTypefaces["ethi"].Insert(0, "Noto Sans Ethiopic");
MapScriptToTypefaces["geor"].Insert(0, "Noto Sans Georgian");
MapScriptToTypefaces["glag"].Insert(0, "Noto Sans Glagolitic");
MapScriptToTypefaces["goth"].Insert(0, "Noto Sans Gothic");
MapScriptToTypefaces["gran"].Insert(0, "Noto Sans Grantha");
MapScriptToTypefaces["gujr"].Insert(0, "Noto Sans Gujarati");
MapScriptToTypefaces["gong"].Insert(0, "Noto Sans Gunjala Gondi");
MapScriptToTypefaces["guru"].Insert(0, "Noto Sans Gurmukhi");
MapScriptToTypefaces["rohg"].Insert(0, "Noto Sans Hanifi Rohingya");
MapScriptToTypefaces["hano"].Insert(0, "Noto Sans Hanunoo");
MapScriptToTypefaces["hatr"].Insert(0, "Noto Sans Hatran");
MapScriptToTypefaces["hebr"].Insert(0, "Noto Sans Hebrew");
MapScriptToTypefaces["armi"].Insert(0, "Noto Sans Imperial Aramaic");
MapScriptToTypefaces["phli"].Insert(0, "Noto Sans Inscriptional Pahlavi");
MapScriptToTypefaces["prti"].Insert(0, "Noto Sans Inscriptional Parthian");
MapScriptToTypefaces["java"].Insert(0, "Noto Sans Javanese");
MapScriptToTypefaces["kthi"].Insert(0, "Noto Sans Kaithi");
MapScriptToTypefaces["knda"].Insert(0, "Noto Sans Kannada");
MapScriptToTypefaces["kali"].Insert(0, "Noto Sans KayahLi");
MapScriptToTypefaces["khar"].Insert(0, "Noto Sans Kharoshthi");
MapScriptToTypefaces["khmr"].Insert(0, "Noto Sans Khmer");
MapScriptToTypefaces["khoj"].Insert(0, "Noto Sans Khojki");
MapScriptToTypefaces["laoo"].Insert(0, "Noto Sans Lao");
MapScriptToTypefaces["lepc"].Insert(0, "Noto Sans Lepcha");
MapScriptToTypefaces["limb"].Insert(0, "Noto Sans Limbu");
MapScriptToTypefaces["lina"].Insert(0, "Noto Sans Linear A");
MapScriptToTypefaces["linb"].Insert(0, "Noto Sans Linear B");
MapScriptToTypefaces["lisu"].Insert(0, "Noto Sans Lisu");
MapScriptToTypefaces["lyci"].Insert(0, "Noto Sans Lycian");
MapScriptToTypefaces["lydi"].Insert(0, "Noto Sans Lydian");
MapScriptToTypefaces["mlym"].Insert(0, "Noto Sans Malayalam");
MapScriptToTypefaces["mand"].Insert(0, "Noto Sans Mandiac");
MapScriptToTypefaces["mani"].Insert(0, "Noto Sans Manichaean");
MapScriptToTypefaces["marc"].Insert(0, "Noto Sans Marchen");
MapScriptToTypefaces["gonm"].Insert(0, "Noto Sans Masaram Gondi");
MapScriptToTypefaces["medf"].Insert(0, "Noto Sans Medefaidrin");
MapScriptToTypefaces["mtei"].Insert(0, "Noto Sans Meetei Mayek");
MapScriptToTypefaces["merc"].Insert(0, "Noto Sans Meroitic");
MapScriptToTypefaces["mero"].Insert(0, "Noto Sans Meroitic");
MapScriptToTypefaces["plrd"].Insert(0, "Noto Sans Miao");
MapScriptToTypefaces["modi"].Insert(0, "Noto Sans Modi");
MapScriptToTypefaces["mong"].Insert(0, "Noto Sans Mongolian");
MapScriptToTypefaces["mroo"].Insert(0, "Noto Sans Mro");
MapScriptToTypefaces["mult"].Insert(0, "Noto Sans Multani");
MapScriptToTypefaces["mymr"].Insert(0, "Noto Sans Myanmar");
MapScriptToTypefaces["nkoo"].Insert(0, "Noto Sans Nko");
MapScriptToTypefaces["nbat"].Insert(0, "Noto Sans Nabataean");
MapScriptToTypefaces["talu"].Insert(0, "Noto Sans New Tai Lue");
MapScriptToTypefaces["newa"].Insert(0, "Noto Sans Newa");
MapScriptToTypefaces["ogam"].Insert(0, "Noto Sans Ogham");
MapScriptToTypefaces["olck"].Insert(0, "Noto Sans Ol Chiki");
MapScriptToTypefaces["ital"].Insert(0, "Noto Sans Old Italian");
MapScriptToTypefaces["narb"].Insert(0, "Noto Sans Old North Arabian");
MapScriptToTypefaces["perm"].Insert(0, "Noto Sans Old Permic");
MapScriptToTypefaces["xpeo"].Insert(0, "Noto Sans Old Persian");
MapScriptToTypefaces["sarb"].Insert(0, "Noto Sans Old South Arabian");
MapScriptToTypefaces["orkh"].Insert(0, "Noto Sans Old Turkic");
MapScriptToTypefaces["orya"].Insert(0, "Noto Sans Oriya");
MapScriptToTypefaces["osge"].Insert(0, "Noto Sans Osage");
MapScriptToTypefaces["osma"].Insert(0, "Noto Sans Osmanya");
MapScriptToTypefaces["hmng"].Insert(0, "Noto Sans Pahawh Hmong");
MapScriptToTypefaces["palm"].Insert(0, "Noto Sans Palmyrene");
MapScriptToTypefaces["pauc"].Insert(0, "Noto Sans Pau Cin Hau");
MapScriptToTypefaces["phag"].Insert(0, "Noto Sans Phags Pa");
MapScriptToTypefaces["phnx"].Insert(0, "Noto Sans Phoenician");
MapScriptToTypefaces["rjng"].Insert(0, "Noto Sans Rejang");
MapScriptToTypefaces["runr"].Insert(0, "Noto Sans Runic");
MapScriptToTypefaces["samr"].Insert(0, "Noto Sans Samaritan");
MapScriptToTypefaces["saur"].Insert(0, "Noto Sans Saurashtra");
MapScriptToTypefaces["shrd"].Insert(0, "Noto Sans Sharada");
MapScriptToTypefaces["shaw"].Insert(0, "Noto Sans Shavian");
MapScriptToTypefaces["sinh"].Insert(0, "Noto Sans Sinhala");
MapScriptToTypefaces["sora"].Insert(0, "Noto Sans Sora Sompeng");
MapScriptToTypefaces["soyo"].Insert(0, "Noto Sans Soyombo");
MapScriptToTypefaces["sund"].Insert(0, "Noto Sans Sundanese");
MapScriptToTypefaces["sylo"].Insert(0, "Noto Sans Syloti Nagri");
MapScriptToTypefaces["zsym"].Insert(0, "Noto Sans Symbols");
MapScriptToTypefaces["syrn"].Insert(0, "Noto Sans Syriac Eastern");
MapScriptToTypefaces["syre"].Insert(0, "Noto Sans Syriac Estrangela");
MapScriptToTypefaces["syrj"].Insert(0, "Noto Sans Syriac Western");
MapScriptToTypefaces["tglg"].Insert(0, "Noto Sans Tagalog");
MapScriptToTypefaces["tagb"].Insert(0, "Noto Sans Tagbanwa");
MapScriptToTypefaces["tale"].Insert(0, "Noto Sans Tai Le");
MapScriptToTypefaces["lana"].Insert(0, "Noto Sans Tai Tham");
MapScriptToTypefaces["tavt"].Insert(0, "Noto Sans Tai Viet");
MapScriptToTypefaces["takr"].Insert(0, "Noto Sans Takri");
MapScriptToTypefaces["taml"].Insert(0, "Noto Sans Tamil");
MapScriptToTypefaces["telu"].Insert(0, "Noto Sans Telugu");
MapScriptToTypefaces["thaa"].Insert(0, "Noto Sans Thaana");
MapScriptToTypefaces["thai"].Insert(0, "Noto Sans Thai");
MapScriptToTypefaces["tfng"].Insert(0, "Noto Sans Tifinagh");
MapScriptToTypefaces["ugar"].Insert(0, "Noto Sans Ugaritic");
MapScriptToTypefaces["vaii"].Insert(0, "Noto Sans Vai");
MapScriptToTypefaces["wcho"].Insert(0, "Noto Sans Wancho");
MapScriptToTypefaces["wara"].Insert(0, "Noto Sans Warang Citi");
MapScriptToTypefaces["yiii"].Insert(0, "Noto Sans Yi");
public static Dictionary<string, List<string>> GetDefaultAndroidFallbackMap() {
var map = new Dictionary<string, List<string>>();
ScriptUtils.FillKeysWithScripts(map, () => new List<string>());
map["zyyy"].Insert(0, "Noto Sans CJK TC"); // TODO Modify default fallback
map["zyyy"].Insert(0, "Noto Sans CJK JP");
map["zyyy"].Insert(0, "Noto Sans CJK SC");
map["zyyy"].Insert(0, "Roboto");
map["zsye"].Insert(0, "Noto Color Emoji");
map["zsye"].Add("Noto Color Emoji Flags");
map["arab"].Insert(0, "Noto Naskh Arabic");
map["adlm"].Insert(0, "Noto Sans Adlam");
map["ahom"].Insert(0, "Noto Sans Ahom");
map["hluw"].Insert(0, "Noto Sans Anatolian Hieroglyphs");
map["armn"].Insert(0, "Noto Sans Armenian");
map["avst"].Insert(0, "Noto Sans Avestan");
map["bali"].Insert(0, "Noto Sans Balinese");
map["bamu"].Insert(0, "Noto Sans Bamum");
map["bass"].Insert(0, "Noto Sans Bassa Vah");
map["batk"].Insert(0, "Noto Sans Batak");
map["beng"].Insert(0, "Noto Sans Bengali");
map["bhks"].Insert(0, "Noto Sans Bhaiksuki");
map["brah"].Insert(0, "Noto Sans Brahmi");
map["bugi"].Insert(0, "Noto Sans Buginese");
map["buhd"].Insert(0, "Noto Sans Buhid");
map["jpan"].Insert(0, "Noto Sans CJK JP");
map["kore"].Insert(0, "Noto Sans CJK KR");
map["hans"].Insert(0, "Noto Sans CJK SC");
map["hant"].Insert(0, "Noto Sans CJK TC");
map["hant"].Add("Noto Sans CJK HK");
map["cans"].Insert(0, "Noto Sans Canadian Aboriginal");
map["cari"].Insert(0, "Noto Sans Carian");
map["cakm"].Insert(0, "Noto Sans Chakma");
map["cham"].Insert(0, "Noto Sans Cham");
map["cher"].Insert(0, "Noto Sans Cherokee");
map["copt"].Insert(0, "Noto Sans Coptic");
map["xsux"].Insert(0, "Noto Sans Cuneiform");
map["cprt"].Insert(0, "Noto Sans Cypriot");
map["dsrt"].Insert(0, "Noto Sans Deseret");
map["deva"].Insert(0, "Noto Sans Devanagari");
map["egyp"].Insert(0, "Noto Sans Egyptian Hieroglyphs");
map["elba"].Insert(0, "Noto Sans Elbasan");
map["ethi"].Insert(0, "Noto Sans Ethiopic");
map["geor"].Insert(0, "Noto Sans Georgian");
map["glag"].Insert(0, "Noto Sans Glagolitic");
map["goth"].Insert(0, "Noto Sans Gothic");
map["gran"].Insert(0, "Noto Sans Grantha");
map["gujr"].Insert(0, "Noto Sans Gujarati");
map["gong"].Insert(0, "Noto Sans Gunjala Gondi");
map["guru"].Insert(0, "Noto Sans Gurmukhi");
map["rohg"].Insert(0, "Noto Sans Hanifi Rohingya");
map["hano"].Insert(0, "Noto Sans Hanunoo");
map["hatr"].Insert(0, "Noto Sans Hatran");
map["hebr"].Insert(0, "Noto Sans Hebrew");
map["armi"].Insert(0, "Noto Sans Imperial Aramaic");
map["phli"].Insert(0, "Noto Sans Inscriptional Pahlavi");
map["prti"].Insert(0, "Noto Sans Inscriptional Parthian");
map["java"].Insert(0, "Noto Sans Javanese");
map["kthi"].Insert(0, "Noto Sans Kaithi");
map["knda"].Insert(0, "Noto Sans Kannada");
map["kali"].Insert(0, "Noto Sans KayahLi");
map["khar"].Insert(0, "Noto Sans Kharoshthi");
map["khmr"].Insert(0, "Noto Sans Khmer");
map["khoj"].Insert(0, "Noto Sans Khojki");
map["laoo"].Insert(0, "Noto Sans Lao");
map["lepc"].Insert(0, "Noto Sans Lepcha");
map["limb"].Insert(0, "Noto Sans Limbu");
map["lina"].Insert(0, "Noto Sans Linear A");
map["linb"].Insert(0, "Noto Sans Linear B");
map["lisu"].Insert(0, "Noto Sans Lisu");
map["lyci"].Insert(0, "Noto Sans Lycian");
map["lydi"].Insert(0, "Noto Sans Lydian");
map["mlym"].Insert(0, "Noto Sans Malayalam");
map["mand"].Insert(0, "Noto Sans Mandiac");
map["mani"].Insert(0, "Noto Sans Manichaean");
map["marc"].Insert(0, "Noto Sans Marchen");
map["gonm"].Insert(0, "Noto Sans Masaram Gondi");
map["medf"].Insert(0, "Noto Sans Medefaidrin");
map["mtei"].Insert(0, "Noto Sans Meetei Mayek");
map["merc"].Insert(0, "Noto Sans Meroitic");
map["mero"].Insert(0, "Noto Sans Meroitic");
map["plrd"].Insert(0, "Noto Sans Miao");
map["modi"].Insert(0, "Noto Sans Modi");
map["mong"].Insert(0, "Noto Sans Mongolian");
map["mroo"].Insert(0, "Noto Sans Mro");
map["mult"].Insert(0, "Noto Sans Multani");
map["mymr"].Insert(0, "Noto Sans Myanmar");
map["nkoo"].Insert(0, "Noto Sans Nko");
map["nbat"].Insert(0, "Noto Sans Nabataean");
map["talu"].Insert(0, "Noto Sans New Tai Lue");
map["newa"].Insert(0, "Noto Sans Newa");
map["ogam"].Insert(0, "Noto Sans Ogham");
map["olck"].Insert(0, "Noto Sans Ol Chiki");
map["ital"].Insert(0, "Noto Sans Old Italian");
map["narb"].Insert(0, "Noto Sans Old North Arabian");
map["perm"].Insert(0, "Noto Sans Old Permic");
map["xpeo"].Insert(0, "Noto Sans Old Persian");
map["sarb"].Insert(0, "Noto Sans Old South Arabian");
map["orkh"].Insert(0, "Noto Sans Old Turkic");
map["orya"].Insert(0, "Noto Sans Oriya");
map["osge"].Insert(0, "Noto Sans Osage");
map["osma"].Insert(0, "Noto Sans Osmanya");
map["hmng"].Insert(0, "Noto Sans Pahawh Hmong");
map["palm"].Insert(0, "Noto Sans Palmyrene");
map["pauc"].Insert(0, "Noto Sans Pau Cin Hau");
map["phag"].Insert(0, "Noto Sans Phags Pa");
map["phnx"].Insert(0, "Noto Sans Phoenician");
map["rjng"].Insert(0, "Noto Sans Rejang");
map["runr"].Insert(0, "Noto Sans Runic");
map["samr"].Insert(0, "Noto Sans Samaritan");
map["saur"].Insert(0, "Noto Sans Saurashtra");
map["shrd"].Insert(0, "Noto Sans Sharada");
map["shaw"].Insert(0, "Noto Sans Shavian");
map["sinh"].Insert(0, "Noto Sans Sinhala");
map["sora"].Insert(0, "Noto Sans Sora Sompeng");
map["soyo"].Insert(0, "Noto Sans Soyombo");
map["sund"].Insert(0, "Noto Sans Sundanese");
map["sylo"].Insert(0, "Noto Sans Syloti Nagri");
map["zsym"].Insert(0, "Noto Sans Symbols");
map["syrn"].Insert(0, "Noto Sans Syriac Eastern");
map["syre"].Insert(0, "Noto Sans Syriac Estrangela");
map["syrj"].Insert(0, "Noto Sans Syriac Western");
map["tglg"].Insert(0, "Noto Sans Tagalog");
map["tagb"].Insert(0, "Noto Sans Tagbanwa");
map["tale"].Insert(0, "Noto Sans Tai Le");
map["lana"].Insert(0, "Noto Sans Tai Tham");
map["tavt"].Insert(0, "Noto Sans Tai Viet");
map["takr"].Insert(0, "Noto Sans Takri");
map["taml"].Insert(0, "Noto Sans Tamil");
map["telu"].Insert(0, "Noto Sans Telugu");
map["thaa"].Insert(0, "Noto Sans Thaana");
map["thai"].Insert(0, "Noto Sans Thai");
map["tfng"].Insert(0, "Noto Sans Tifinagh");
map["ugar"].Insert(0, "Noto Sans Ugaritic");
map["vaii"].Insert(0, "Noto Sans Vai");
map["wcho"].Insert(0, "Noto Sans Wancho");
map["wara"].Insert(0, "Noto Sans Warang Citi");
map["yiii"].Insert(0, "Noto Sans Yi");
return map;
}
public FallbackListFontMatcher(FontManager manager) : base(manager) { }
public override IEnumerable<Typeface> MatchScript(string script = null, bool distinctFamily = false) {

View File

@@ -66,7 +66,7 @@ namespace Cryville.Crtr.Browsing {
var coverFile = item.GetFiles(meta.cover);
if (coverFile.Length > 0) {
cover = new AsyncDelivery<Texture2D>();
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
cover.CancelSource = task.Cancel;
Game.NetworkTaskWorker.SubmitNetworkTask(task);
}
@@ -93,7 +93,7 @@ namespace Cryville.Crtr.Browsing {
var coverFile = item.GetFiles(meta.cover);
if (coverFile.Length > 0) {
cover = new AsyncDelivery<Texture2D>();
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
cover.CancelSource = task.Cancel;
Game.NetworkTaskWorker.SubmitNetworkTask(task);
}

View File

@@ -1,5 +1,3 @@
#define BUILD
using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Crtr.Config;
@@ -82,7 +80,6 @@ namespace Cryville.Crtr {
status = GameObject.Find("Status").GetComponent<TextMeshProUGUI>();
#if BUILD
try {
Play();
}
@@ -91,7 +88,6 @@ namespace Cryville.Crtr {
Popup.CreateException(ex);
ReturnToMenu();
}
#endif
// Camera.main.RenderToCubemap();
}
@@ -186,9 +182,7 @@ namespace Cryville.Crtr {
Logger.Log("main", 4, "Load/MainThread", "Load failed");
loadThread = null;
Popup.CreateException(threadException);
#if BUILD
ReturnToMenu();
#endif
}
else if (texloaddone) {
if (texLoader == null) Stop();
@@ -377,7 +371,7 @@ namespace Cryville.Crtr {
areaJudgePrecision = 1 << Settings.Default.AreaJudgePrecision;
forceSyncFrames = Settings.Default.ForceSyncFrames;
texloaddone = false;
Game.NetworkTaskWorker.SuspendBackgroundTasks();
Game.SuspendBackgroundTasks();
Game.AudioSession = Game.AudioSequencer.NewSession();
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
@@ -455,7 +449,7 @@ namespace Cryville.Crtr {
for (int i = 0; i < queue.Count; i++) {
#if UNITY_5_4_OR_NEWER
texHandler = new DownloadHandlerTexture();
texLoader = new UnityWebRequest(Game.FileProtocolPrefix + queue[i], "GET", texHandler, null);
texLoader = new UnityWebRequest(PlatformConfig.FileProtocolPrefix + queue[i], "GET", texHandler, null);
texLoader.SendWebRequest();
#else
texLoader = new WWW(Game.FileProtocolPrefix + queue[i]);
@@ -568,10 +562,8 @@ namespace Cryville.Crtr {
started = false;
}
}
Game.NetworkTaskWorker.ResumeBackgroundTasks();
#if BUILD
Game.ResumeBackgroundTasks();
ReturnToMenu();
#endif
}
void OnSettingsUpdate() {
@@ -588,11 +580,9 @@ namespace Cryville.Crtr {
}
Exception threadException;
#if !NO_THREAD
Thread loadThread = null;
volatile float loadPregress;
Stopwatch workerTimer;
#endif
void Load(object _info) {
var info = (LoadInfo)_info;
try {

View File

@@ -22,14 +22,6 @@ namespace Cryville.Crtr {
get;
private set;
}
public static readonly string FileProtocolPrefix
#if UNITY_STANDALONE_WIN
= "file:///";
#elif UNITY_ANDROID
= "file://";
#else
#error No file protocol prefix is defined.
#endif
public static IAudioDeviceManager AudioManager;
public static AudioClient AudioClient;
public static SimpleSequencerSource AudioSequencer;
@@ -129,19 +121,10 @@ namespace Cryville.Crtr {
Settings.Default.Save();
Logger.Log("main", 1, "UI", "Initializing font manager");
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
var fontMatcher = new FallbackListFontMatcher(new FontManagerWindows());
fontMatcher.LoadDefaultWindowsFallbackList();
TMPAutoFont.FontMatcher = fontMatcher;
TMPAutoFont.DefaultShader = Resources.Load<Shader>("TextMesh Pro/Shaders/TMP_SDF SSD");
#elif UNITY_ANDROID
var fontMatcher = new FallbackListFontMatcher(new FontManagerAndroid());
fontMatcher.LoadDefaultAndroidFallbackList();
TMPAutoFont.FontMatcher = fontMatcher;
TMPAutoFont.DefaultShader = Resources.Load<Shader>("TextMesh Pro/Shaders/TMP_SDF-Mobile SSD");
#else
#error No font manager initialization logic.
#endif
TMPAutoFont.FontMatcher = new FallbackListFontMatcher(PlatformConfig.FontManager) {
MapScriptToTypefaces = PlatformConfig.ScriptFontMap
};
TMPAutoFont.DefaultShader = Resources.Load<Shader>(PlatformConfig.TextShader);
Logger.Log("main", 1, "Game", "Initialized");
}
@@ -181,5 +164,14 @@ namespace Cryville.Crtr {
}
Logger.Log("main", l, "Internal", "{0}\n{1}", condition, stackTrace);
}
public static void SuspendBackgroundTasks() {
NetworkTaskWorker.SuspendBackgroundTasks();
Dialog.Suppress();
}
public static void ResumeBackgroundTasks() {
Dialog.Release();
NetworkTaskWorker.ResumeBackgroundTasks();
}
}
}

View File

@@ -262,10 +262,9 @@ namespace Cryville.Crtr {
frame.Vector = vec;
}
else frame = rc.InverseTransform(frame);
bool locked = false;
Monitor.Enter(_etor);
try {
Profiler.BeginSample("InputProxy.OnInput");
Monitor.Enter(_etor, ref locked);
InputProxyEntry proxy;
if (_sproxies.TryGetValue(id.Source, out proxy)) {
float ft, tt = (float)GetSyncedTime(frame.Time, id.Source.Handler);
@@ -289,8 +288,8 @@ namespace Cryville.Crtr {
}
}
finally {
if (locked) Monitor.Exit(_etor);
Profiler.EndSample();
Monitor.Exit(_etor);
}
}
static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from");

View File

@@ -58,7 +58,7 @@ namespace Cryville.Crtr {
void OnEnable() {
Application.targetFrameRate = 60;
if (animatorState != null) m_targetAnimator.PlayInFixedTime(animatorState, 0, 0);
Game.NetworkTaskWorker.ResumeBackgroundTasks();
Game.ResumeBackgroundTasks();
}
#pragma warning restore IDE0051

View File

@@ -0,0 +1,27 @@
using Cryville.Common.Font;
using System.Collections.Generic;
namespace Cryville.Crtr {
internal static class PlatformConfig {
#if UNITY_STANDALONE_WIN
public static readonly string Name = "windows";
#elif UNITY_ANDROID
public static readonly string Name = "android";
#else
#error Unknown platform.
#endif
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
public static readonly string FileProtocolPrefix = "file:///";
public static readonly FontManager FontManager = new FontManagerWindows();
public static readonly Dictionary<string, List<string>> ScriptFontMap = FallbackListFontMatcher.GetDefaultWindowsFallbackMap();
public static readonly string TextShader = "TextMesh Pro/Shaders/TMP_SDF SSD";
#elif UNITY_ANDROID
public static readonly string FileProtocolPrefix = "file://";
public static readonly FontManager FontManager = new FontManagerAndroid();
public static readonly Dictionary<string, List<string>> ScriptFontMap = FallbackListFontMatcher.GetDefaultAndroidFallbackMap();
public static readonly string TextShader = "TextMesh Pro/Shaders/TMP_SDF-Mobile SSD";
#else
#error Unknown platform.
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5b9be7f84b72ac9468dacec2d44003a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: