如何在一个页面中使用两种font-family?

时间:2015-04-24 10:17:00

标签: html css fonts font-face

我的网页有两种语言,英文和中文,我只能将一种字体系列应用于一种语言,如何同时将两种字体系列应用于英文和中文?想法?

@font-face {
  font-family: 'Kavoon';
  font-style: normal;
  font-weight: 400;
  src: url(http://example.com/myfonts.eot);
  src: local('Kavoon Regular'), local('Kavoon-Regular'), url(http://example.com/myfonts.eot) format('embedded-opentype'), url(http://example.com/myfonts.woff) format('woff');
}

如何更改此定义以支持我的要求?

3 个答案:

答案 0 :(得分:0)

您可以为不同的字体创建另一个字体。

英语:

 @font-face {
font-family: EnglishFont;
src: url(source_to_english.woff);
}

中国:

 @font-face {
font-family: chineseFont;
src: url(source_to_chinese.woff);
}

其他:

 @font-face {
font-family: OtherFont;
src: url(source_to_other.woff);
}

答案 1 :(得分:0)

Code Lord的答案是正确的,但总是试图为每个浏览器转换字体:

英文:

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

中国:

@font-face {
    font-family: 'chinese';
    src: url('chinese.eot');
    src: url('chinese.eot?#iefix') format('embedded-opentype'),
         url('chinese.woff2') format('woff2'),
         url('chinese.woff') format('woff'),
         url('chinese.ttf') format('truetype'),
         url('chines.svg#chinese_medregular') format('svg');
    font-weight: normal;
    font-style: normal;
}

您可以使用此工具转换字体:"Parasitic Combination Inheritance" in Professional JavaScript for Web Developers

答案 2 :(得分:0)

据我所知,台湾的服务可以帮助您使用不同的中文字体。

http://en.justfont.com/fonts

由于中文字体文件较大,建议使用Google云端服务。但是上面没有合适的中文字体。所以你可以尝试一下这个justfont web字体服务。

  1. 为特定字体粗细选择所需的任何字体。然后将它添加到您的项目中。
  2. 选择.notosans#notosansh2
  3. 等选择器
  4. 点击" JS"按钮并获取您的设置代码
  5. <body>
  6. 之前添加
  7. 插入您的课程或ID。
  8. 尝试使用class和id获取漂亮的中文字体。 :)