如何在我的ionic应用程序中更改字体?

qncylg1j  于 5个月前  发布在  Ionic
关注(0)|答案(2)|浏览(96)

我想改变字体,但我不能在Chrome或三星A50,Android Xi设备上做到这一点。我将感谢您能指导我的任何帮助,谢谢!

Ionic CLI: 6.19.0
Ionic Framework: @ionic/angular 6.0.4
Cordova CLI: 11.0.0

字符串
我将ttf复制到assets/fonts文件夹PermanentMarker-Regular.ttf中

global.scss: 
@font-face {
    font-family: 'Permanent Marker', cursive;
    src: url('/src/assets/fonts/PermanentMarker-Regular.ttf')
}
home.scss:
ion-content h3 {
    --ion-font-family: 'Permanent Marker', cursive !important;
    font-size: 24px;
}
home.html: 
<ion-content class="ion-padding" [style.background-image]="'url(' + img_backg + ')'">
  <ion-grid>
    <ion-row class="ion-text-center">
      <ion-col>
        <h3>{{global.titulo_principal}}</h3>
………
nnsrf1az

nnsrf1az1#

假设home.html是正确的,将global.scss的路径更改为以下内容:

src: url('../assets/fonts/PermanentMarker-Regular.ttf')

字符串

jfewjypa

jfewjypa2#

这对我很有效:

@font-face {
  font-family: 'M PLUS Rounded 1c';
  src: url('assets/fonts/MPLUSRounded1c-Black.ttf') format('truetype');
  font-weight: normal;
}

:root {
  --ion-font-family: 'M PLUS Rounded 1c', sans-serif;
}

字符串
我知道这可能不是“去”的方式来做到这一点,但它的工作,因此我会保持这样,直到我注意到任何问题。

相关问题