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 the alignment of many unicode strings #34886

Merged
merged 2 commits into from
Oct 21, 2019

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Oct 20, 2019

Summary

SUMMARY: Interface "Assorted string alignment fixes"

Purpose of change

Fix the incorrect alignment of many strings when they contain unicode characters.

Describe the solution

Used utf8_width instead of string::size/length to calculate the display width of strings. Three new functions left_justify, right_justify, and utf8_justify were added and used instead of %<num>s to correctly handle the left/right justifying of utf8 strings.

Replaced some string::size/length calls used for emptyness check/access to the last element with string::empty/back.

Also fixed a bunch of small bugs/issues I encountered when testing the changes:

  1. Player with debug hammerspace can now immediately finish any faction camp missions to make debugging with the faction camp code easier.
  2. Used the non-breaking space (0xA0) after item health bars to make NPC clothing description in the look-around mode prettier.
  3. Fixed the issue where unicode characters inside scrolling combat text were not displayed.

Testing

All fixes were tested in-game and were working as expected.

@Qrox Qrox changed the title Fix alignment of many unicode strings Fix the alignment of many unicode strings Oct 20, 2019
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. Translation I18n labels Oct 20, 2019
@ZhilkinSerg ZhilkinSerg merged commit 0490a5a into CleverRaven:master Oct 21, 2019
@Qrox Qrox deleted the fix-alignment branch October 23, 2019 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. Translation I18n
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants