html - 如何正确地将自定义字体包含到 ionic 项目中?

标签 html fonts ionic-framework sass

在我的项目中设置了scss->css编译。而且我无法从 scss 文件夹中获取我的自定义字体。 这是我的文件夹结构,以便更好地理解。

| scss/
  |-- basics/
    |--_fonts.scss
  |-- fonts/
    |-- lineto-circular-book.woff
    |-- lineto-circular-medium.woff
| www
  |-- lib/
    |-- ionic/
      |-- css/         
      |-- fonts/

这就是 _fonts.scss 的样子:

@charset "UTF-8";

@font-face {
  font-family: 'Circular-Medium';
  src: url('fonts/lineto-circular-medium.woff');
}

@font-face {
  font-family: 'Circular-Medium-Book';
  src: url('fonts/lineto-circular-book.woff');
}

enter image description here

我处于未找到状态。我该如何解决这个问题?

最佳答案

首先,将 fonts/文件夹移动到 www/文件夹中,所以它看起来像这样。

| scss/
  |-- basics/
    |--_fonts.scss
| www
  |-- fonts/
    |-- lineto-circular-book.woff
    |-- lineto-circular-medium.woff

然后,如果您不缩小资源,那么路径可能会偏离一级。这应该修复引用。

@font-face {
    font-family: 'Circular-Medium';
    src: url('../fonts/lineto-circular-medium.woff');
}

@font-face {
    font-family: 'Circular-Medium-Book';
    src: url('../fonts/lineto-circular-book.woff');
}

关于html - 如何正确地将自定义字体包含到 ionic 项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36479495/

相关文章:

jquery - 如何在下拉框下方的Select2中显示选中的标签?

html - IE 中的 CSS 100% 高度

html - 查看网页是否使用了字体替换

c# - 如何以及何时为 WinForms 控件设置字体

html - Html5 中的母版页概念?

html - 如何仅使用 HTML 和 CSS 一键选中所有复选框

python - pygame.font.SysFont() 在 macOS 上大约需要 5 秒

javascript - Google map Javascript API 在 Ionic 2 中工作吗?

sqlite - Ionic 2 存储模块说明

jquery - Ionic 和 Angular JS HTTPS Post 请求