Ionic中的Google字体2 [英] Google Fonts in Ionic 2

查看:174
本文介绍了Ionic中的Google字体2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ionic 2中使用Google字体。

I am trying to use Google Fonts in Ionic 2.

在研究Stackoverflow&离子论坛,我已经导入了字体&包含变量.scss中的基数如下

After researching Stackoverflow & Ionic Forum, I have imported the font & included the base in the variables.scss as follows

@import url('https://fonts.googleapis.com/css?family=Lato');
$font-family-base: "Lato";
$font-family-md-base: "Lato";
$font-family-ios-base: "Lato";
$font-family-wp-base: "Lato";

显然,这不是渲染字体。我做错了什么或者还有什么需要做?

Obviously, this is not rendering the font. What am I doing wrong or what else needs to be done?

推荐答案

如果这有助于任何人,我需要一个谷歌字体显示在我的Ionic 2应用程序中。这就是我实现它的方式:

In case this helps anybody, I needed to get a Google Font to show within my Ionic 2 app. This is how I achieved it:

转到 https://fonts.googleapis.com/css?family=Rajdhani

获取 woff的网址 file

转到此URL并下载 woff 文件。将它放入您的assets / fonts /目录

Go to this URL and download the woff file. Put it into your assets/fonts/ directory

编辑 app / app.scss 并添加

@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/fonts/Rajdhani.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}

* {
  font-family: 'Rajdhani';
}

这篇关于Ionic中的Google字体2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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