Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey everyone,
I'm using two fonts from the google font library by adding them via @import in my css-file. After enabling the font submodule I can not recognize that anything has changed. Google Pagespeed Analysis also says that the two fonts are still blocking the rendering.
Is it required to use @font-face instead of @import or do I'm missing a special setting?
Comments
Comment #2
mikeytown2 CreditAttribution: mikeytown2 commentedThe async fontloader works by rewriting the css; if the css is externally imported then advagg can't rewrite it. Give @font-face a try, should do the trick. The
admin/config/development/performance/advagg/font
page, under "CSS files with external fonts" shows what CSS files and fonts are being async loaded.Comment #3
mikeytown2 CreditAttribution: mikeytown2 commentedMarking as fixed. re-open if I was mistaken.
Comment #5
bryancasler CreditAttribution: bryancasler as a volunteer commented@mikeytown2, followed your instructions and tried using @font-face to load local font ("Oswald") from one of the theme's CSS files.
Since "CSS files with external fonts" does not show Oswald listed, I assume that means it is not being Asynchronously loaded. Any suggestions?
Comment #6
bryancasler CreditAttribution: bryancasler commentedUpdating priority.
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commentedAssuming you've flushed the cache. Where's that CSS file located?
Comment #8
bryancasler CreditAttribution: bryancasler commentedI had flushed the cache, but checked again just to make sure. No change. Fonts are in their own folder within the theme.
Structure
theme/css/schemes/site-template.css
theme/fonts/Oswald-Regular.woff
Screenshot
http://d.pr/i/unNu
Comment #9
mikeytown2 CreditAttribution: mikeytown2 commentedCan you upload the CSS files that use the font so I can reproduce this issue?
Comment #10
bryancasler CreditAttribution: bryancasler commented@font-face is line 17
http://pastebin.com/raw/y8qRmtpC
Comment #11
bryancasler CreditAttribution: bryancasler commentedAs an experiment, I moved the font-face code into its own CSS file and then put that as first in the list within the theme's .info file. After flushing cache and confirming the new CSS file is loading, I checked what was listed under "CSS files with external fonts" and nothing had changed.
Comment #12
mikeytown2 CreditAttribution: mikeytown2 commentedQuick glance at this and these font's do not have a fallback; thus async font loading isn't going to work; it doesn't know what to use instead of Oswald.
These 2 have a fallback so they should be listed. Will see what happened. Most likely it's an issue with parsing font; above is font-family.
Comment #13
bryancasler CreditAttribution: bryancasler commentedThanks for the follow up! Eliminated the use of Font to simplify things, and added the fallbacks to font-family. Now they show up under "CSS files with external fonts". Despite that, the fallback is always used and I'm still not seeing a cookie being set by Font Face Observer or any of its files being loaded. I double checked that Font-Face Observer is in the correct location, with the correct naming, and all files are there.
Updated CSS
http://pastebin.com/raw/ZRtY2rVL
Adv Agg Settings
http://d.pr/i/S2xH
Comment #14
mikeytown2 CreditAttribution: mikeytown2 commentedThe external version of https://github.com/bramstein/fontfaceobserver is 2.x the 7.x-2.18 version and below only works with the 1.x version of fontfaceobserver. This is fixed in the latest dev of advagg.
Comment #16
mikeytown2 CreditAttribution: mikeytown2 commentedI've added in support for parsing font and font-family now. Updating to the latest dev of advagg should fix the issue with using the latest version of fontfaceobserver.
If you open the console you should see a js error with the versions that you're using.
Comment #17
bryancasler CreditAttribution: bryancasler commentedDoesn't seem to have resolved the issue. And now the Admin Theme has its font defaulting to the last fallback font listed in each of its definitions.
Going to keep playing around to see if I can provide any more concrete feedback.
Comment #18
mikeytown2 CreditAttribution: mikeytown2 commentedComment #19
bryancasler CreditAttribution: bryancasler commentedLogs are reporting the following:
Warning: file_get_contents(public://ctools/css/5bee440bb9f6b9b48aea1731a1edb727.css): failed to open stream: "DrupalPublicStreamWrapper::stream_open" call failed in advagg_font_admin_settings_form() (line 108 of /srv/bindings/bbf404295e8b4600915b63a91bda1bea/code/sites/all/modules/advagg/advagg_font/advagg_font.admin.inc).
I'm also still not seeing a font face observer JS being loaded or a cookie being set. If it matters, the site is on Pantheon.
Comment #20
mikeytown2 CreditAttribution: mikeytown2 commentedDo you see font data in the Drupal.settings.advagg_font variable in the js browser console?
That warning can be ignored; ctools creates and removes css files on a regular basis. This patch makes the errors go away; it doesn't solve the issue you're having.
Comment #22
mikeytown2 CreditAttribution: mikeytown2 commentedComment #23
mikeytown2 CreditAttribution: mikeytown2 commentedComment #25
mikeytown2 CreditAttribution: mikeytown2 commentedThis has been committed and should fix the issues.
Comment #26
bryancasler CreditAttribution: bryancasler commented@mikeytown, I'm seeing the font data in the JS console (see screenshot). I'm still seeing the custom font getting completely stripped from the generated CSS files for both the default and admin theme. Looks like it might be stripping any font name in quotes.
JS Console:: http://d.pr/i/14ar0
Cookies being loaded: http://d.pr/i/93CU
Async Font Loader Settings: http://d.pr/i/2Xm9
Input CSS with Custom Font
AdvAgg Output
This issue is also affecting the Seven admin theme.
Seven Theme Input
AdvAgg Output
Comment #27
mikeytown2 CreditAttribution: mikeytown2 commentedIn the outputed css there should be a new rule that has the stripped font in it. Cookie gets set via js. If the cookie isn't there; that's an issue with the external js lib getting loaded, or the local js not working; can also mean the font isn't being downloaded by the browser.
Comment #28
bryancasler CreditAttribution: bryancasler commentedConfirmed that the CSS is being loaded into another file. Didn't realize that was how it worked, sorry for the confusion.
As for the external/local JS of FontFaceObserver, I'm not sure why it's not loading. No errors are being kicked up by the page. Also no idea why the cookie isn't being set.
Anything I can do to help you troubleshoot further?
Comment #29
mikeytown2 CreditAttribution: mikeytown2 commentedTry loading the library locally. The admin page has instructions on how to do that.
Comment #30
bryancasler CreditAttribution: bryancasler commentedThe site has had a local copy this whole time. Even tried removing it to use the fallback, no change. Then re-uploaded a fresh download of the library, still no change. http://d.pr/i/lBVJ And the status report page reports that the library is up to date. http://d.pr/i/gGxB
Going to start removing JS libraries from the theme and see if a conflict is somehow happening.
Comment #31
mikeytown2 CreditAttribution: mikeytown2 commentedWill also say that the latest version is 2.0.5. I'm not sure how you're getting 2.0.4 for the external version as that gets it's info from https://cdn.rawgit.com/bramstein/fontfaceobserver/master/package.json
You might have some rules in your apache/nginx setup stripping etags or the last-modified header.
Comment #32
bryancasler CreditAttribution: bryancasler commentedThe server is showing that the current version is in the libraries folder, but as you can see from the screenshot it's getting 2.0.4 from somewhere.
Looking into this further, I found this Pantheon page that says:
If it's Pantheon's configuration that's causing the issue, then I'm afraid there's not much I can do about that.
Comment #33
mikeytown2 CreditAttribution: mikeytown2 commentedI should get a dev box setup so I can test it out over there.
Comment #35
mikeytown2 CreditAttribution: mikeytown2 commentedThis will make those issues go away. Will work on the font thing next
Comment #37
mikeytown2 CreditAttribution: mikeytown2 commentedThis has also been committed. I think the issue for you was that you don't have the libraries module installed. Will come back to this on monday as I don't see any cookies getting set.
Comment #38
bryancasler CreditAttribution: bryancasler commentedHey Mikeytown2, won't have time to test the patch until later in the week but the libraries module is definitely installed. And the Status page is even reporting the presence of fontfaceobserver (http://d.pr/i/gGxB).
Comment #39
mikeytown2 CreditAttribution: mikeytown2 commentedLooking into this and another issue that might be affecting you is if the css file with the font has the preprocess attribute set to false. You can get around this by installing the advagg_mod module and checking the "Enable preprocess on all CSS" button
Comment #41
mikeytown2 CreditAttribution: mikeytown2 commentedThis is a better status report. Also believe this is fixed; got this working on pantheon by using advagg_mod.
Comment #42
bryancasler CreditAttribution: bryancasler commentedTrying to update with the latest dev gives me the following error.
Parse error: syntax error, unexpected '[' in /srv/bindings/3d4644228b094e23a34065d19d8c87f8/code/sites/all/modules/advagg/advagg.install on line 2009
The site is running PHP 5.3.29
Also tried disabling Adv Agg modules, unintalling them, and reinstalling with the latest Dev but got the same error.
Comment #44
mikeytown2 CreditAttribution: mikeytown2 commentedThanks for the heads up on that! Don't know why it didn't throw an error on Pantheon.
http://cgit.drupalcode.org/advagg/commit/?id=b607976
Comment #45
mikeytown2 CreditAttribution: mikeytown2 commentedPHP 5.3 - https://www.drupal.org/pift-ci-job/520914
PHP 5.6 - https://www.drupal.org/pift-ci-job/520915