A game about forced loneliness, made by TACStudios
1using System;
2using System.Linq;
3using System.Collections.Generic;
4using UnityEngine;
5using UnityEngine.TextCore.LowLevel;
6
7
8namespace TMPro
9{
10 /// <summary>
11 /// Table that contains the various font features available for the given font asset.
12 /// </summary>
13 [Serializable]
14 public class TMP_FontFeatureTable
15 {
16 /// <summary>
17 /// List that contains the glyph multiple substitution records.
18 /// </summary>
19 public List<MultipleSubstitutionRecord> multipleSubstitutionRecords
20 {
21 get { return m_MultipleSubstitutionRecords; }
22 set { m_MultipleSubstitutionRecords = value; }
23 }
24
25 /// <summary>
26 /// List that contains the glyph ligature records.
27 /// </summary>
28 public List<LigatureSubstitutionRecord> ligatureRecords
29 {
30 get { return m_LigatureSubstitutionRecords; }
31 set { m_LigatureSubstitutionRecords = value; }
32 }
33
34 /// <summary>
35 /// List that contains the glyph pair adjustment records.
36 /// </summary>
37 public List<GlyphPairAdjustmentRecord> glyphPairAdjustmentRecords
38 {
39 get { return m_GlyphPairAdjustmentRecords; }
40 set { m_GlyphPairAdjustmentRecords = value; }
41 }
42
43 /// <summary>
44 ///
45 /// </summary>
46 public List<MarkToBaseAdjustmentRecord> MarkToBaseAdjustmentRecords
47 {
48 get { return m_MarkToBaseAdjustmentRecords; }
49 set { m_MarkToBaseAdjustmentRecords = value; }
50 }
51
52 /// <summary>
53 ///
54 /// </summary>
55 public List<MarkToMarkAdjustmentRecord> MarkToMarkAdjustmentRecords
56 {
57 get { return m_MarkToMarkAdjustmentRecords; }
58 set { m_MarkToMarkAdjustmentRecords = value; }
59 }
60
61 // =============================================
62 // Private backing fields for public properties.
63 // =============================================
64
65 [SerializeField]
66 internal List<MultipleSubstitutionRecord> m_MultipleSubstitutionRecords;
67
68 [SerializeField]
69 internal List<LigatureSubstitutionRecord> m_LigatureSubstitutionRecords;
70
71 [SerializeField]
72 internal List<GlyphPairAdjustmentRecord> m_GlyphPairAdjustmentRecords;
73
74 [SerializeField]
75 internal List<MarkToBaseAdjustmentRecord> m_MarkToBaseAdjustmentRecords;
76
77 [SerializeField]
78 internal List<MarkToMarkAdjustmentRecord> m_MarkToMarkAdjustmentRecords;
79
80
81 // =============================================
82 // Lookup data structures.
83 // =============================================
84
85 internal Dictionary<uint, List<LigatureSubstitutionRecord>> m_LigatureSubstitutionRecordLookup;
86
87 internal Dictionary<uint, GlyphPairAdjustmentRecord> m_GlyphPairAdjustmentRecordLookup;
88
89 internal Dictionary<uint, MarkToBaseAdjustmentRecord> m_MarkToBaseAdjustmentRecordLookup;
90
91 internal Dictionary<uint, MarkToMarkAdjustmentRecord> m_MarkToMarkAdjustmentRecordLookup;
92
93 // =============================================
94 // Constructor(s)
95 // =============================================
96
97 public TMP_FontFeatureTable()
98 {
99 m_LigatureSubstitutionRecords = new List<LigatureSubstitutionRecord>();
100 m_LigatureSubstitutionRecordLookup = new Dictionary<uint, List<LigatureSubstitutionRecord>>();
101
102 m_GlyphPairAdjustmentRecords = new List<GlyphPairAdjustmentRecord>();
103 m_GlyphPairAdjustmentRecordLookup = new Dictionary<uint, GlyphPairAdjustmentRecord>();
104
105 m_MarkToBaseAdjustmentRecords = new List<MarkToBaseAdjustmentRecord>();
106 m_MarkToBaseAdjustmentRecordLookup = new Dictionary<uint, MarkToBaseAdjustmentRecord>();
107
108 m_MarkToMarkAdjustmentRecords = new List<MarkToMarkAdjustmentRecord>();
109 m_MarkToMarkAdjustmentRecordLookup = new Dictionary<uint, MarkToMarkAdjustmentRecord>();
110 }
111
112 // =============================================
113 // Utility Functions
114 // =============================================
115
116 /// <summary>
117 /// Sort the glyph pair adjustment records by glyph index.
118 /// </summary>
119 public void SortGlyphPairAdjustmentRecords()
120 {
121 // Sort List of Kerning Info
122 if (m_GlyphPairAdjustmentRecords.Count > 0)
123 m_GlyphPairAdjustmentRecords = m_GlyphPairAdjustmentRecords.OrderBy(s => s.firstAdjustmentRecord.glyphIndex).ThenBy(s => s.secondAdjustmentRecord.glyphIndex).ToList();
124 }
125
126 /// <summary>
127 /// Sort the Mark-to-Base Adjustment Table records.
128 /// </summary>
129 public void SortMarkToBaseAdjustmentRecords()
130 {
131 // Sort List of Kerning Info
132 if (m_MarkToBaseAdjustmentRecords.Count > 0)
133 m_MarkToBaseAdjustmentRecords = m_MarkToBaseAdjustmentRecords.OrderBy(s => s.baseGlyphID).ThenBy(s => s.markGlyphID).ToList();
134 }
135
136 /// <summary>
137 /// Sort the Mark-to-Mark Adjustment Table records.
138 /// </summary>
139 public void SortMarkToMarkAdjustmentRecords()
140 {
141 // Sort List of Kerning Info
142 if (m_MarkToMarkAdjustmentRecords.Count > 0)
143 m_MarkToMarkAdjustmentRecords = m_MarkToMarkAdjustmentRecords.OrderBy(s => s.baseMarkGlyphID).ThenBy(s => s.combiningMarkGlyphID).ToList();
144 }
145 }
146}