RendererClass.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.Internal;
  23. namespace SharpFont
  24. {
  25. /// <summary>
  26. /// The renderer module class descriptor.
  27. /// </summary>
  28. public class RendererClass
  29. {
  30. #region Fields
  31. private IntPtr reference;
  32. private RendererClassRec rec;
  33. #endregion
  34. #region Constructors
  35. internal RendererClass(IntPtr reference)
  36. {
  37. Reference = reference;
  38. }
  39. #endregion
  40. #region Properties
  41. /// <summary>
  42. /// Gets the root <see cref="ModuleClass"/> fields.
  43. /// </summary>
  44. public ModuleClass Root
  45. {
  46. get
  47. {
  48. return new ModuleClass(reference);
  49. }
  50. }
  51. /// <summary>
  52. /// Gets the glyph image format this renderer handles.
  53. /// </summary>
  54. [CLSCompliant(false)]
  55. public GlyphFormat Format
  56. {
  57. get
  58. {
  59. return rec.glyph_format;
  60. }
  61. }
  62. /// <summary>
  63. /// Gets a method used to render the image that is in a given glyph slot into a bitmap.
  64. /// </summary>
  65. public IntPtr RenderGlyph
  66. {
  67. get
  68. {
  69. return rec.render_glyph;
  70. }
  71. }
  72. /// <summary>
  73. /// Gets a method used to transform the image that is in a given glyph slot.
  74. /// </summary>
  75. public IntPtr TransformGlyph
  76. {
  77. get
  78. {
  79. return rec.transform_glyph;
  80. }
  81. }
  82. /// <summary>
  83. /// Gets a method used to access the glyph's cbox.
  84. /// </summary>
  85. public IntPtr GetGlyphCBox
  86. {
  87. get
  88. {
  89. return rec.get_glyph_cbox;
  90. }
  91. }
  92. /// <summary>
  93. /// Gets a method used to pass additional parameters.
  94. /// </summary>
  95. public IntPtr SetMode
  96. {
  97. get
  98. {
  99. return rec.set_mode;
  100. }
  101. }
  102. /// <summary>
  103. /// Gets a pointer to its raster's class.
  104. /// </summary>
  105. /// <remarks>For <see cref="GlyphFormat.Outline"/> renderers only.</remarks>
  106. public RasterFuncs RasterClass
  107. {
  108. get
  109. {
  110. return new RasterFuncs(reference, Marshal.OffsetOf(typeof(RendererClassRec), "raster_class"));
  111. }
  112. }
  113. internal IntPtr Reference
  114. {
  115. get
  116. {
  117. return reference;
  118. }
  119. set
  120. {
  121. reference = value;
  122. rec = PInvokeHelper.PtrToStructure<RendererClassRec>(reference);
  123. }
  124. }
  125. #endregion
  126. }
  127. }