Hi,

I'm using a localhost installation. This module admin pages are working fine. But i noticed that at code source, the printed value for fontyourface css is wrong, it's printing the physical path.

@import url("http://localhost/drupal7/sites/all/modules/ctools/css/ctools.css?kwq1q7"); @import url("http://localhost/drupal7/C%3A%5Cxampp%5Chtdocs%5Cdrupal7%5Csites%5Cdefault%5Cfiles%5Cfontyourface%5Cfont.css?kwq1q7"); So, how can i change it? thanks.
CommentFileSizeAuthor
#4 path.patch775 bytessreynen

Comments

carvalhar’s picture

PS:
if i manually access the css file, with the correct path, i can see that the CSS code is right.
http://localhost/drupal7/sites/default/files/fontyourface/font.css?kwq1q

h2 { font-family: 'AcknowledgementMedium'; }
body { font-family: 'ActionManRegular'; }
.field-items { font-family: 'Allerta'; }

sreynen’s picture

I'm pretty sure I know where the problem is, but I'm not yet sure how to solve it. The problem, I think, is with this code in the fontyourface_add_css_in_preprocess() function:

$full_path = drupal_realpath(file_build_uri($css_path));
$base_path = drupal_realpath('.');
$css_path = str_replace($base_path . '/', '', $full_path);

What that's doing is taking the file wrapper CSS path that gets passed into the function, which is something like "public://fontyourface/font.css" and converting it to the path to the CSS file relative to the base_path(), which is what drupal_add_css() takes, e.g. "sites/default/files/fontyourface/font.css". I haven't found any way to do this in Drupal 7, so I wrote the code above. I was worried it wouldn't be reliable when I wrote it and it sounds like it's not. Specifically, it looks like it fails on Windows, maybe because that slash is a backslash on Windows? I'm going to ask around more and see if there isn't a more platform-neutral way to do this with core D7 functions.

@carvalhar, if you're able to tell me what drupal_realpath('.') and base_path() each return on your Windows system, that would be useful.

carvalhar’s picture

Hi,

I got these values:
full_path = C:\xampp\htdocs\drupal7\sites\default\files\fontyourface\font.css
base_path = C:\xampp\htdocs\drupal7
css_path = C:\xampp\htdocs\drupal7\sites\default\files\fontyourface\font.css

I found a function:
conf_path()
http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/conf_path

It does check for the default directories, i suppose "files/fontyourface" will be the same always no?

I'm using this code and the url is working properly:

$css_path = conf_path() . "/files/fontyourface/font.css";

I got a url like: http://localhost/drupal7/sites/default/files/fontyourface/font.css?kwq1q7

BUT some fonts doesn't change, and some case i get a serif-bad-look very different from the font i choose.

AcknowledgementMedium -> Bad serif, wrong font (seens like a default browser font)
ActionManRegular -> doesn't change nothing
Allerta -> OK

BUT, i can see all 3 fonts working very well at admin preview.

Any way to solve it?

Thanks,
Carlos

sreynen’s picture

Status: Active » Needs review
StatusFileSize
new775 bytes

I'd rather not get into conf_path() as that's not necessarily related to the files directory. You could, for example, have your settings.php in sites/default and your files directory in sites/localhost/files or vice versa.

I think this patch should fix it. Let me know if it works for you.

Status: Needs review » Needs work

The last submitted patch, path.patch, failed testing.

sreynen’s picture

Status: Needs work » Needs review

I'm not sure why that patch is causing a fatal error on the test bot. It's working for me locally. Moving back to "needs review" status.

carvalhar’s picture

ok, it worked fine.

About the font problem, what do you think it should be? At preview they're ok...

sreynen’s picture

@carvalhar, which font provider are those fonts from?

sreynen’s picture

Title: printed style decaration has physical path [CSS] » CSS path broken on Windows servers

Making the title a little more descriptive, in case anyone else is having the same problem.

carvalhar’s picture

Font Squirrel 'AcknowledgementMedium'
Font Squirrel 'ActionManRegular'
Allerta KERNEST

The two that doesn't work are from Font Squirrel.

carvalhar’s picture

I noticed that if i enable this module's block, the content from Squirrel appears as a image, not text.

sreynen’s picture

Version: 7.x-1.0-beta2 » 7.x-1.0-beta3
Status: Needs review » Fixed

This patch is in beta 3, so I think the original issue here is fixed. @carvalhar, I think your other issue may have been fixed in #1038574: Font Squirrel fonts not loading. If you're still having problems with beta 3, please open a new issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.