Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Layouter reverse-mapping to characters #11060

Merged
merged 2 commits into from Jun 26, 2023

Conversation

nielsmh
Copy link
Contributor

@nielsmh nielsmh commented Jun 22, 2023

Motivation / Problem

Mapping back from a glyph to a character index in the source string should work, even with multiple run and when formatting codes are involved.

Description

Have visual runs keep track of their offsets in the input text.
Count formatting codes the same way in both forward and reverse mapping.

Limitations

Not thoroughly tested recently, but this fixed something when I was working on #7786 originally. (Reverse-mapping is relevant for hit-testing mouse clicks against individual character glyphs.)

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@nielsmh nielsmh changed the title Fix: FallbackParagraphLayouter reverse-mapping to characters Fix: Layouter reverse-mapping to characters Jun 22, 2023
src/gfx_layout.cpp Outdated Show resolved Hide resolved
@nielsmh nielsmh force-pushed the fix-reversemap-fallbacklayouter branch from b4c4c37 to 54b3b7b Compare June 23, 2023 14:57
@nielsmh nielsmh merged commit 103d88e into OpenTTD:master Jun 26, 2023
19 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.

None yet

4 participants