UserCharToGlyphIndexMap.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //MIT, 2016-present, WinterDev
  2. namespace Typography.TextLayout
  3. {
  4. public struct UserCodePointToGlyphIndex
  5. {
  6. //from user codepoint index to offset in _glyphIndics
  7. //this index is 1-based ***
  8. //if glyphIndexListOffset_1==0 then no map data in _glyphIndices***
  9. public ushort glyphIndexListOffset_plus1;
  10. public ushort len;
  11. internal int userCodePointIndex;
  12. #if DEBUG
  13. public override string ToString()
  14. {
  15. return glyphIndexListOffset_plus1 + ":" + len;
  16. }
  17. #endif
  18. internal void AppendData(ushort glyphIndexListOffset_plus1, ushort len)
  19. {
  20. #if DEBUG
  21. if (len != 1)
  22. {
  23. }
  24. #endif
  25. if (this.glyphIndexListOffset_plus1 != 0)
  26. {
  27. //extend ***
  28. //some user char may be represented by >1 glyphs
  29. if (this.glyphIndexListOffset_plus1 + 1 == glyphIndexListOffset_plus1)
  30. {
  31. //ok
  32. if (len == 1)
  33. {
  34. this.len += 1;
  35. return; //***
  36. }
  37. else
  38. {
  39. throw new System.NotSupportedException();
  40. }
  41. }
  42. else
  43. {
  44. throw new System.NotSupportedException();
  45. }
  46. }
  47. this.glyphIndexListOffset_plus1 = glyphIndexListOffset_plus1;
  48. this.len = len;
  49. }
  50. }
  51. }