Add new TexBlock and Hit testing APIs by JimBobSquarePants · Pull Request #530 · SixLabors/Fonts · GitHub
Skip to content

Add new TexBlock and Hit testing APIs - #530

Merged
JimBobSquarePants merged 17 commits into
mainfrom
js/textblock
May 8, 2026
Merged

JimBobSquarePants merged 17 commits into
mainfrom
js/textblock

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This PR expands the text layout stack into a richer prepared-layout and interaction API surface.

Highlights:

  • Adds prepared TextBlock layout APIs for repeated measuring, rendering, per-line inspection, and manual flow.
  • Adds LineLayout and LineLayoutEnumerator so callers can inspect, render, and position individual laid-out lines.
  • Adds text interaction APIs for hit testing, caret positioning, caret movement, word selection, and selection bounds.
  • Adds bidi-aware caret/selection behavior, including split visual selection rectangles for mixed-direction text.
  • Adds TextBidiMode to support normal bidi resolution and explicit direction override behavior.
  • Adds paragraph/editor interaction modes so paragraph layout trims trailing whitespace while editor layout preserves typed trailing spaces and terminal hard breaks.
  • Adds soft-hyphen rendering support with TextHyphenation and custom hyphen markers.
  • Adds max-line ellipsis support with TextEllipsis and custom ellipsis markers.
  • Adds inline placeholder support using object replacement semantics, placeholder metrics, alignment, and line-height participation.
  • Consolidates glyph detail APIs into GetGlyphMetrics, exposing advance, bounds, renderable bounds, code point, and source mapping from one glyph metrics entry.
  • Updates the design documentation for the new measurement, layout, and interaction APIs.

Breaking API Changes

  • Replaces the old separate glyph measurement APIs with a single GetGlyphMetrics API.
  • Renames the font-table glyph metrics type to FontGlyphMetrics.
  • Uses GlyphMetrics for laid-out glyph entries exposed by text measurement APIs.

Testing

This includes unit and visual coverage for:

  • Soft hyphen behavior, including none/custom modes, fallback runs, bidi text, and visual output.
  • Ellipsis behavior, including standard/custom markers, max-line truncation, and visual output.
  • Bidi mode behavior, including normal vs override ordering.
  • Caret placement and movement, including bidi cases, start/end placement, line movement, and preserved line navigation position.
  • Selection geometry, including bidi-discontinuous selection ranges.
  • Paragraph vs editor whitespace handling.
  • Placeholder layout, alignment, line-height effects, source mapping, and visual output.
  • Per-line layout enumeration and manual flow rendering.

@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant