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

Support Unicode in plTextFont (avatar tooltips, console, etc.) #1489

Merged
merged 7 commits into from
Oct 1, 2023

Conversation

dgelessus
Copy link
Contributor

@dgelessus dgelessus commented Sep 25, 2023

Fixes the last remaining problems with rendering non-ASCII characters. The main effect is that avatar tooltips work for non-ASCII names now:

Screenshot of avatar tooltip for "Æthelred the Unready" with working "Æ" character

Aside from that, it fixes non-ASCII text rendering in the console, log drawer, other debug views, and the loading screen. With this, I think Plasma now supports Unicode (or at least Latin-1) in all places where it matters.

Internally, this expands the supported character range of plTextFont from ASCII to Latin-1. Characters beyond the supported range don't cause rendering glitches anymore and instead show a fallback character (currently ¿, because the real replacement character is not in Latin-1).

Because plTextFont uses the OS native fonts instead of the game's .p2f files, it's easy to extend the character range further, theoretically up to all of Unicode. The practical limit is currently much lower than that though, because plTextFont pre-renders the entire character set into a texture with hardcoded sizes. I stuck with Latin-1 for now, because it fits into the current texture sizes, and anything else isn't usable by players yet anyway (though that would change with H-uru/moul-assets#237 adding Russian fonts).

If we want to support more than Latin-1, we need to adjust the hardcoded texture sizes accordingly, or calculate the required texture size dynamically as the font is loaded. Might also be good to support non-contiguous ranges of characters - that's an open issue for plFont as well I think.

The diff is quite big, but most of it are boring ST::stringification changes for all the debug views. The actually interesting changes are are in plTextFont and pfConsole.

@ZarothYe
Copy link
Contributor

I have no ability to review this on a technical level, but I'm so freaking hyped for and immensely impressed by this! Well done!

@Hoikas Hoikas merged commit e780361 into H-uru:master Oct 1, 2023
14 checks passed
@dgelessus dgelessus deleted the pltextfont_non_ascii branch November 29, 2023 21:31
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.

3 participants