Why does one of these font-face render in IE8, but

2019-01-13 11:37发布

问题:

Why does this fontface render in IE8:

@font-face {
  font-family: 'Aller';
  src: url('aller_rg-webfont.eot');
  src: url('aller_rg-webfont.eot?#iefix') format('embedded-opentype'),
       url('aller_rg-webfont.woff') format('woff'),
       url('aller_rg-webfont.ttf') format('truetype'),
       url('aller_rg-webfont.svg#AllerRegular') format('svg');
  font-weight: normal;
  font-style: normal;
}

And this does not:

@font-face {
  font-family: 'Champagne';
  src: url('champreg-webfont.eot');
  src: url('champreg-webfont.eot?#iefix') format('embedded-opentype'),
       url('champreg-webfont.woff') format('woff'),
       url('champreg-webfont.ttf') format('truetype'),
       url('champreg-webfont.svg#Champagne&LimousinesRegular') format('svg');
  font-weight: normal;
  font-style: normal;
}

I really can't figure it out. All other browsers work fine, obviously.

回答1:

Try creating a new .eot file with one of the others using an online woff/ttf/svg to eot convertor.

  • http://www.font2web.com/
  • http://www.fontsquirrel.com/fontface/generator <- might have problems because they black list font names.

If this new file doesn't work, then it might be a problem with the font itself. Sometimes IE6-8 has a fit if the Fontname and Family Name are not the same within the actual font file. To fix it:

  • You'll need to download FontForge
  • Open up the font
  • From the menu, choose Element > Font Info
  • Ensure the Fontname, Family Name and Name for Humans are all the same
  • Save the font as a TTF or OTF and use an online convertor to spit out an EOT file.

Every issue I've had with font-face - if the CSS was correct - worked with one of the above two solutions, so good luck :-) Maybe even try saving the font without any changes in FontForge and converting that online before you fiddle with the name properties.



回答2:

  1. Added this to htaccess. "BrowserMatch MSIE best-standards-support Header set X-UA-Compatible IE=8 env=best-standards-support"
  2. trying to reconvert eot font
  3. doc compactibility mode chnage
  4. tried usleep function
  5. setInterval js
  6. add google html5 script
  7. call css in body part for ie8
  8. add data-icon class
  9. ad pseudo elements js
  10. add png & svg filters in css
  11. check font type Permission in server

but finally works when added

.sass and .less css

files happy coding... by sivakumar



回答3:

Under IIS (MVC environment) I had to add the following rule to my Web.config:

   <system.web>
    <httpHandlers>
      <add verb="GET" path="*.eot" type="System.Web.StaticFileHandler" />
      <add verb="GET" path="*.svg" type="System.Web.StaticFileHandler" />
      <add verb="GET" path="*.ttf" type="System.Web.StaticFileHandler" />
      <add verb="GET" path="*.woff" type="System.Web.StaticFileHandler" />
      <add verb="GET" path="*.otf" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>