MMVar.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #region MIT License
  2. /*Copyright (c) 2012 Robert Rouhani <robert.rouhani@gmail.com>
  3. SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
  4. Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. this software and associated documentation files (the "Software"), to deal in
  6. the Software without restriction, including without limitation the rights to
  7. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  8. of the Software, and to permit persons to whom the Software is furnished to do
  9. so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.*/
  19. #endregion
  20. using System;
  21. using System.Runtime.InteropServices;
  22. using SharpFont.MultipleMasters.Internal;
  23. namespace SharpFont.MultipleMasters
  24. {
  25. /// <summary><para>
  26. /// A structure used to model the axes and space of a Multiple Masters or GX var distortable font.
  27. /// </para><para>
  28. /// Some fields are specific to one format and not to the other.
  29. /// </para></summary>
  30. public class MMVar
  31. {
  32. #region Fields
  33. private IntPtr reference;
  34. private MMVarRec rec;
  35. #endregion
  36. #region Constructors
  37. internal MMVar(IntPtr reference)
  38. {
  39. Reference = reference;
  40. }
  41. #endregion
  42. #region Properties
  43. /// <summary>
  44. /// Gets the number of axes. The maximum value is 4 for MM; no limit in GX.
  45. /// </summary>
  46. [CLSCompliant(false)]
  47. public uint AxisCount
  48. {
  49. get
  50. {
  51. return rec.num_axis;
  52. }
  53. }
  54. /// <summary>
  55. /// Gets the number of designs; should be normally 2^num_axis for MM fonts. Not meaningful for GX (where every
  56. /// glyph could have a different number of designs).
  57. /// </summary>
  58. [CLSCompliant(false)]
  59. public uint DesignsCount
  60. {
  61. get
  62. {
  63. return rec.num_designs;
  64. }
  65. }
  66. /// <summary>
  67. /// Gets the number of named styles; only meaningful for GX which allows certain design coordinates to have a
  68. /// string ID (in the ‘name’ table) associated with them. The font can tell the user that, for example,
  69. /// Weight=1.5 is ‘Bold’.
  70. /// </summary>
  71. [CLSCompliant(false)]
  72. public uint NamedStylesCount
  73. {
  74. get
  75. {
  76. return rec.num_namedstyles;
  77. }
  78. }
  79. /// <summary>
  80. /// Gets a table of axis descriptors. GX fonts contain slightly more data than MM.
  81. /// </summary>
  82. public VarAxis Axis
  83. {
  84. get
  85. {
  86. return new VarAxis(rec.axis);
  87. }
  88. }
  89. /// <summary>
  90. /// Gets a table of named styles. Only meaningful with GX.
  91. /// </summary>
  92. public VarNamedStyle NamedStyle
  93. {
  94. get
  95. {
  96. return new VarNamedStyle(rec.namedstyle);
  97. }
  98. }
  99. internal IntPtr Reference
  100. {
  101. get
  102. {
  103. return reference;
  104. }
  105. set
  106. {
  107. reference = value;
  108. rec = PInvokeHelper.PtrToStructure<MMVarRec>(reference);
  109. }
  110. }
  111. #endregion
  112. }
  113. }