Jump to content

can't load font in macOS MAMP local dev environment


protro
 Share

Recommended Posts

Using latest PW with Rockfrontend … I have in my custom.less

@font-face {
    font-family: 'Eurostile Extended';
    src:local('Eurostile Extended'),
        url('/site/templates/styles/fonts/eurostile-extended-regular.ttf') format('truetype');
    font-style: normal;
    font-weight: 300;
}

But the inspector shows

GET http://localhost:8888/mysite/site/templates/site/templates/styles/fonts/eurostile-extended-regular.ttf 404 (Not Found)

The path is correct and the files exist at the location. What am I missing ? I suspect the localhost:8888/mysite path is causing an issue.

Thank you

Edited by protro
Link to comment
Share on other sites

Looks like I solved the problem by changing the declaration. At least this path works on local now. Haven't test on production.

@font-face {
    font-family: 'Eurostile Extended';
    src:local('Eurostile Extended'),
        url('../styles/fonts/eurostile-extended-regular.ttf') format('truetype');
    font-style: normal;
    font-weight: 300;
}
Link to comment
Share on other sites

1 hour ago, protro said:

The path is correct

Really? ?

Quote
http://localhost:8888/mysite/site/templates/site/templates/styles/fonts/eurostile-extended-regular.ttf

Maybe check the root directory you set in Apache config. It looks like it's targeted on mysite/site/templates/ instead of mysite/.

Personally I use relative paths in CSS (url('../font/NotoSansDisplay-Regular.ttf')), but that doesn't matter, if I enter url('/site/templates/font/NotoSansDisplay-Regular.ttf') it works fine too since Apache root directory is set on parent directory of /site/.

Edited by da²
  • Like 1
Link to comment
Share on other sites

1 hour ago, protro said:

Using latest PW with Rockfrontend … I have in my custom.less

@font-face {
    font-family: 'Eurostile Extended';
    src:local('Eurostile Extended'),
        url('/site/templates/styles/fonts/eurostile-extended-regular.ttf') format('truetype');
    font-style: normal;
    font-weight: 300;
}

But the inspector shows

GET http://localhost:8888/mysite/site/templates/site/templates/styles/fonts/eurostile-extended-regular.ttf 404 (Not Found)

The path is correct and the files exist at the location. What am I missing ? I suspect the localhost:8888/mysite path is causing an issue.

Thank you

The path seems to be correct. I am using the same path in my font declarations:

@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Barlow Regular';
  font-style: normal;
  font-weight: 400;
  src: url('/site/templates/fonts/barlow-condensed-v12-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

I would try out this advice from @da²

1 hour ago, da² said:

Maybe check the root directory you set in Apache config. It looks like it's targeted on mysite/site/templates/ instead of mysite/.

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, da² said:

Maybe check the root directory you set in Apache config. It looks like it's targeted on mysite/site/templates/ instead of mysite/.

Thanks @Stefanowitsch @da²

I haven't done this before but yeah that looks like the issue.
Is this okay to change to the root (i.e. mysite/) without any unwanted downstream effects when deploying to production (with Duplicator module for instance) ?

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...