Beispiel #1
0
 /// <summary>
 /// Renders the text.
 /// </summary>
 /// <param name="renderer">The target renderer surface.</param>
 /// <param name="text">The text.</param>
 /// <param name="options">The options.</param>
 /// <returns>Returns the original <paramref name="renderer"/></returns>
 public static IGlyphRenderer Render(this IGlyphRenderer renderer, ReadOnlySpan <char> text, TextOptions options)
 {
     new TextRenderer(renderer).RenderText(text, options);
     return(renderer);
 }
 /// <summary>
 /// Measures the text.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="options">The style.</param>
 /// <returns>The size of the text if it was to be rendered.</returns>
 public static FontRectangle MeasureBounds(ReadOnlySpan <char> text, TextOptions options)
 => TextMeasurerInt.Default.MeasureBounds(text, options);
 /// <summary>
 /// Measures the character bounds of the text. For each control character the list contains a <c>null</c> element.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="options">The style.</param>
 /// <param name="characterBounds">The list of character bounds of the text if it was to be rendered.</param>
 /// <returns>Whether any of the characters had non-empty bounds.</returns>
 public static bool TryMeasureCharacterBounds(ReadOnlySpan <char> text, TextOptions options, out GlyphBounds[] characterBounds)
 => TextMeasurerInt.Default.TryMeasureCharacterBounds(text, options, out characterBounds);
            /// <summary>
            /// Measures the text.
            /// </summary>
            /// <param name="text">The text.</param>
            /// <param name="options">The style.</param>
            /// <returns>The size of the text if it was to be rendered.</returns>
            internal FontRectangle Measure(ReadOnlySpan <char> text, TextOptions options)
            {
                IReadOnlyList <GlyphLayout> glyphsToRender = this.layoutEngine.GenerateLayout(text, options);

                return(GetSize(glyphsToRender, options.Dpi));
            }
 /// <summary>
 /// Measures the text.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="options">The style.</param>
 /// <returns>The size of the text if it was to be rendered.</returns>
 public static FontRectangle MeasureBounds(string text, TextOptions options)
 => TextMeasurerInt.Default.MeasureBounds(text.AsSpan(), options);
            /// <summary>
            /// Measures the text.
            /// </summary>
            /// <param name="text">The text.</param>
            /// <param name="options">The style.</param>
            /// <param name="characterBounds">The character bounds list.</param>
            /// <returns>The size of the text if it was to be rendered.</returns>
            internal bool TryMeasureCharacterBounds(ReadOnlySpan <char> text, TextOptions options, out GlyphBounds[] characterBounds)
            {
                IReadOnlyList <GlyphLayout> glyphsToRender = this.layoutEngine.GenerateLayout(text, options);

                return(TryGetCharacterBounds(glyphsToRender, options.Dpi, out characterBounds));
            }
Beispiel #7
0
 /// <summary>
 /// Renders the glyph to the render surface in font units relative to a bottom left origin at (0,0)
 /// </summary>
 /// <param name="surface">The surface.</param>
 /// <param name="location">The location.</param>
 /// <param name="options">The options to render using.</param>
 /// <exception cref="System.NotSupportedException">Too many control points.</exception>
 internal void RenderTo(IGlyphRenderer surface, Vector2 location, TextOptions options)
 => this.GlyphMetrics.RenderTo(surface, this.pointSize, location, options);
Beispiel #8
0
 /// <summary>
 /// Renders the text.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="options">The style.</param>
 public void RenderText(string text, TextOptions options)
 => this.RenderText(text.AsSpan(), options);
Beispiel #9
0
 /// <summary>
 /// Renders the text to the <paramref name="renderer"/>.
 /// </summary>
 /// <param name="renderer">The target renderer.</param>
 /// <param name="text">The text.</param>
 /// <param name="options">The style.</param>
 public static void RenderTextTo(IGlyphRenderer renderer, string text, TextOptions options)
 => new TextRenderer(renderer).RenderText(text, options);
Beispiel #10
0
 /// <summary>
 /// Renders the text to the <paramref name="renderer"/>.
 /// </summary>
 /// <param name="renderer">The target renderer.</param>
 /// <param name="text">The text.</param>
 /// <param name="options">The style.</param>
 public static void RenderTextTo(IGlyphRenderer renderer, ReadOnlySpan <char> text, TextOptions options)
 => new TextRenderer(renderer).RenderText(text, options);