Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@olliwang
Copy link
Contributor

iOS uses the Hiragino Sans font as the default Japanese font. However, this font abuses the line gap property like many fonts.

  • Adobe fonts usually treat line gap as the line height.
  • Most other western fonts sets line gap to 200.

Back to the Hiragino font. The font family always sets line gap to 500 no matter what while the font height (ascent - descent) is only 1000. Which causes the spaces between lines are super big.

Screen Shot 2020-02-28 at 5 31 10 PM

As mentioned here https://stackoverflow.com/questions/5414730/custom-installed-font-not-displayed-correctly-in-uilabel, Apple ignores the line gap property since iOS 7, and a workaround to fix this issue is to add the line gap to the ascent and we'll be fine to ignore the line gap property. Now the result looks much normal.

Screen Shot 2020-02-28 at 5 30 27 PM

This change doesn't affect the alignment, either.

linegap

@memononen
Copy link
Owner

How will this affect how western multiline text is rendered? i.e. the nanovg demo.

@olliwang
Copy link
Contributor Author

This doesn't affect western multiline at all.

Screen Shot 2020-02-28 at 6 09 22 PM

PS. In my previous PR of fixing font size, the font size now matches what you saw on other native apps. The font used by the demo was affected by this because the font sizes were set to a value bigger than they actually were. I'm still fixing the font sizes and will submit another PR later.

@olliwang
Copy link
Contributor Author

olliwang commented Feb 28, 2020

Just submitted a PR to fix demo's font size. #564

The result looks exactly the same with or without this PR's changes of fixing the line gap issue.

BEFORE:
Screen Shot 2020-02-28 at 6 22 05 PM

AFTER:
Screen Shot 2020-02-28 at 6 31 23 PM

@memononen memononen merged commit db50e12 into memononen:master Feb 28, 2020
@memononen
Copy link
Owner

Thanks for the fix!

@olliwang
Copy link
Contributor Author

Thanks for the quick merging. Cheers! 🥂

@olliwang olliwang deleted the linegap branch February 28, 2020 13:11
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

Successfully merging this pull request may close these issues.

2 participants