Fix text_driver returning wrong size for non Latin-1 characters #170
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.
PR duplicated from thoth-tech#40
Commits were rebased.
Description
sk_text_size
usesTTF_SizeText
internally to calculate the size of the text. This function is only expecting Latin-1 encoded text, and as such doesn't work properly when given most Unicode characters. This PR just replacesTTF_SizeText
withTTF_SizeUTF8
, which makes it take Unicode now instead, matching the rest of thetext_driver.cpp
functions.Type of change
How Has This Been Tested?
The size returned from
sk_text_size
with various non English strings has been checked and shown to properly fit the returned text. Without the commit, the width returned is too long.Can be tested with the following:
With the commit, the rectangles surround the text accurately - without, the rectangle around the Japanese text is too long.
Testing Checklist
Checklist