Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

[TextKit] Fix text layout issue for CJK laungages #3026

Merged
merged 2 commits into from Feb 15, 2017

Conversation

yxztj
Copy link
Contributor

@yxztj yxztj commented Feb 14, 2017

A quick fix for CJK language layout issue, which is supposed to bring no side effect. Has been tested in our production for one month.
See #2894

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@yxztj
Copy link
Contributor Author

yxztj commented Feb 14, 2017

Just signed the CLA.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link
Contributor

@Adlai-Holler Adlai-Holler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yxztj Thanks for the diff! As a potentially smaller change, is it sufficient to instead call one of these?

  • ensureAttributesAreFixedInRange:
  • fixAttributesInRange:
  • invalidateAttributesInRange:

If not, it would be great to see profiling results from this change if possible. Text nodes are some of the most common nodes that are used, and changing the attributed string of NSTextStorage could be a quite expensive operation.

@yxztj
Copy link
Contributor Author

yxztj commented Feb 15, 2017

@Adlai-Holler Thanks for the suggestions. I tried the 3 methods you suggested but none of them worked..

After some profiling(copy and run the related code, from _textStorage init to setAttributedString 30000 times), setting attributedString both in init and later is doubling the execution time than before.

So I changed the code: always init _textStorage with no parameter, and set attributedString later. Running the profiling code this time I can see the execution time is very close to before.

@appleguy
Copy link
Contributor

@yxztj awesome, thanks for investigating this issue and then also guiding your work via profiling! An allstar contributor :), really appreciate how you've helped out over time.

Both @Adlai-Holler and @maicki are the de-facto experts on ASTextNode these days, so I'll leave it to them to make the call on safety of taking this change. However, we're all interested in seeing improvements to a few nagging correctness issues that still affect the component and so will seriously consider any PRs in this area.

One last suggestion: consider adding this to examples_extra/TextStressTest? Not a blocker for this PR, just a suggested followup. I've been trying to collect our known ASTextNode bugs there and then the fixes so we can run the app to check them. Of course it would be better to add snapshot tests for all of these, but either one would be a great step.

@Adlai-Holler
Copy link
Contributor

Great work @yxztj, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants