Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Split text before font render issue

Recommended Posts

Hey guys,


Hoping someone can help me out.


My Problem: Split text is being applied before my font has actually rendered in the browser which results in abnormally large letter spacing. My assumption is the fallback font is being used for the split text calculation prior to my imported fonts being rendered in the browser (thus, when my fonts are rendered, they're not formatted correctly). I'm 90% sure this is the cause of my issue, although let me know me if otherwise! The issue occurs about 50% of the time (the other 50% renders as expected) and at the moment it's only happening on IOS Safari / Chrome (so far from what I've tested) which makes it hard to debug. I've also tested and found this problem occurs more frequently when my font loads slower than usual. The problematic font is loaded from AWS, although I've also had the same problem loading fonts from Google. 

I've seen questions regarding this issue thrown around a few times, although I couldn't seem to find a robust / official solution (mostly hacks or the use of the Webfontloader (https://github.com/typekit/webfontloader) which looks great, but I can't seem to get working). 


Here's an example of what I'm seeing: 






Has anyone got this figured out?

Thanks guys!

Link to comment
Share on other sites

It certainly sounds like you've diagnosed it well. I share your suspicions about the delayed font loading being the issue. I don't have time to research it in depth now, but if I were you I'd be looking for ways to listen for an event that's triggered when the font has loaded and rendered, and THEN do the SplitText thing. Maybe even have visibility:hidden until things are loaded (so you don't get that flash of unstyled text). 


I assume you've got the SplitText stuff as far down on the page as possible (like, in the source code I mean), right? 

  • Like 1
Link to comment
Share on other sites

Thanks for the advice, Jack!

Glad to say I figured out a solution this morning. I used font face observer (https://github.com/bramstein/fontfaceobserver) which is a library that allows you to fire a callback once particular fonts have been loaded (and it probably does some other things). Web font loader is an alternative to this, although it's a heavier library (and as mentioned above, I couldn't get this working anyway).

Still a bit puzzled as I use split text all the time and haven't come across this issue before. Anyway, this looks to be a pretty solid solution should anyone else happen to come across this :)

  • Like 2
Link to comment
Share on other sites

Excellent, thanks for sharing the solution. 


Happy tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.