// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using SixLabors.Fonts.Unicode; namespace SixLabors.Fonts { /// /// Represents one laid-out glyph entry in final layout order. /// public readonly struct GlyphMetrics { /// /// Initializes a new instance of the struct. /// /// The Unicode code point represented by the glyph entry. /// The positioned logical advance rectangle for the glyph entry in pixel units. /// The rendered rectangle for the glyph entry in pixel units. /// The union of the positioned logical advance rectangle and rendered rectangle in pixel units. /// The font used to shape and render the glyph entry. /// The grapheme index in the original text. /// The UTF-16 index in the original text where the glyph entry begins. internal GlyphMetrics( CodePoint codePoint, in FontRectangle advance, in FontRectangle bounds, in FontRectangle renderableBounds, Font font, int graphemeIndex, int stringIndex) { this.CodePoint = codePoint; this.Advance = advance; this.Bounds = bounds; this.RenderableBounds = renderableBounds; this.Font = font; this.GraphemeIndex = graphemeIndex; this.StringIndex = stringIndex; } /// /// Gets the Unicode code point represented by the glyph entry. /// public CodePoint CodePoint { get; } /// /// Gets the positioned logical advance rectangle for the glyph entry in pixel units. /// public FontRectangle Advance { get; } /// /// Gets the rendered rectangle for the glyph entry in pixel units. /// public FontRectangle Bounds { get; } /// /// Gets the union of the positioned logical advance rectangle and rendered rectangle in pixel units. /// public FontRectangle RenderableBounds { get; } /// /// Gets the font used to shape and render the glyph entry. /// public Font Font { get; } /// /// Gets the zero-based grapheme index in the original text. /// public int GraphemeIndex { get; } /// /// Gets the zero-based UTF-16 code unit index in the original text. /// public int StringIndex { get; } /// public override string ToString() => $"CodePoint: {this.CodePoint}, Advance: {this.Advance}, Bounds: {this.Bounds}, RenderableBounds: {this.RenderableBounds}."; } }