refactor: Update Unity to 2022.3.62

This commit is contained in:
2025-06-21 01:22:02 +08:00
parent d71bf7d4a5
commit 283783954f
112 changed files with 778 additions and 907 deletions

View File

@@ -16,13 +16,11 @@ namespace Cryville.Common.Font {
}
public void Close() { Reader.Close(); }
public static FontFile Create(FileInfo file) {
switch (file.Extension) {
case ".ttf": case ".otf": return new FontFileTTF(file);
case ".ttc": case ".otc": return new FontFileTTC(file);
default: return null;
}
}
public static FontFile Create(FileInfo file) => file.Extension switch {
".ttf" or ".otf" => new FontFileTTF(file),
".ttc" or ".otc" => new FontFileTTC(file),
_ => null,
};
public Enumerator GetEnumerator() {
return new Enumerator(this);
@@ -42,7 +40,7 @@ namespace Cryville.Common.Font {
_index = -1;
}
public Typeface Current {
public readonly Typeface Current {
get {
if (_index < 0)
throw new InvalidOperationException(_index == -1 ? "Enum not started" : "Enum ended");
@@ -50,7 +48,7 @@ namespace Cryville.Common.Font {
}
}
object IEnumerator.Current { get { return Current; } }
readonly object IEnumerator.Current => Current;
public void Dispose() {
_index = -2;

View File

@@ -17,8 +17,7 @@ namespace Cryville.Common.Font {
Shared.Logger.Log(3, "UI", "Discarding a font with a duplicate full name {0}", f.FullName);
continue;
}
List<Typeface> set2;
if (!map2.TryGetValue(f.FamilyName, out set2)) {
if (!map2.TryGetValue(f.FamilyName, out List<Typeface> set2)) {
map2.Add(f.FamilyName, set2 = new List<Typeface>());
}
set2.Add(f);

View File

@@ -12,7 +12,7 @@ namespace Cryville.Common.Font {
public class FallbackListFontMatcher : FontMatcher {
readonly LanguageMatching _matcher;
static readonly string UltimateFallbackScript = "zzzz";
public Dictionary<string, List<string>> MapScriptToTypefaces = new Dictionary<string, List<string>>();
public Dictionary<string, List<string>> MapScriptToTypefaces = new();
public static Dictionary<string, List<string>> GetDefaultWindowsFallbackMap() {
var map = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
FillKeysWithScripts(map, () => new List<string>());
@@ -333,8 +333,7 @@ namespace Cryville.Common.Font {
yield return typeface1;
}
if (distinctFamily) continue;
IReadOnlyCollection<Typeface> typefaces2;
if (Manager.MapNameToTypefaces.TryGetValue(candidate, out typefaces2)) {
if (Manager.MapNameToTypefaces.TryGetValue(candidate, out IReadOnlyCollection<Typeface> typefaces2)) {
foreach (var typeface in typefaces2) {
if (typeface1 == typeface) continue;
yield return typeface;

View File

@@ -25,7 +25,7 @@ namespace Cryville.Common.Font {
readonly UInt16 majorVersion;
readonly UInt16 minorVersion;
readonly UInt32 numFonts;
readonly List<UInt32> tableDirectoryOffsets = new List<UInt32>();
readonly List<UInt32> tableDirectoryOffsets = new();
#pragma warning disable IDE0052 // Reserved
readonly String dsigTag;
readonly UInt32 dsigLength;
@@ -61,7 +61,7 @@ namespace Cryville.Common.Font {
readonly UInt16 entrySelector;
readonly UInt16 rangeShift;
#pragma warning restore IDE0052 // Reserved
readonly List<TableRecord> tableRecords = new List<TableRecord>();
readonly List<TableRecord> tableRecords = new();
public TableDirectory(BinaryReader reader, UInt32 offset) : base(reader, offset) {
sfntVersion = reader.ReadUInt32();
if (sfntVersion != 0x00010000 && sfntVersion != 0x4F54544F &&
@@ -81,13 +81,11 @@ namespace Cryville.Common.Font {
public override IReadOnlyList<TableRecord> GetItems() {
return tableRecords;
}
public override object GetSubTable(TableRecord item) {
switch (item.tableTag) {
case "name": return new NameTable(Reader, item.offset);
case "meta": return new MetaTable(Reader, item.offset);
default: throw new NotImplementedException();
}
}
public override object GetSubTable(TableRecord item) => item.tableTag switch {
"name" => new NameTable(Reader, item.offset),
"meta" => new MetaTable(Reader, item.offset),
_ => throw new NotImplementedException(),
};
}
public struct TableRecord {
public string tableTag;
@@ -99,9 +97,9 @@ namespace Cryville.Common.Font {
readonly UInt16 version;
readonly UInt16 count;
readonly UInt16 storageOffset;
readonly List<NameRecord> nameRecord = new List<NameRecord>();
readonly List<NameRecord> nameRecord = new();
readonly UInt16 langTagCount;
readonly List<LangTagRecord> langTagRecord = new List<LangTagRecord>();
readonly List<LangTagRecord> langTagRecord = new();
public NameTable(BinaryReader reader, UInt32 offset) : base(reader, offset) {
version = reader.ReadUInt16();
count = reader.ReadUInt16();
@@ -213,7 +211,7 @@ namespace Cryville.Common.Font {
readonly UInt32 flags;
#pragma warning restore IDE0052 // Reserved
readonly UInt32 dataMapCount;
readonly List<DataMap> dataMaps = new List<DataMap>();
readonly List<DataMap> dataMaps = new();
public MetaTable(BinaryReader reader, UInt32 offset) : base(reader, offset) {
version = reader.ReadUInt32();
if (version != 1) throw new NotSupportedException();