html - 在网页中显示两种语言的文本,在 css 规则中使用不同字体的字体

标签 html css font-face unicode-range

我的网页按预期使用 Yekan 字体显示波斯文本。为什么英文文本错误地使用了 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;
    }

最佳答案

一个元素只能添加一种字体。
技巧:尝试给他们相同的名字:

@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;
}

用法:

body {
    font-family: 'MyFont';
}

这应该可以解决您的问题,但我无法测试它,因为我在移动设备上。

关于html - 在网页中显示两种语言的文本,在 css 规则中使用不同字体的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32287257/

相关文章:

javascript - 灯箱图片都是黑白的

javascript - HTML5 Canvas 如何使图像可以通过 Kinetic.js 调整大小?

css - 使用 CSS 放大以光标为中心的图像

php - 使表格在排序时显示交替的颜色背景

css - IE7 不加载 eot webfont

html - 即使页面中未使用字体,浏览器也会下载它吗?

javascript - FB :comments getting height getting "unhealthily" cut

html - CSS 选择器测试器有效性

html - 在div的 Angular 上绘制三 Angular 形

javascript - 在 IExplorer 中检测字体下载权限