Need some help with scrollHeight of a font. #58
Unanswered
DrHeinzDoofenshmirtz
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Sounds like that font is not configured correctly, or you might not be waiting for the webfont to load before doing the fitting. Try introducing a delay, or compensate otherwise with reduced or additional padding. Other than that, I don't think there's much this library can do. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi.
I have a case where I can't get the text fitting to work. textFit is diffinitely the best function for this that I have found.
But I have this case, and I am not exactly sure what the problem is, but I have an idea that it is the font.
So, I basically just a div container (70x70px) with a paragraph
insite of it holding some text.
The p element is set to fit the container and have some padding all the way around (8px), which means the content actual content area is 54x54px.
When I try to debug the binary search fit part of the function, I can see that scrollHeight of the textFitted span does not correspond to the actual height, when I manually set the font-size afterwards and inspect the height.
I am using a font from Google Fonts called Orbitron, and I think it might be the reason. The font is fine, but maybe it has a setting that makes it difficult for scrollHeight to show the correct value?
Note: When I am using the normal sans-serif font everything works perfectly on the pixel.
I hope someone can help me, ask the right questions, and point me in the right dirrection.
Best
Matt
Beta Was this translation helpful? Give feedback.
All reactions