A game about forced loneliness, made by TACStudios
at master 107 lines 3.4 kB view raw
1using System; 2using UnityEngine; 3 4#pragma warning disable CS0660, CS0661 5 6namespace TMPro 7{ 8 /// <summary> 9 /// The SingleSubstitutionRecord defines the substitution of a single glyph by another. 10 /// </summary> 11 [Serializable] 12 public struct SingleSubstitutionRecord 13 { 14 // 15 } 16 17 /// <summary> 18 /// The MultipleSubstitutionRecord defines the substitution of a single glyph by multiple glyphs. 19 /// </summary> 20 [Serializable] 21 public struct MultipleSubstitutionRecord 22 { 23 /// <summary> 24 /// The index of the target glyph being substituted. 25 /// </summary> 26 public uint targetGlyphID { get { return m_TargetGlyphID; } set { m_TargetGlyphID = value; } } 27 28 /// <summary> 29 /// Array that contains the index of the glyphs replacing the single target glyph. 30 /// </summary> 31 public uint[] substituteGlyphIDs { get { return m_SubstituteGlyphIDs; } set { m_SubstituteGlyphIDs = value; } } 32 33 // ============================================= 34 // Private backing fields for public properties. 35 // ============================================= 36 37 [SerializeField] 38 private uint m_TargetGlyphID; 39 40 [SerializeField] 41 private uint[] m_SubstituteGlyphIDs; 42 } 43 44 /// <summary> 45 /// The AlternateSubstitutionRecord defines the substitution of a single glyph by several potential alternative glyphs. 46 /// </summary> 47 [Serializable] 48 public struct AlternateSubstitutionRecord 49 { 50 51 } 52 53 /// <summary> 54 /// The LigatureSubstitutionRecord defines the substitution of multiple glyphs by a single glyph. 55 /// </summary> 56 [Serializable] 57 public struct LigatureSubstitutionRecord 58 { 59 /// <summary> 60 /// Array that contains the index of the glyphs being substituted. 61 /// </summary> 62 public uint[] componentGlyphIDs { get { return m_ComponentGlyphIDs; } set { m_ComponentGlyphIDs = value; } } 63 64 /// <summary> 65 /// The index of the replacement glyph. 66 /// </summary> 67 public uint ligatureGlyphID { get { return m_LigatureGlyphID; } set { m_LigatureGlyphID = value; } } 68 69 // ============================================= 70 // Private backing fields for public properties. 71 // ============================================= 72 73 [SerializeField] 74 private uint[] m_ComponentGlyphIDs; 75 76 [SerializeField] 77 private uint m_LigatureGlyphID; 78 79 // ============================================= 80 // Operator overrides 81 // ============================================= 82 83 public static bool operator==(LigatureSubstitutionRecord lhs, LigatureSubstitutionRecord rhs) 84 { 85 if (lhs.ligatureGlyphID != rhs.m_LigatureGlyphID) 86 return false; 87 88 int lhsComponentCount = lhs.m_ComponentGlyphIDs.Length; 89 90 if (lhsComponentCount != rhs.m_ComponentGlyphIDs.Length) 91 return false; 92 93 for (int i = 0; i < lhsComponentCount; i++) 94 { 95 if (lhs.m_ComponentGlyphIDs[i] != rhs.m_ComponentGlyphIDs[i]) 96 return false; 97 } 98 99 return true; 100 } 101 102 public static bool operator!=(LigatureSubstitutionRecord lhs, LigatureSubstitutionRecord rhs) 103 { 104 return !(lhs == rhs); 105 } 106 } 107}