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

Miscalculation when using custom fonts #80

Open
danielbitzer opened this issue Mar 31, 2016 · 6 comments
Open

Miscalculation when using custom fonts #80

danielbitzer opened this issue Mar 31, 2016 · 6 comments

Comments

@danielbitzer
Copy link

Thanks for developing this amazing script!

I just wanted to flag this issue in case anyone else has experienced it.

I only notice the issue when loading a custom font (from MyFonts) where the text is be balanced across too many lines, so text that could easily fit on 2 lines would render over 3 lines.

I think the issue can be traced back to the nowrapHeight calculation. I've fixed the issue for myself by changing line 313 from $this.css('line-height', 'normal'); to $this.css('line-height', '1');

@redmunds
Copy link
Contributor

redmunds commented Jul 3, 2016

@danielbitzer Sorry for the delayed repsonse. Thanks for the info. I will keep this in mind for future changes.

@carasmo
Copy link

carasmo commented Aug 31, 2018

Thank you for the fix to '1' I found the word 'normal' in the current vanilla js version and it works great now!

@carasmo
Copy link

carasmo commented Aug 31, 2018

Oh well. Works great on headlines, but on small chunks of text that I use it on, it's very odd. Too bad this can't be tweaked per class with some arguments.

@daveyjones
Copy link

daveyjones commented May 10, 2019

@redmunds Here's a fiddle that demonstrates this behavior:

https://jsfiddle.net/jsL7qh96/

Note that I was able to fix this by removing this line from the source:

// remove line height before measuring container size
el.style.lineHeight = 'normal';

Out of curiosity, why remove the line height in the first place?

@redmunds
Copy link
Contributor

@daveyjones Normalizing the line-height fixes the case where line-height is much larger than font-size. See LINE HEIGHT TEST case in test/test1.htm .

@mattcoz
Copy link

mattcoz commented Oct 27, 2021

I can confirm that changing it to 1 instead of normal fixes it for me too, thanks.

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

5 participants