// RichTextKit // Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this product except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. using SkiaSharp; using System; namespace Topten.RichTextKit { /// /// Options to control how TextBlock is rendered. /// public class TextPaintOptions { /// /// Constructs a new text paint options /// public TextPaintOptions() { } /// /// Creates a clone of this object /// /// The closed object public TextPaintOptions Clone() { return (TextPaintOptions)this.MemberwiseClone(); } /// /// An optional TextRange to painted as selected. /// public TextRange? Selection { get; set; } /// /// The color to be used for the selection background. /// public SKColor SelectionColor { get; set; } /// /// The color to be used for touch screen selection handles /// public SKColor SelectionHandleColor { get; set; } /// /// Scaling of the touch screen selection handles /// /// /// Sets the scaling of the selection handles. This can be used /// to keep the selection handle size consistent even if zooming in /// on rendered text. Set to zero to disable selection handles /// public float SelectionHandleScale { get; set; } = 0; /// /// Controls how font edges are drawn /// public SKFontEdging Edging { get; set; } = SKFontEdging.Antialias; /// /// Requests text be drawn at sub-pixel offsets /// public bool SubpixelPositioning { get; set; } = true; /// /// Controls whether text is rendered with anti-aliasing. /// [Obsolete("Use Edging property instead of IsAntialias")] public bool IsAntialias { get => Edging != SKFontEdging.Alias; set => Edging = value ? SKFontEdging.Antialias : SKFontEdging.Alias; } /// /// Controls whether text is rendered using LCD sub-pixel rendering. /// [Obsolete("Use Edging property instead of LcdRenderText")] public bool LcdRenderText { get => Edging == SKFontEdging.SubpixelAntialias; set => Edging = value ? SKFontEdging.SubpixelAntialias : SKFontEdging.Antialias; } /// /// Controls the font hint used when rendering text /// public SKFontHinting Hinting { get; set; } = SKFontHinting.Normal; /// /// A default set of paint options that renders text blocks without /// a selection range. /// public static TextPaintOptions Default = new TextPaintOptions(); } }