TMP_FontFeatureTable.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace TMPro
  6. {
  7. /// <summary>
  8. /// Table that contains the various font features available for the given font asset.
  9. /// </summary>
  10. [Serializable]
  11. public class TMP_FontFeatureTable
  12. {
  13. /// <summary>
  14. /// List that contains the glyph pair adjustment records.
  15. /// </summary>
  16. public List<TMP_GlyphPairAdjustmentRecord> glyphPairAdjustmentRecords
  17. {
  18. get { return m_GlyphPairAdjustmentRecords; }
  19. set { m_GlyphPairAdjustmentRecords = value; }
  20. }
  21. [SerializeField]
  22. internal List<TMP_GlyphPairAdjustmentRecord> m_GlyphPairAdjustmentRecords;
  23. /// <summary>
  24. ///
  25. /// </summary>
  26. internal Dictionary<uint, TMP_GlyphPairAdjustmentRecord> m_GlyphPairAdjustmentRecordLookupDictionary;
  27. // =============================================
  28. // Constructor(s)
  29. // =============================================
  30. public TMP_FontFeatureTable()
  31. {
  32. m_GlyphPairAdjustmentRecords = new List<TMP_GlyphPairAdjustmentRecord>();
  33. m_GlyphPairAdjustmentRecordLookupDictionary = new Dictionary<uint, TMP_GlyphPairAdjustmentRecord>();
  34. }
  35. // =============================================
  36. // Utility Functions
  37. // =============================================
  38. /// <summary>
  39. /// Sort the glyph pair adjustment records by glyph index.
  40. /// </summary>
  41. public void SortGlyphPairAdjustmentRecords()
  42. {
  43. // Sort List of Kerning Info
  44. if (m_GlyphPairAdjustmentRecords.Count > 0)
  45. m_GlyphPairAdjustmentRecords = m_GlyphPairAdjustmentRecords.OrderBy(s => s.firstAdjustmentRecord.glyphIndex).ThenBy(s => s.secondAdjustmentRecord.glyphIndex).ToList();
  46. }
  47. }
  48. }