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

Unicode in mapgen #38149

Merged
merged 4 commits into from
Mar 11, 2020
Merged

Unicode in mapgen #38149

merged 4 commits into from
Mar 11, 2020

Conversation

jbytheway
Copy link
Contributor

Summary

SUMMARY: Infrastructure "Allow Unicode keys in mapgen rows"

Purpose of change

Some mapgen palettes (such as the one for houses) are running out of useful ASCII characters to use as keys.

Describe the solution

Allow arbitrary Unicode characters as keys, provided they consume only a single column (so e.g. no Chinese characters, nor most emojis).

Combining characters are handled, so arbitrary accents and even Z̴̨̧̞̦̱̭̼̹̱̠̱͍͙̥̃̽͋̅͝ā̴̛̛̬̞͈̞͇̀̏̐́̎͆́̚ͅl̵̖͔̥̑̓͛͑̇̃͋̑̈́̀͆̅̓̕͝g̶̨̗͋̆̆̈́̀̋̌͗͝o̴̥̥̬̥̱͆̀̍͐͌͑̍͘̕͠ ̴̺̫̹̂̏̇͒̀͂̈̌͌̉̓̔͆̽͘͜ẗ̷̛̲͈̱͚̣͔̥͍̗͔͖́̅͊̀͛̎͒͠͠e̷̙̣͇̗͖͈͔̲̤̞̥̱̤̜͚͆̀̈́̎̈́̈́̒͂͠͝x̴̢̢̨̨̫̬͇̱͖̯̠͙̬̩͚̓̑̆̿̌̌́͘t̷̡̮̓̓͗͛͋͒̆̑̀̌̌̒ should work. No normalization is performed.

Add a single example use of this feature in house_w_palette by using a box-drawing character that looks somewhat like a bookcase (▤) to represent bookcase.

Document the new feature.

Describe alternatives you've considered

We could try to allow double-width characters. We'd probably want to enforce that the entire map used a single width of character consistently. But this seems like enough generalization for now.

Could try to normalize the strings so that different representations of the same character are equivalent, but we don't have the Unicode data required to do that, and I didn't want to add a dependency on libicu just for this.

Testing

Used the new feature in house_w_palette as mentioned above. Spawned some of those houses in-game to verify that bookcases and books still appear.

Additional context

Requested by @I-am-Erk.

@ifreund ifreund added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Feb 19, 2020
This splits a string into a sequence of displayed characters.
Using new facility to split strings into displayed chunks, allow mapgen
to use arbitrary Unicode characters (including combining characters) as
keys.
Replace bookcase symbol in the house_w_nest_palette with a Unicode
symbol that looks similar to a bookcase (▤).
@ZhilkinSerg ZhilkinSerg changed the base branch from master to dev March 11, 2020 06:47
@ZhilkinSerg ZhilkinSerg mentioned this pull request Mar 11, 2020
13 tasks
@ZhilkinSerg ZhilkinSerg merged commit f5f5b4f into CleverRaven:dev Mar 11, 2020
@jbytheway jbytheway deleted the unicode_in_mapgen branch March 12, 2020 01:03
ZhilkinSerg pushed a commit that referenced this pull request Apr 1, 2020
ZhilkinSerg pushed a commit that referenced this pull request Apr 1, 2020
ZhilkinSerg pushed a commit that referenced this pull request Apr 2, 2020
ZhilkinSerg pushed a commit that referenced this pull request Apr 2, 2020
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` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style <Enhancement / Feature> New features, or enhancements on existing Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants