Wildly bombed. Developing a website on yii2. There was a need to connect third-party fonts. Generated through fontsquirrel web font generator web fonts. Put it in the web/fonts folder. Created a web/css/fonts.css following content:

 @font-face { font-family: 'open_sansregular'; src: url('../fonts/opensans-regular-webfont.woff2') format('woff2'), url('../fonts/opensans-regular-webfont.woff') format('woff'); font-weight: normal; font-style: normal; } 

AppAsset looks like this:

 class AppAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [ 'css/font-awesome.min.css', 'css/fonts.css', 'css/site.css', 'css/login.css', ]; public $js = [ 'js/jquery.bootstrap-autohidingnavbar.min.js' ]; public $depends = [ 'yii\web\YiiAsset', 'yii\bootstrap\BootstrapPluginAsset', ]; } 

Well, in site.css looks like this:

 body { background-color: #FAFAFA; font-family: 'open_sansregular', sans-serif; } 

The result is zero. The most interesting thing is that I can not connect the fonts.css file at all - the desktop chrome itself will somehow find them. Other browsers (including mobile chrome) do not pull up fonts. In the source code of the page everything is connected in the right order. I do not understand what's what. Cache cleaned millions of times ..

UPD: font awesom works great ..

1 answer 1

Still overcome the problem.
1. Replaced the converter with transfonter.org. The previous one somehow broke the Russian font. 2. It is necessary to edit that css file with the pens that the converter left us, namely: this convector calls all the fonts the same, so we rule each font-family with the pens and edit the font url (and this is the most fun).

What is fun? If you set up your server to look in the web folder by default, then you should be fine. I did not have such an opportunity and I solved this problem through .htaccess (which is copied on a popular site). And apparently there are some problems there, since the human url to the fonts looks like this: '../fonts/font-name.blabla' , and my (working) one is: '../web/fonts/font-name.blabla'

Well, that's all, the day I killed for it ..