Header.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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.Fnt.Internal;
  23. namespace SharpFont.Fnt
  24. {
  25. /// <summary>
  26. /// Windows FNT Header info.
  27. /// </summary>
  28. public class Header
  29. {
  30. #region Fields
  31. private IntPtr reference;
  32. private HeaderRec rec;
  33. #endregion
  34. #region Constructors
  35. internal Header(IntPtr reference)
  36. {
  37. Reference = reference;
  38. }
  39. #endregion
  40. #region Properties
  41. [CLSCompliant(false)]
  42. public ushort Version
  43. {
  44. get
  45. {
  46. return rec.version;
  47. }
  48. }
  49. [CLSCompliant(false)]
  50. public uint FileSize
  51. {
  52. get
  53. {
  54. return (uint)rec.file_size;
  55. }
  56. }
  57. public byte[] Copyright
  58. {
  59. get
  60. {
  61. return rec.copyright;
  62. }
  63. }
  64. [CLSCompliant(false)]
  65. public ushort FileType
  66. {
  67. get
  68. {
  69. return rec.file_type;
  70. }
  71. }
  72. [CLSCompliant(false)]
  73. public ushort NominalPointSize
  74. {
  75. get
  76. {
  77. return rec.nominal_point_size;
  78. }
  79. }
  80. [CLSCompliant(false)]
  81. public ushort VerticalResolution
  82. {
  83. get
  84. {
  85. return rec.vertical_resolution;
  86. }
  87. }
  88. [CLSCompliant(false)]
  89. public ushort HorizontalResolution
  90. {
  91. get
  92. {
  93. return rec.horizontal_resolution;
  94. }
  95. }
  96. [CLSCompliant(false)]
  97. public ushort Ascent
  98. {
  99. get
  100. {
  101. return rec.ascent;
  102. }
  103. }
  104. [CLSCompliant(false)]
  105. public ushort InternalLeading
  106. {
  107. get
  108. {
  109. return rec.internal_leading;
  110. }
  111. }
  112. [CLSCompliant(false)]
  113. public ushort ExternalLeading
  114. {
  115. get
  116. {
  117. return rec.external_leading;
  118. }
  119. }
  120. public byte Italic
  121. {
  122. get
  123. {
  124. return rec.italic;
  125. }
  126. }
  127. public byte Underline
  128. {
  129. get
  130. {
  131. return rec.underline;
  132. }
  133. }
  134. public byte Strikeout
  135. {
  136. get
  137. {
  138. return rec.strike_out;
  139. }
  140. }
  141. [CLSCompliant(false)]
  142. public ushort Weight
  143. {
  144. get
  145. {
  146. return rec.weight;
  147. }
  148. }
  149. public byte Charset
  150. {
  151. get
  152. {
  153. return rec.charset;
  154. }
  155. }
  156. [CLSCompliant(false)]
  157. public ushort PixelWidth
  158. {
  159. get
  160. {
  161. return rec.pixel_width;
  162. }
  163. }
  164. [CLSCompliant(false)]
  165. public ushort PixelHeight
  166. {
  167. get
  168. {
  169. return rec.pixel_height;
  170. }
  171. }
  172. public byte PitchAndFamily
  173. {
  174. get
  175. {
  176. return rec.pitch_and_family;
  177. }
  178. }
  179. [CLSCompliant(false)]
  180. public ushort AverageWidth
  181. {
  182. get
  183. {
  184. return rec.avg_width;
  185. }
  186. }
  187. [CLSCompliant(false)]
  188. public ushort MaximumWidth
  189. {
  190. get
  191. {
  192. return rec.max_width;
  193. }
  194. }
  195. public byte FirstChar
  196. {
  197. get
  198. {
  199. return rec.first_char;
  200. }
  201. }
  202. public byte LastChar
  203. {
  204. get
  205. {
  206. return rec.last_char;
  207. }
  208. }
  209. public byte DefaultChar
  210. {
  211. get
  212. {
  213. return rec.default_char;
  214. }
  215. }
  216. public byte BreakChar
  217. {
  218. get
  219. {
  220. return rec.break_char;
  221. }
  222. }
  223. [CLSCompliant(false)]
  224. public ushort BytesPerRow
  225. {
  226. get
  227. {
  228. return rec.bytes_per_row;
  229. }
  230. }
  231. [CLSCompliant(false)]
  232. public uint DeviceOffset
  233. {
  234. get
  235. {
  236. return (uint)rec.device_offset;
  237. }
  238. }
  239. [CLSCompliant(false)]
  240. public uint FaceNameOffset
  241. {
  242. get
  243. {
  244. return (uint)rec.face_name_offset;
  245. }
  246. }
  247. [CLSCompliant(false)]
  248. public uint BitsPointer
  249. {
  250. get
  251. {
  252. return (uint)rec.bits_pointer;
  253. }
  254. }
  255. [CLSCompliant(false)]
  256. public uint BitsOffset
  257. {
  258. get
  259. {
  260. return (uint)rec.bits_offset;
  261. }
  262. }
  263. public byte Reserved
  264. {
  265. get
  266. {
  267. return rec.reserved;
  268. }
  269. }
  270. [CLSCompliant(false)]
  271. public uint Flags
  272. {
  273. get
  274. {
  275. return (uint)rec.flags;
  276. }
  277. }
  278. [CLSCompliant(false)]
  279. public ushort ASpace
  280. {
  281. get
  282. {
  283. return rec.A_space;
  284. }
  285. }
  286. [CLSCompliant(false)]
  287. public ushort BSpace
  288. {
  289. get
  290. {
  291. return rec.B_space;
  292. }
  293. }
  294. [CLSCompliant(false)]
  295. public ushort CSpace
  296. {
  297. get
  298. {
  299. return rec.C_space;
  300. }
  301. }
  302. [CLSCompliant(false)]
  303. public ushort ColorTableOffset
  304. {
  305. get
  306. {
  307. return rec.color_table_offset;
  308. }
  309. }
  310. [CLSCompliant(false)]
  311. public uint[] Reserved1
  312. {
  313. get
  314. {
  315. #if WIN64
  316. return rec.reserved1;
  317. #else
  318. return Array.ConvertAll<UIntPtr, uint>(rec.reserved1, new Converter<UIntPtr, uint>(delegate(UIntPtr u) { return (uint)u; }));
  319. #endif
  320. }
  321. }
  322. internal IntPtr Reference
  323. {
  324. get
  325. {
  326. return reference;
  327. }
  328. set
  329. {
  330. reference = value;
  331. rec = PInvokeHelper.PtrToStructure<HeaderRec>(reference);
  332. }
  333. }
  334. #endregion
  335. }
  336. }