Wait for fonts to load before rendering web page

Since nobody mentioned that, I believe this question needs an update. The way I managed to solve the problem was using the “preload” option supported by modern browsers. In case someone does not need to support old browsers. <link rel=”preload” href=”https://stackoverflow.com/questions/4712242/assets/fonts/xxx.woff” as=”font” type=”font/woff” crossorigin> some useful links with more details: https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content http://www.bramstein.com/writing/preload-hints-for-web-fonts.html

How to know if a font (@font-face) has already been loaded?

Now on GitHub: https://github.com/patrickmarabeas/jQuery-FontSpy.js Essentially the method works by comparing the width of a string in two different fonts. We are using Comic Sans as the font to test against, because it is the most different of the web safe fonts and hopefully different enough to any custom font you will be using. Additionally we … Read more

Amazon S3 CORS (Cross-Origin Resource Sharing) and Firefox cross-domain font loading

Update September 10, 2014: You shouldn’t need to do any of the query string hacks below anymore since Cloudfront properly supports CORS now. See http://aws.amazon.com/blogs/aws/enhanced-cloudfront-customization/ and this answer for more info: https://stackoverflow.com/a/25305915/308315 OK, I finally got the fonts working using the config below with a little tweak from examples in the documentation. My fonts are … Read more

CSS @font-face not working with Firefox, but working with Chrome and IE

LOCALLY RUNNING THE SITE (file:///) Firefox comes with a very strict “file uri origin” (file:///) policy by default: to have it to behave just as other browsers, go to about:config, filter by fileuri and toggle the following preference: security.fileuri.strict_origin_policy Set it to false and you should be able to load local font resources across different … Read more

How to add multiple font files for the same font?

The solution seems to be to add multiple @font-face rules, for example: @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans.ttf”); } @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans-Bold.ttf”); font-weight: bold; } @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans-Oblique.ttf”); font-style: italic, oblique; } @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans-BoldOblique.ttf”); font-weight: bold; font-style: italic, oblique; } By … Read more

How to add an Access-Control-Allow-Origin header

So what you do is… In the font files folder put an htaccess file with the following in it. <FilesMatch “\.(ttf|otf|eot|woff|woff2)$”> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin “*” </IfModule> </FilesMatch> also in your remote CSS file, the font-face declaration needs the full absolute URL of the font-file (not needed in local CSS files): e.g. @font-face { … Read more