为两种不同的语言使用单独的字体 [英] Using separate fonts for two different languages

查看:226
本文介绍了为两种不同的语言使用单独的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将两种不同的字体用于两种不同的语言。但是两种字体彼此重叠,因此导致阅读文本时遇到困难。这是我正在尝试的;

I'm trying to use two different fonts for two different languages. But both fonts are overlapping eachother hence causing difficulty in reading the text. Here is what I am trying;

@font-face {
       font-family: 'Jameel Noori Nastaleeq';
       src: url(../../../fonts/Jameel Noori Nastaleeq.ttf)
}

,然后在编写我的文本的区域中使用了此CSS类:

and then in the area where my text is written this CSS class has been used:

.post_body {
    padding: 5px;
    font-size: 17px;
    font-family: Tahoma, Jameel Noori Nastaleeq;
}

问题是,当我使用 URDU 文本显示正确的字体样式,但是当我使用 ENGLISH 文本时,则不使用 Tahoma 字体样式。

The issue is, when I use URDU text in my post it shows correct font style, however when I use ENGLISH text then it doesn't uses Tahoma font style.

请帮助如何在同一区域为两种不同的语言使用两种不同的字体样式?

Please help on how to use two different font styles for two different languages in the same area?

推荐答案

您应该首先设置html语言或元素的语言。

You should start by setting the language of the html... ...or the language of the element.

<!-- html -->
<html lang="en">


/* CSS */
.post_body {
    /* common style stuff -- don't set font-family here */
}

:lang(en) .post_body {
    font-family : Tahoma;
}

然后使用JS更改 document.documentElement。 lang 属性。

Then use JS to change the document.documentElement.lang property.

当然,这就是如果整个页面都在改变语言。

That, of course, is if the whole page is changing language.

如果您想同时在乌尔都语中有一些帖子和一些英语中的帖子,请设置

If you want to have some posts in Urdu and some posts in English at the same time, set

<article class="post_body" lang="en">

.post_body:lang(en) { font-family : Tahoma; }

这篇关于为两种不同的语言使用单独的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆