magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Custom font 404 on product page

Open devhn opened this issue 10 years ago • 3 comments

I have a custom theme with custom fonts included (Magento 2.0.2). I've used Luma as a base theme and changed the current Open Sans font for a custom one. All works fine except upon opening the product page where the custom fonts get loaded twice, once 200 and other 404. Successfully loaded fonts have a correct path but other (404) are coming from /mage/ folder: Console error:

GET http://domain.com/pub/static/frontend/vendor/theme/en_US/mage/fonts/custom/my_custom_font.woff2 celeste-sports-bra:2117 GET http://domain.com/pub/static/frontend/vendor/theme/en_US/mage/fonts/custom/my_custom_font.woff2 celeste-sports-bra:1 GET http://domain.com/pub/static/frontend/vendor/theme/en_US/mage/fonts/custom/my_custom_font.woff celeste-sports-bra:1 GET http://domain.com/pub/static/frontend/vendor/theme/en_US/mage/fonts/custom/my_custom_font.woff celeste-sports-bra:1 GET http://domain.com/pub/static/frontend/vendor/theme/en_US/mage/fonts/custom/my_custom_font.ttf celeste-sports-bra:1 GET http://domain.com/pub/static/frontend/vendor/theme/en_US/mage/fonts/custom/my_custom_font.ttf 404 (Not Found)

I have tried:

  • cleaning all the caches (Magento and browser)
  • redeploying the static files
  • installed a clean version of M2 and tryed my theme there.

This happens only to non-icon fonts, custom icons are working fine.

devhn avatar Mar 07 '16 08:03 devhn

Hi, @bb8d!

Could you please provide steps to reproduce this issue: how exactly and where do you include your custom font?

zanilee avatar Mar 09 '16 13:03 zanilee

As there are no new updates from reporter, issue will be closed.

MomotenkoNatalia avatar Mar 28 '16 12:03 MomotenkoNatalia

Same issue here on magento 2.2.5

I found what is causing the problem

In the file lib/web/mage/gallery/gallery.less

There is this line

@import '../../css/source/_variables.less'; // Local theme variables

That import the theme variables, the thing is the theme usually defines fonts and some other things in those files and all with a relative path..

So the theme shouldn't define fonts and other things in _variables.less but in _extends.less and import that file in the style.less

This thread talks about the same issue https://magento.stackexchange.com/questions/172192/why-does-gallery-less-include-theme-less

Tofandel avatar Jul 18 '18 10:07 Tofandel