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

ASTextKitFontSizeAdjuster longest word #94

Open
davevdveen opened this issue May 1, 2017 · 0 comments
Open

ASTextKitFontSizeAdjuster longest word #94

davevdveen opened this issue May 1, 2017 · 0 comments

Comments

@davevdveen
Copy link

davevdveen commented May 1, 2017

The ASTextKitFontSizeAdjuster class tries to find te longest word to prevent character wrapping. This is done by finding the longest word in terms of character count. For a monospaced font this is correct but not for proportional font. For instance the word 'Thanksgiving' counts 12 characters but is in terms of size longer than 'Tellerfleisch' which counts 13 characters.

So you may end up in the following situation:
Thanksgivin
g
Tellerfleisch

Also a NSAttributedString can contain multiple styles. The current implementation assumes that the style of first occurrence of the longest word is the style of the complete text. So the current implementation isn't accurate.

I implemented a version which checks the actual width of the different words. This comes with a performance penalty, but is accurate.

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

No branches or pull requests

1 participant