首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Qtranslate每种语言的自定义字体问题

Qtranslate每种语言的自定义字体问题
EN

Stack Overflow用户
提问于 2016-12-04 17:20:12
回答 1查看 438关注 0票数 1

我在wordpress网站上遇到了一个问题,一个客户想要为每种语言设置一个自定义字体系列

我正在使用wordpress的Qtranslate插件来翻译内容,我成功地做到了这一点……我还使用了一个名为Custom CSS for wordpress的插件在代码中应用CSS更改

问题是当我使用代码设置自定义字体时。它为两种语言设置自定义字体。所以请帮我解决这个问题

我的自定义CSS代码是

代码语言:javascript
运行
复制
@font-face {
font-family: GEDinarOne-Medium; 
src: url('http://www.example.com/wp-content/themes/fonts/GEDinarOne-Medium.ttf'); 
font-weight: normal;}

:lang(ar) body, h1, h2, h3, h4, h5, h6, p, blockquote, li, a{
    font-family: GEDinarOne-Medium !important; 
  }
EN

回答 1

Stack Overflow用户

发布于 2016-12-04 18:34:02

您需要create一个CSS类,并将其放置在CSS的底部中,然后将其添加到翻译的内容标记中。

例如:

代码语言:javascript
运行
复制
@font-face {
  font-family: 'Yrsa';
  font-style: normal;
  font-weight: 400;
  src: local('Yrsa'), local('Yrsa-Regular'), url(https://fonts.gstatic.com/s/yrsa/v1/HvXbkSMs7hgg2r-HiCNOmA.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
  font-family: 'Indie Flower';
  font-style: normal;
  font-weight: 400;
  src: local('Indie Flower'), local('IndieFlower'), url(https://fonts.gstatic.com/s/indieflower/v8/10JVD_humAd5zP2yrFqw6ugdm0LZdjqr5-oayXSOefg.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
body {
  background: #111;
  color: #999;
  text-align: justify;
  text-justify: inter-word;
  max-width: 80%;
  margin: 10%
}
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
li,
a {
  font-family: 'Yrsa';
}
.otherlanguage {
  font-family: 'Indie Flower';
}
代码语言:javascript
运行
复制
<body>
  <div>
    <h1>This is a Header 1 in font A</h1>
    <h1 class="otherlanguage">This is a Header 1 in font B</h1>
    <h2>This is a Header 2 in font A</h2>
    <h2 class="otherlanguage">This is a Header 2 in font B</h2>
    <h3>This is a Header 2 in font A</h3>
    <h3 class="otherlanguage">This is a Header 2 in font B</h3>
    <p>This is a paragraph using font A
      <br>Lorem ipsum dolor sit amet, in eam simul nostrud definiebas, mea iusto placerat prodesset ei. Eum summo audiam ea. Vitae aperiri at duo. Vis atomorum partiendo id, nam ea noluisse platonem. Nec minimum consequat cu, pri in harum moderatius. Ferri
      aperiam forensibus an nam.</p>
    <p class="otherlanguage">This is a paragraph using font B
      <br>Lorem ipsum dolor sit amet, in eam simul nostrud definiebas, mea iusto placerat prodesset ei. Eum summo audiam ea. Vitae aperiri at duo. Vis atomorum partiendo id, nam ea noluisse platonem. Nec minimum consequat cu, pri in harum moderatius. Ferri
      aperiam forensibus an nam.</p>
  </div>
</body>

编辑:新代码段

我确信有一种更好的方式来组合选择器,但这应该不需要改变任何。

代码语言:javascript
运行
复制
@font-face {
  font-family: 'Yrsa';
  font-style: normal;
  font-weight: 400;
  src: local('Yrsa'), local('Yrsa-Regular'), url(https://fonts.gstatic.com/s/yrsa/v1/HvXbkSMs7hgg2r-HiCNOmA.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
  font-family: 'Indie Flower';
  font-style: normal;
  font-weight: 400;
  src: local('Indie Flower'), local('IndieFlower'), url(https://fonts.gstatic.com/s/indieflower/v8/10JVD_humAd5zP2yrFqw6ugdm0LZdjqr5-oayXSOefg.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
.page-id-70 h1,
.page-id-70 h2,
.page-id-70 h3,
.page-id-70 h3,
.page-id-70 h4,
{
  font-family: 'Yrsa';
}
.page-id-71 h1,
.page-id-71 h2,
.page-id-71 h3,
.page-id-71 h3,
.page-id-71 h4,
{
  font-family: 'Indie Flower';
}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40957142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档