OutlineGlyph.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /// A structure used for outline (vectorial) glyph images. This really is a ‘sub-class’ of <see cref="Glyph"/>.
  27. /// </summary>
  28. /// <remarks><para>
  29. /// You can typecast an <see cref="Glyph"/> to <see cref="OutlineGlyph"/> if you have ‘<see cref="Glyph.Format"/>
  30. /// == <see cref="GlyphFormat.Outline"/>’. This lets you access the outline's content easily.
  31. /// </para><para>
  32. /// As the outline is extracted from a glyph slot, its coordinates are expressed normally in 26.6 pixels, unless
  33. /// the flag <see cref="LoadFlags.NoScale"/> was used in <see cref="Face.LoadGlyph"/> or
  34. /// <see cref="Face.LoadChar"/>.
  35. /// </para><para>
  36. /// The outline's tables are always owned by the object and are destroyed with it.
  37. /// </para></remarks>
  38. public class OutlineGlyph
  39. {
  40. #region Fields
  41. private IntPtr reference;
  42. private OutlineGlyphRec rec;
  43. #endregion
  44. #region Constructors
  45. internal OutlineGlyph(IntPtr reference)
  46. {
  47. Reference = reference;
  48. }
  49. #endregion
  50. #region Properties
  51. /// <summary>
  52. /// Gets the root <see cref="Glyph"/> fields.
  53. /// </summary>
  54. public Glyph Root
  55. {
  56. get
  57. {
  58. //HACK fix this later.
  59. return new Glyph(rec.root, null);
  60. }
  61. }
  62. /// <summary>
  63. /// Gets a descriptor for the outline.
  64. /// </summary>
  65. public Outline Outline
  66. {
  67. get
  68. {
  69. return new Outline(rec.outline);
  70. }
  71. }
  72. internal IntPtr Reference
  73. {
  74. get
  75. {
  76. return reference;
  77. }
  78. set
  79. {
  80. reference = value;
  81. rec = PInvokeHelper.PtrToStructure<OutlineGlyphRec>(reference);
  82. }
  83. }
  84. #endregion
  85. }
  86. }