TextPaintOptions.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // RichTextKit
  2. // Copyright © 2019-2020 Topten Software. All Rights Reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. // not use this product except in compliance with the License. You may obtain
  6. // a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. // License for the specific language governing permissions and limitations
  14. // under the License.
  15. // Modifications by Alexander Tsyganeko: marked by ATZ
  16. using SkiaSharp;
  17. using System;
  18. namespace Topten.RichTextKit
  19. {
  20. /// <summary>
  21. /// Options to control how TextBlock is rendered.
  22. /// </summary>
  23. public class TextPaintOptions
  24. {
  25. /// <summary>
  26. /// Constructs a new text paint options
  27. /// </summary>
  28. public TextPaintOptions()
  29. {
  30. }
  31. /// <summary>
  32. /// Creates a clone of this object
  33. /// </summary>
  34. /// <returns>The closed object</returns>
  35. public TextPaintOptions Clone()
  36. {
  37. return (TextPaintOptions)this.MemberwiseClone();
  38. }
  39. // ATZ
  40. /// <summary>
  41. /// The path to draw glyph outlines to.
  42. /// </summary>
  43. public SKPath DrawToPath { get; set; }
  44. /// <summary>
  45. /// An optional TextRange to painted as selected.
  46. /// </summary>
  47. public TextRange? Selection
  48. {
  49. get;
  50. set;
  51. }
  52. /// <summary>
  53. /// The color to be used for the selection background.
  54. /// </summary>
  55. public SKColor SelectionColor
  56. {
  57. get;
  58. set;
  59. }
  60. /// <summary>
  61. /// The color to be used for touch screen selection handles
  62. /// </summary>
  63. public SKColor SelectionHandleColor
  64. {
  65. get;
  66. set;
  67. }
  68. /// <summary>
  69. /// Scaling of the touch screen selection handles
  70. /// </summary>
  71. /// <remarks>
  72. /// Sets the scaling of the selection handles. This can be used
  73. /// to keep the selection handle size consistent even if zooming in
  74. /// on rendered text. Set to zero to disable selection handles
  75. /// </remarks>
  76. public float SelectionHandleScale
  77. {
  78. get;
  79. set;
  80. } = 0;
  81. /// <summary>
  82. /// Controls how font edges are drawn
  83. /// </summary>
  84. public SKFontEdging Edging
  85. {
  86. get;
  87. set;
  88. } = SKFontEdging.Antialias;
  89. /// <summary>
  90. /// Requests text be drawn at sub-pixel offsets
  91. /// </summary>
  92. public bool SubpixelPositioning
  93. {
  94. get;
  95. set;
  96. } = true;
  97. /// <summary>
  98. /// Controls whether text is rendered with anti-aliasing.
  99. /// </summary>
  100. [Obsolete("Use Edging property instead of IsAntialias")]
  101. public bool IsAntialias
  102. {
  103. get => Edging != SKFontEdging.Alias;
  104. set => Edging = value ? SKFontEdging.Antialias : SKFontEdging.Alias;
  105. }
  106. /// <summary>
  107. /// Controls whether text is rendered using LCD sub-pixel rendering.
  108. /// </summary>
  109. [Obsolete("Use Edging property instead of LcdRenderText")]
  110. public bool LcdRenderText
  111. {
  112. get => Edging == SKFontEdging.SubpixelAntialias;
  113. set => Edging = value ? SKFontEdging.SubpixelAntialias : SKFontEdging.Antialias;
  114. }
  115. /// <summary>
  116. /// Controls the font hint used when rendering text
  117. /// </summary>
  118. public SKFontHinting Hinting
  119. {
  120. get;
  121. set;
  122. } = SKFontHinting.Normal;
  123. /// <summary>
  124. /// A default set of paint options that renders text blocks without
  125. /// a selection range.
  126. /// </summary>
  127. public static TextPaintOptions Default = new TextPaintOptions();
  128. }
  129. }