In order to properly display fonts at the front, the browser must use the correct http header to accept the font file. If the server does not have the required header information set, some browsers will not display an error or directly in the console.
May your server has been configured, you no longer need to touch anything. If not configured, then you need to pay attention to the following points:
First, modify the mime-type headers;
the second set CORS headers- only if you get the font file or html page from a different domain time. (* Note: If you do not CORS headers settings, you can direct the font file (path) embedded CSS styles if you go fontello site to the local then fontello.css in already done so.)
Here are the two main font server configuration support:
the Apache
Set the correct mime-type supports font file, add the following line to the server configuration file:
1 AddType application/font-sfnt otf ttf
2 AddType application/font-woff woff
3 AddType application/font-woff2 woff2
4 AddType application/vnd.ms-fontobject eot
If you can not modify the configuration file, then create a new * .htaccess file in your project, add the following settings:
Information set CORS headers:
<FilesMatch ".(eot|ttf|otf|woff|woff2)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
Nginx
Nginx server default font is not supported mime-type setting, and to .eot file mime-type is not correct. Find a place to mime-type set in the configuration folder. Typically, in the mimes.types file.
mine.types files are generally in /etc/ngix/mime.types, look for the next json file format, you can pull modify locally and then upload complete
search .eot, and add the following lines at its next setting:
1 application/font-sfnt otf ttf;
2 application/font-woff woff;
3 application/font-woff2 woff2;
4 application/vnd.ms-fontobject eot;
For information set CORS headers, add the following lines to your vhost configuration:
Find the file in ngix.conf and default.conf
location ~* \.(eot|otf|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
}
---------------------
Author: yypsober
Source: CSDN
Original: https: //blog.csdn.net/yypsober/article/details/52012577 Disclaimer: This article as a blogger original article, reproduced, please attach Bowen link!