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 oblique type bug for Chinese #1147

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

shengyang998
Copy link

@shengyang998 shengyang998 commented Mar 1, 2019

The bug is: When you type Chinese (or other language that has not italic type) and English at the same line with italic format enable, and then when you delete all the English characters, the italic format button won't be able to hit again.

To test:
Just type Chinese and English with italic open and delete all the English characters.
After doing so, try to hit the italic format button again and you will see the different.

The bug is: When you type Chinese and English at the same line with `oblique` format enable, and then when you delete all the English characters, the `oblique` format button won't be able to toggle again.
@SergioEstevao
Copy link
Contributor

@shengyang998 thank you for the report and the PR! Do you mind adding a unit test to validate or just shows us some text where the problem occurs?

@shengyang998
Copy link
Author

@shengyang998 thank you for the report and the PR! Do you mind adding a unit test to validate or just shows us some text where the problem occurs?

Here is my test case:

  1. Type this in (with italic format button turned on)
早上好 SergioEstevao
  1. and then delete backward until the cursor hit the Chinese character, like:
早上好
     ^
  1. right now the italic format button should be turned off automatically and you can never toggle it again.

The problem is caused by return self in guard let. So I decided to remove the traitItalic and return a properly initialized UIFont instead.

Moreover, the problem is not only for Chinese character, any character that don't have a Italic trait may cause the problem. However, I don't have resources and test them through. That is the reason why I use the code to specify the font name PingFangSC with .postscriptName.hasPrefix(".PingFangSC") (SC is for Simplified Chinese).

There should be an improvement in my code, but I am not a linguist and don't have too much time to deal with all kind of languages.

Yes, it would be better if there is a method to test whether a font has a italic trait or not, but I did not find it. If you find a better solution, let me know. Thanks. ❤️

@maxme
Copy link
Contributor

maxme commented Sep 15, 2020

We recently switched the project license. Aztec is now under the MPL v2.0. More info on this ticket: #1305

If this PR gets merged, the code will be under the MPL v2.0.

@SergioEstevao SergioEstevao removed their request for review January 23, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants