FaceInfo.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.PostScript.Internal;
  23. namespace SharpFont.PostScript
  24. {
  25. /// <summary>
  26. /// A structure used to represent CID Face information.
  27. /// </summary>
  28. public class FaceInfo
  29. {
  30. #region Fields
  31. private IntPtr reference;
  32. private FaceInfoRec rec;
  33. #endregion
  34. #region Constructors
  35. internal FaceInfo(IntPtr reference)
  36. {
  37. Reference = reference;
  38. }
  39. #endregion
  40. #region Properties
  41. public string CidFontName
  42. {
  43. get
  44. {
  45. return rec.cid_font_name;
  46. }
  47. }
  48. public int CidVersion
  49. {
  50. get
  51. {
  52. return (int)rec.cid_version;
  53. }
  54. }
  55. public string Registry
  56. {
  57. get
  58. {
  59. return rec.registry;
  60. }
  61. }
  62. public string Ordering
  63. {
  64. get
  65. {
  66. return rec.ordering;
  67. }
  68. }
  69. public int Supplement
  70. {
  71. get
  72. {
  73. return rec.supplement;
  74. }
  75. }
  76. public FontInfo FontInfo
  77. {
  78. get
  79. {
  80. return new FontInfo(new IntPtr(reference.ToInt64() + Marshal.OffsetOf(typeof(FaceInfoRec), "font_info").ToInt64()));
  81. }
  82. }
  83. public BBox FontBBox
  84. {
  85. get
  86. {
  87. return new BBox(new IntPtr(reference.ToInt64() + Marshal.OffsetOf(typeof(FaceInfoRec), "font_bbox").ToInt64()));
  88. }
  89. }
  90. [CLSCompliant(false)]
  91. public uint UidBase
  92. {
  93. get
  94. {
  95. return (uint)rec.uid_base;
  96. }
  97. }
  98. public int XuidCount
  99. {
  100. get
  101. {
  102. return rec.num_xuid;
  103. }
  104. }
  105. [CLSCompliant(false)]
  106. public uint[] Xuid
  107. {
  108. get
  109. {
  110. #if WIN64
  111. return rec.xuid;
  112. #else
  113. return Array.ConvertAll<UIntPtr, uint>(rec.xuid, new Converter<UIntPtr, uint>(delegate(UIntPtr x) { return (uint)x; }));
  114. #endif
  115. }
  116. }
  117. [CLSCompliant(false)]
  118. public uint CidMapOffset
  119. {
  120. get
  121. {
  122. return (uint)rec.cidmap_offset;
  123. }
  124. }
  125. public int FDBytes
  126. {
  127. get
  128. {
  129. return rec.fd_bytes;
  130. }
  131. }
  132. public int GDBytes
  133. {
  134. get
  135. {
  136. return rec.gd_bytes;
  137. }
  138. }
  139. [CLSCompliant(false)]
  140. public uint CidCount
  141. {
  142. get
  143. {
  144. return (uint)rec.cid_count;
  145. }
  146. }
  147. public int DictsCount
  148. {
  149. get
  150. {
  151. return rec.num_dicts;
  152. }
  153. }
  154. public FaceDict FontDicts
  155. {
  156. get
  157. {
  158. return new FaceDict(new IntPtr(reference.ToInt64() + Marshal.OffsetOf(typeof(FaceInfo), "font_dicts").ToInt64()));
  159. }
  160. }
  161. [CLSCompliant(false)]
  162. public uint DataOffset
  163. {
  164. get
  165. {
  166. return (uint)rec.data_offset;
  167. }
  168. }
  169. internal IntPtr Reference
  170. {
  171. get
  172. {
  173. return reference;
  174. }
  175. set
  176. {
  177. reference = value;
  178. rec = PInvokeHelper.PtrToStructure<FaceInfoRec>(reference);
  179. }
  180. }
  181. #endregion
  182. }
  183. }