You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
This should be a TextKit bug, based on which ASTextNode is built.
To repro:
add a simple UILabel and a ASTextNode
fill them with the same attributedString
overlap each other and see if them coincide, which they should
Repro
(I've created a sample project, render the string is UILabel in blue and ASTextNode in black. Each view has a border with the same color as their content)
Everything looks good for English:
The UILabel and ASTextNode coincide completely. Since the black ASTextNode is drawn upon the blue UILabel, we can barely see the latter one.
When it comes to Chinese, we can see that the 2 strings don't fully coincide. The blue one goes a little bit down, and has a larger frame than black one.
The same goes for Korean:
The black frame is 6pt short in height if you print in console, while the height of blue frame exactly matches lineHeight property of the font. So the black frame is wrong, seems it incorrectly matches the pointSize of the font.
For English string, both blue and black frame matches lineHeight of the font.
Quick Fix
Fortunately if you add a "useless" line of code right after [_textStorage addLayoutManager] in ASTextKitContext.mm, all issues go away:
_testStorage should have just been initialized with the attributedString provided, so setting the same string again should be useless. But it does magically fix the sizing issue:
Sadly Apple has been ignoring my bug report for months.
Also the issue looks very similar to #1013 , hope the fix also applies to that.
Please let me know if you need any additional information, or you prefer a PR.
The text was updated successfully, but these errors were encountered:
@yxztj thanks for the sample project and the fix! I'm really surprised this actually makes a difference, but it looks like your new implementation is strictly better / more correct if there is some kind of undocumented order-of-operations dependency in the Apple frameworks about this.
It's great to have this issue linked directly in the source code, as it provides a concise summary of why the code structure is important to maintain.
This should be a TextKit bug, based on which ASTextNode is built.
To repro:
Repro
(I've created a sample project, render the string is UILabel in blue and ASTextNode in black. Each view has a border with the same color as their content)
Everything looks good for English:
The UILabel and ASTextNode coincide completely. Since the black ASTextNode is drawn upon the blue UILabel, we can barely see the latter one.
When it comes to Chinese, we can see that the 2 strings don't fully coincide. The blue one goes a little bit down, and has a larger frame than black one.
The same goes for Korean:
The black frame is 6pt short in height if you print in console, while the height of blue frame exactly matches lineHeight property of the font. So the black frame is wrong, seems it incorrectly matches the pointSize of the font.
For English string, both blue and black frame matches lineHeight of the font.
Quick Fix
Fortunately if you add a "useless" line of code right after [_textStorage addLayoutManager] in ASTextKitContext.mm, all issues go away:
_testStorage should have just been initialized with the attributedString provided, so setting the same string again should be useless. But it does magically fix the sizing issue:
Sadly Apple has been ignoring my bug report for months.
Also the issue looks very similar to #1013 , hope the fix also applies to that.
Please let me know if you need any additional information, or you prefer a PR.
The text was updated successfully, but these errors were encountered: