// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.Fonts { /// /// Represents a hit-tested grapheme position in laid-out text. /// public readonly struct TextHit { /// /// Initializes a new instance of the struct. /// /// The zero-based line index. /// The grapheme index in the original text. /// The UTF-16 index in the original text. /// Whether the hit is on the trailing side of the grapheme. internal TextHit(int lineIndex, int graphemeIndex, int stringIndex, bool isTrailing) { this.LineIndex = lineIndex; this.GraphemeIndex = graphemeIndex; this.StringIndex = stringIndex; this.IsTrailing = isTrailing; } /// /// Gets the zero-based line index. /// public int LineIndex { 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; } /// /// Gets the grapheme insertion index represented by this hit. /// public int GraphemeInsertionIndex => this.GraphemeIndex + (this.IsTrailing ? 1 : 0); /// /// Gets a value indicating whether the hit is on the trailing side of the grapheme. /// public bool IsTrailing { get; } } }