Update fallback script.

This commit is contained in:
2023-11-03 00:25:49 +08:00
parent 08a12097a4
commit b672889008

View File

@@ -12,18 +12,18 @@ namespace Cryville.Common.Font {
} }
public class FallbackListFontMatcher : FontMatcher { public class FallbackListFontMatcher : FontMatcher {
readonly LanguageMatching _matcher; readonly LanguageMatching _matcher;
static readonly string UltimateFallbackScript = "zyyy"; static readonly string UltimateFallbackScript = "zzzz";
public Dictionary<string, List<string>> MapScriptToTypefaces = new Dictionary<string, List<string>>(); public Dictionary<string, List<string>> MapScriptToTypefaces = new Dictionary<string, List<string>>();
public static Dictionary<string, List<string>> GetDefaultWindowsFallbackMap() { public static Dictionary<string, List<string>> GetDefaultWindowsFallbackMap() {
var map = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase); var map = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
FillKeysWithScripts(map, () => new List<string>()); FillKeysWithScripts(map, () => new List<string>());
// Reference: https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/platform/fonts/win/font_fallback_win.cc // Reference: https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/platform/fonts/win/font_fallback_win.cc
map["zyyy"].Insert(0, "SimSun"); // Custom map[UltimateFallbackScript].Insert(0, "SimSun"); // Custom
map["zyyy"].Insert(0, "SimHei"); // Custom map[UltimateFallbackScript].Insert(0, "SimHei"); // Custom
map["zyyy"].Insert(0, "Microsoft YaHei"); // Custom map[UltimateFallbackScript].Insert(0, "Microsoft YaHei"); // Custom
map["zyyy"].Insert(0, "Arial"); map[UltimateFallbackScript].Insert(0, "Arial");
map["zyyy"].Insert(0, "Times New Roman"); map[UltimateFallbackScript].Insert(0, "Times New Roman");
map["zyyy"].Insert(0, "Segoe UI"); // Custom map[UltimateFallbackScript].Insert(0, "Segoe UI"); // Custom
map["arab"].Insert(0, "Tahoma"); map["arab"].Insert(0, "Tahoma");
map["cyrl"].Insert(0, "Times New Roman"); map["cyrl"].Insert(0, "Times New Roman");
map["grek"].Insert(0, "Times New Roman"); map["grek"].Insert(0, "Times New Roman");
@@ -163,10 +163,10 @@ namespace Cryville.Common.Font {
public static Dictionary<string, List<string>> GetDefaultAndroidFallbackMap() { public static Dictionary<string, List<string>> GetDefaultAndroidFallbackMap() {
var map = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase); var map = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
FillKeysWithScripts(map, () => new List<string>()); FillKeysWithScripts(map, () => new List<string>());
map["zyyy"].Insert(0, "Noto Sans CJK TC"); // TODO Modify default fallback map[UltimateFallbackScript].Insert(0, "Noto Sans CJK TC"); // TODO Modify default fallback
map["zyyy"].Insert(0, "Noto Sans CJK JP"); map[UltimateFallbackScript].Insert(0, "Noto Sans CJK JP");
map["zyyy"].Insert(0, "Noto Sans CJK SC"); map[UltimateFallbackScript].Insert(0, "Noto Sans CJK SC");
map["zyyy"].Insert(0, "Roboto"); map[UltimateFallbackScript].Insert(0, "Roboto");
map["zsye"].Insert(0, "Noto Color Emoji"); map["zsye"].Insert(0, "Noto Color Emoji");
map["zsye"].Add("Noto Color Emoji Flags"); map["zsye"].Add("Noto Color Emoji Flags");
map["arab"].Insert(0, "Noto Naskh Arabic"); map["arab"].Insert(0, "Noto Naskh Arabic");