Hi!
I installed @font-your-face and enable everything in the module interface. But when i tried to enable a specific font in the UI, I always received this error message : "Font not found. Could not enable."
Did I forget to import something? Or is it a bug from the module?
Thank you for your help!
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | fontyourface-googledevtools.JPG | 123.86 KB | craigritchie |
Comments
Comment #1
sreynen commentedCan you give an example of a font this happens on, along with the provider?
Comment #2
Anaelle commentedSure. For example, it happens on Open Sans Condensed (Font Squirrel).
Comment #3
sreynen commentedWhat browser are you using? If you're able to use a web inspector to look at the HTTP request that happens when you click "enable", please post a screen shot of it here. Or if this is on a site I could access, you can also send me credentials via my contact form and I can check it directly.
Here's how this is supposed to work:
1) In the JavaScript, fontyourfaceEnableClick() gets the font ID (fid) from the HTML with
link.parent().attr('data-fid');2) The JavaScript then passes the fid with a POST request to admin/appearance/fontyourface/ajax/enable
3) The PHP looks at $_POST['fid'] and loads that font from the database.
That error happens when the incoming $_POST['fid'] is not found in the database, which means one of those 3 steps is going wrong. Either it's not getting the fid from the HTML, or it's not passing it correctly from JS to PHP, or it's not handling it properly in PHP.
Comment #4
craigritchie commentedSame issue here. Via both Chrome and Firefox, I've tried Bree Serif and Arimo (and a couple of others) from Google Web Fonts. I'm happy to look at a Web Inspector to troubleshoot, but I don't know what that is... can you describe how to get to the screen shot you need? Thanks.
Comment #5
sreynen commentedHere are instructions for how to use the network panel in Chrome:
https://developers.google.com/chrome-developer-tools/docs/network
The network panel should show the AJAX request to admin/appearance/fontyourface/ajax/enable and the headers of that request should show the data being sent.
Comment #6
craigritchie commentedOkay, I think the analysis is attached here. Three "undefined" requests.
Comment #7
sreynen commentedPlease click on one of those and get a screen shot of the headers for an individual request.
Comment #9
craigritchie commentedHere are the headers for all three, with my domain/dir X'd out:
Request URL:http://xxxx.xxx/xxxxx/admin/appearance/fontyourface/ajax/enable/undefined
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:application/x-www-form-urlencoded
Cookie:Drupal.toolbar.collapsed=1; Drupal.tableDrag.showWeight=1; __utma=160722927.1630144385.1328724441.1337058092.1337058122.11; __utmz=160722927.1337058122.11.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=site%3Axxxx.xxx%20xxx%20xx%20xxx; SESS43322c98eda9276bc0f3399024592433=n7E8l7XBjt_qe0W-NMcwF2oTtcdrFKDjUP40uPtCg9M; has_js=1
Host:xxxx.xxx
Origin:http://xxxx.xxx
Referer:http://xxxx.xxx/admin/appearance/fontyourface/browse/google_fonts_api?re...
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
X-Requested-With:XMLHttpRequest
Response Headersview source
Cache-Control:no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Language:en
Content-Type:application/json
Date:Mon, 28 May 2012 15:33:40 GMT
ETag:"1338219220"
Expires:Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive:timeout=10, max=29
Last-Modified:Mon, 28 May 2012 15:33:40 GMT
Server:Apache
Transfer-Encoding:chunked
Vary:Accept-Encoding
Request URL:http://xxxx.xxx/admin/appearance/fontyourface/ajax/enable/undefined
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:application/x-www-form-urlencoded
Cookie:Drupal.toolbar.collapsed=1; Drupal.tableDrag.showWeight=1; __utma=160722927.1630144385.1328724441.1337058092.1337058122.11; __utmz=160722927.1337058122.11.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=site%3Axxxx.xxx%20xxx%20xx%20xxx; SESS43322c98eda9276bc0f3399024592433=n7E8l7XBjt_qe0W-NMcwF2oTtcdrFKDjUP40uPtCg9M; has_js=1
Host:xxxx.xxx
Origin:http://xxxx.xxx
Referer:http://xxxx.xxx/admin/appearance/fontyourface/browse/google_fonts_api?re...
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
X-Requested-With:XMLHttpRequest
Response Headersview source
Cache-Control:no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Language:en
Content-Type:application/json
Date:Mon, 28 May 2012 15:33:40 GMT
ETag:"1338219220"
Expires:Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive:timeout=10, max=30
Last-Modified:Mon, 28 May 2012 15:33:40 GMT
Server:Apache
Transfer-Encoding:chunked
Vary:Accept-Encoding
Request URL:http://xxxx.xxx/admin/appearance/fontyourface/ajax/enable/undefined
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:application/x-www-form-urlencoded
Cookie:Drupal.toolbar.collapsed=1; Drupal.tableDrag.showWeight=1; __utma=160722927.1630144385.1328724441.1337058092.1337058122.11; __utmz=160722927.1337058122.11.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=site%3Axxxx.xxx%20xxx%20xx%20xxx; SESS43322c98eda9276bc0f3399024592433=n7E8l7XBjt_qe0W-NMcwF2oTtcdrFKDjUP40uPtCg9M; has_js=1
Host:xxxx.xxx
Origin:http://xxxx.xxx
Referer:http://xxxx.xxx/admin/appearance/fontyourface/browse/google_fonts_api?re...
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
X-Requested-With:XMLHttpRequest
Response Headersview source
Cache-Control:no-cache, must-revalidate, post-check=0, pre-check=0
Connection:close
Content-Language:en
Content-Type:application/json
Date:Mon, 28 May 2012 15:33:40 GMT
ETag:"1338219220"
Expires:Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified:Mon, 28 May 2012 15:33:40 GMT
Server:Apache
Transfer-Encoding:chunked
Vary:Accept-Encoding
Comment #10
sreynen commentedOkay, so that narrows down the problem to either the JavaScript or the HTML. Let's check the HTML next. To do that, right-click (or control-click) on the footer of a font at admin/appearance/fontyourface/browse and select "Inspect Element" You should see something like this:
<div class="fontyourface-footer enabled-no" data-fid="4249"><a href="/admin/appearance/fontyourface/enable/4249%3Fdestination%3Dadmin/appearance/fontyourface/browse/font_awesome" class="enable-link">Enable</a></div>Please take a screenshot of what you see, or otherwise add the HTML here.
Comment #11
craigritchie commented<div class="fontyourface-footer enabled-no" data-fid="1"><span thmr="thmr_30"><a href="http://xxxxx.com/xxxx/#overlay=admin/appearance/fontyourface/enable/1%253Fdestination%253Dadmin/appearance/fontyourface/browse/google_fonts_api" class="enable-link">Enable</a></span></div>Comment #12
sreynen commentedOkay, so the only difference I see there is you're using Overlay. I'll try with that on and see if it's related. If it's not Overlay-related, I think we've narrowed it down to a JavaScript problem.
Comment #13
craigritchie commentedI just tried it without the overlay, still didn't work.
Comment #14
sreynen commentedI also tested with overlay, and I'm not seeing the error. The problem seems to be in the JavaScript file at [module_directory]/fontyourface/modules/fontyourface_ui/js/browse.js, in the fontyourfaceEnableClick() function. To narrow it down further, I'll need someone who is seeing the error to debug that file with console.log messages. Specifically, something like this:
And then screenshots of what gets output in your browser's JS console.
Comment #15
craigritchie commentedI'm no JavaScript wiz. Do I add those lines to that function and then try again? Where will the output appear?
Comment #16
sreynen commentedThe same window you used to see the network traffic has a "Console" tab at the top, which is where console.log() output goes. And yes, you just need to replace the current code with that's above. The current code should look like this:
Comment #17
sreynen commentedComment #18
craigritchie commentedComment #19
craigritchie commentedComment #20
sreynen commentedI think I see the problem now, and it's actually in #11, which has an extra span I didn't notice before. Rather than figure out where that span is coming from and how to get rid of it, let's just work around it. Try changing this line:
var fid = link.parent().attr('data-fid');To this:
var fid = link.parents('.fontyourface-footer').attr('data-fid');And see if that fixes it for you.
Comment #21
craigritchie commentedOh, that span is from the Theme Developer module. I'll try turning that module off and see if the font choice works.
Comment #22
craigritchie commentedOh, that span is from the Theme Developer module. I'll try turning that module off and see if the font choice works.
Comment #23
craigritchie commentedDone! Turning off the Theme Developer module and enabling a font appears to have worked. Thanks!
Comment #24
sreynen commentedOkay, I'm going to leave this open as a feature request so we can make it work even with that module enabled. Probably a pretty common use case to use the two together.
Comment #25
Drave Robber commentedIt seems Theme Developer has changed its manners to be less intrusive - the span is now appended after the div, not inserted inside it:
I can enable and disable fonts without problems. Thus, this issue is not reproducible anymore.
Feel free to reopen if you can reproduce it.
(And thanks to the developers of Theme Developer!)