Display text with two language in webpage with different fonts with font-face at rule in css

和自甴很熟 提交于 2021-01-27 15:50:38

问题


My web page displays Persian text using the Yekan font as expected. Why does the English text incorrectly use a font other than Alger?

@font-face { <!-- Persian Font -->
        font-family: Yekan;
        src: url(Fonts/BYekan.ttf);
        unicode-range:U+0600-06FF;
    }
    @font-face { <!-- English Font -->
        font-family: Alger;
        src: url(Fonts/ALGER.TTF);
        unicode-range: U+0020-007F;
    }

回答1:


You can add only one font to an element
Trick: Try giving them the same Name:

@font-face { /* Persian Font */
        font-family: 'MyFont';
        src: url(Fonts/BYekan.ttf);
        unicode-range:U+0600-06FF;
    }
    @font-face { /* english font */
        font-family: 'MyFont';
        src: url(Fonts/ALGER.TTF);
        unicode-range: U+0020-007F;
    }

Usage:

body{
  font-family: 'MyFont';}

This should solve your problem, but i cant test it because i'm on mobile



来源:https://stackoverflow.com/questions/32287257/display-text-with-two-language-in-webpage-with-different-fonts-with-font-face-at

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!