Rich text support for BitmapText - #7354
Open
skhoroshavin wants to merge 19 commits into
Open
Conversation
skhoroshavin
force-pushed
the
rich-bitmap-text
branch
from
August 23, 2026 01:42
e44bcca to
4599b51
Compare
Contributor
|
Is creating a third-party plugin a better option? |
Contributor
Author
|
@rexrainbow it could be, but it would duplicate quite a ton of logic from BitmapText. Actually we had this discussion about 1 month ago in discord, unfortunatelly I had some "life" in between, so I returned with draft impleentation only now. |
skhoroshavin
force-pushed
the
rich-bitmap-text
branch
from
August 23, 2026 01:47
4599b51 to
1ce07f0
Compare
skhoroshavin
force-pushed
the
rich-bitmap-text
branch
from
August 23, 2026 01:52
1ce07f0 to
5ffbf01
Compare
skhoroshavin
marked this pull request as ready for review
August 23, 2026 01:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in rich text support to
BitmapText: segmented rendering with each segment having its own font, size and color. Fully backward compatible - when the feature is unused, rendering is pixel-identical to the previous code path (proved by Playwright tests added from the very beginning of development).setTextis untouched and stays plain-only.Usage
Programmatic alternative without markup:
Feature set:
addTextStyle(name, { font?, size?, color? }); styles without a font inherit the object's font[style]...[/style]with[[/]]escapes; malformed markup warns and degrades gracefullysetCharacterTint(charColors) still takes precedence over style colorsNotes for reviewers
When I conceived this feature initially, I hoped it wouldn't require serious refactorings, however it turned out
GetBitmapTextSizewas quite entangled, and in the end I had to basically rewrite it. Since backward compatibility was a top priority, I actually started with adding a set of screenshot-based tests, and only then moved on to actual implementation, moving in small steps, and making sure tests stay green. The whole process can be audited in the commit history.Even though this PR looks huge (~2400 lines added), actual code changes are significantly smaller. Actual composition:
src/, majority of which are purely additive, exceptGetBitmapTextSizefunctionlato.xmlandclarendon.xmlBMFonts copied from Phaser examples - used in visual testsFrankly speaking, I'm not fully happy with the current implementation, and have some ideas for how to unify setText and setRichText internal paths, but that would be a bigger refactoring with more changes in plain text code paths, so I'd like to discuss it with maintainers before actually implementing, either here or in a separate follow-up PR.