Skip to content

Additional tests and fixes#136

Merged
dhardy merged 22 commits intomasterfrom
push-rnptkyoywonx
Feb 26, 2026
Merged

Additional tests and fixes#136
dhardy merged 22 commits intomasterfrom
push-rnptkyoywonx

Conversation

@dhardy
Copy link
Copy Markdown
Contributor

@dhardy dhardy commented Feb 26, 2026

This PR:

Removes the highlight-range functions (already deprecated in #133) since other changes in this PR would break them.

Panic-prevention:

  • Do not panic if fn text_glyph_pos matches index to more than two positions

New tests:

  • Additional RTL run-breaking tests
  • Shaping tests for glyph indices and wrap-point associations

Code revisions / clean up:

  • Revise fn glyphs_with_effects
  • Revise fn part_lengths
  • Use logical order for GlyphRun::breaks and GlyphRun::glyphs (these previously used left-to-right oredr regardless of text direction)

Fixes (many confirmed through interactive testing since tests would be font-specific):

  • Fix font fallback adding a wrap-point at the start of a sub-run
  • Fix font fallbacks changing the font due to non-printing chars
  • Fix RTL text wrapping at the wrong position
  • Fix glyph-wrap-position associations for shaped (RTL) text using multiple glyphs per text index
  • Fix the position returned by text_glyph_pos in shaped (RTL) text using multiple glyphs per text index
  • Various other fixes for minor RTL wrapping and position issues

Behaviour changes:

  • When a run is broken into sub-runs for font fallbacks, always prefer the default font face instead of the last-used face

//! [`format`]: mod@format

#![cfg_attr(docsrs, feature(doc_cfg))]
#![allow(text_direction_codepoint_in_literal)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required by a new test. Unfortunately Rust does not allow enabling text-direction marks for specific uses only, thus we must enable it at the crate level.

@dhardy
Copy link
Copy Markdown
Contributor Author

dhardy commented Feb 26, 2026

Although the new tests avoid depending on any font metrics, they still fail on various platforms due to font variations:

  • Shaping may use multiple glyphs per text index or skip some text indices entirely (use of ligatures)
  • Font fallback may cause extra breaks in text

@dhardy dhardy merged commit a087ae3 into master Feb 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant