Fonts not getting applied on android device in ion

2019-05-10 08:36发布

问题:

I'm trying to apply my custom font for android application. So I have modified the src/theme/variables.scss and added the following lines:

  @font-face {
  font-family: AppFont;
  src: url("../assets/fonts/RobotoCondensed-Regular.ttf");
}

body, span, button, h1, h2, h3, h4, h5, h6, p, ion-item, ion-title {
  font-family: 'AppFont' !important;
}

$font-family-base: 'AppFont';
$font-family-ios-base: 'AppFont';
$font-family-md-base: 'AppFont';
$font-family-wp-base: 'AppFont';

and when I run ng serve the fonts are getting applied correctly but when I deploy it to device fonts are gone. How can this be resolved.

回答1:

Problem was with ionic-cli-3.9.2 which is not picking the fonts from assets/fonts so i moved the fonts to /assets. Then it started working very annoying.