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 fallout from SimpleGraphic upgrade with wider Unicode support #7586

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

zao
Copy link
Contributor

@zao zao commented Apr 19, 2024

Description of the problem being solved:

In PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic#59 there were significant foundational improvements for users installing Path of Building into paths with characters that cannot be expressed in their codepage.

There is also a companion PR for the Launcher in PathOfBuildingCommunity/PathOfBuilding-Launcher#6.

In short:

  • the LuaJIT runtime is patched to understand paths in UTF-8,
  • API functionality like FileSearch yields paths encoded in UTF-8,
  • GetScriptPath/GetUserPath yields paths in UTF-8,
  • text rendering draws glyphs that don't exist in the fonts as [U+1234] "tofu" in a smaller font size,
  • mouse selection understands codepoint boundaries,
  • a compiled extension lua-utf8 is exposed to the Lua side.

This means that Lua code that touches things like the full build path or the script path may need to adapt to process UTF-8 correctly with string operations.

In order to help with that, the SimpleGraphic update also features luautf8, a Lua extension that provides UTF-8 analogues of many string operations like gsub, match, etc.

This change leverages that extension via local utf8 = require('lua-utf8') to correctly move the text caret with the cursor keys in edit controls, and also showcases its use to handle (hypothetical) Unicode decimal and thousands separators.

The runtime also lost the vestigial ability to process GIF and BLP image formats, some existing assets were stealth GIFs with PNG extensions and have here been converted lossless to PNG.

The update check logic has been adapted to generate relative paths in the op-files to make its limited interpreter work correctly in exotic install locations.

Steps taken to verify a working solution:

Install location:

  • install PoB into a location with traditionally unrepresentable Japanese characters in an English locale,
  • note how it can both start and update itself

Build path:

  • set the build path to such a location,
  • note how builds with ASCII characters can still be saved and otherwise modified there.

Build name:

  • manually create a build XML file with exotic characters outside of PoB,
  • exercise the build rename, copy and removal UI to see that they still work,
  • move the text caret around in the build rename UI without splitting any codepoints,

Numeric separators:

  • artificially set the numeric separators to Unicode codepoints in Settings.xml,
  • observe how the sidebar and calcs UI draws them correctly.

Link to a build that showcases this PR:

n/a

After screenshot:

image
image

zao added 4 commits April 19, 2024 03:58
As the runtime is going to support Unicode installation locations and
build directories, some UTF-8 text is going to reach the Lua side of
the project. This includes the script path, the user path, any paths
yielded from file searches and also imported character names from
accounts.

Care needs to be taken in many places where string operations are
performed as no longer does a byte necessarily correspond to a single
character and anything that truncates, reverses or otherwise slices
strings could need an audit.

This change fixes cursor movement in `EditControl`s with the arrow keys
as those historically used string matching and byte offsets. It also
ensures that the use of arbitrary Unicode codepoints as decimal and
thousands separators works correctly as the previous code used unaware
reversing and slicing.
Historical UI code uses empty text controls with invalid font sizes as anchors for other UI as that used to be benign with older font technology. While the runtime should be hardened against such use, this replaces the controls with more appropriate base types to better communicate intent.
The updater is a fixed piece of older code that uses a Lua runtime that
only handles paths that are representable in the user's text codepage.

As the software may be installed in a location that cannot be expressed
in that way, to mitigate the problem we turn all the paths in the
update op-files into relative paths. That way as long as we never use
exotic codepoints in our own paths it should be able to apply them
cleanly and restart Path of Building afterward with a relative path.

The updater executable can ironically enough not be updated at all with
the related type of runtime hacks we introduced in SimpleGraphic as the
updater deadlocks in updating itself. We have to work around its
shortcomings in how we produce the op-files and possibly the update
application script that runs under that limited runtime.
Upon removing support for several file formats like GIF and BLP from the
SimpleGraphic runtime, we noticed that there were some assets that had
incorrect file extensions and loaded only thanks to file format
detection ignoring extensions.

As the actual file format loader for GIF was removed, these stealth GIFs
are now losslessly converted to PNG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical Hidden from release notes user-interface Changes that only affect the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants