Internet Explorer @font-face is failing

前端 未结 15 1326
甜味超标
甜味超标 2020-11-27 18:07

I\'m trying to get Internet Explorer to render my pretty fonts. It\'s not working. They work fine in Firefox and I can see in my Apache access logs that IE has pulled the fo

相关标签:
15条回答
  • 2020-11-27 18:48

    This worked for me:

    @font-face {
        font-family : 'din-pro';
        src         : url('../fonts/din/DINPro-Medium.woff') format('woff');
        src         : url('../fonts/din/DINPro-Medium.otf') format('otf');
        src         : url('../fonts/din/DINPro-Medium.ttf') format('truetype');
        font-weight : 500;
        font-style  : normal;
    }
    
    @font-face {
        font-family : 'din-pro';
        src         : url('../fonts/din/DINPro-Regular.woff') format('woff');
        src         : url('../fonts/din/DINPro-Regular.woff2') format('woff2');
        src         : url('../fonts/din/DINPro-Regular.ttf') format('truetype');
        font-weight : 400;
        font-style  : normal;
    }
    @font-face {
        font-family : 'din-pro-ie';
        src         : url('../fonts/din/DINPro-Regular.eot?');
        font-weight : 400;
        font-style : normal;
    }
    @font-face {
        font-family : 'din-pro-ie';
        src         : url('../fonts/din/DINPro-Medium.eot?');
        font-weight : 500;
        font-style : normal;
    }
    

    Notice that I defined the font for IE seperately with a -ie suffix. When using the font I would do something like p { font-family : din-pro, din-pro-ie }. Tested and working from IE5 forward using emulation.

    0 讨论(0)
  • 2020-11-27 18:54

    this code could solve my problem in IE:

      @font-face {
          font-family: 'kurdish';
          src: url('font/zkurd_aras.eot?') format('eot'), url('font/zkurd_aras.woff') format('woff'), url('font/zkurd_aras.ttf') format('truetype');}
    
    0 讨论(0)
  • 2020-11-27 18:55

    You could convert your TTF font to the modern formats (ie. WOFF) using Transfonter and then use a strong @font-face like this:

    @font-face {
      font-family: 'MyWebFont';
      src: url('webfont.eot'); /* IE9 Compat Modes */
      src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
           url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
           url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
           url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
           url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    }
    

    Source: https://css-tricks.com/snippets/css/using-font-face/

    0 讨论(0)
  • 2020-11-27 18:56

    What worked for me is the following declaration:

    @font-face {
        font-family: 'Frutiger45LightBoldItalic';
        src: local('☺'), url('../font/frutiger-bolditalic-webfont.woff') format('woff'), url('../font/frutiger-bolditalic-webfont.ttf') format('truetype'), url('../font/frutiger-bolditalic-webfont.svg#webfontR2tDy7QH') format('svg'), url('../font/frutiger-bolditalic-webfont.eot');
    }
    

    So there is only 1 src attribute and .eot is at the end of it, without question mark.

    What I tried before and didn't work:

    • putting .eot on a separate line (before or after the other src)
    • putting a question mark after .eot
    0 讨论(0)
  • 2020-11-27 18:58

    One thing that is special about IE is that it requires the font-family name to be the exact same as the name found in the font's properties. While Chrome and others let you name the font-family what you want, that's not the case for IE

    0 讨论(0)
  • 2020-11-27 19:00

    I was having the same problem as panas. I converted from ttf to eot using onlinefontconverter.com. Well, it seems that was the problem: I just tryied fontsquirrel.com as atsjr pointed out and everything is working fine!

    0 讨论(0)
提交回复
热议问题