Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add custom font to a cordova project

Tags:

fonts

cordova

I have a custom fonts that I would like to use in my app.

The font name is myfont and the files with the extension are (myfont.eot,.myfont.svg,myfont.ttf,myfont.woff,myfont.woff2) and they are copied to IOS and android asset folder when I do a cordova build. However, when I open the app on the device I don't see the new font display.

I do see the new fond display when I run the app from safari browser on the mac.

here is the snippet from my CSS file

html, body {
    overflow-x: hidden;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    font-family: 'myfont';
    font-size: 16px;
}

Is there something else I need to do in order to see this new font on the android and iOS device

Thanks

like image 709
user2570135 Avatar asked Apr 07 '17 03:04

user2570135


People also ask

How do I import a font into project?

Add the font files to the projectDrag your fonts from a Finder window into your project. This copies the fonts to your project. Select the font or folder with the fonts, and verify that the files show their target membership checked for your app's targets.

Can you upload fonts to PageFly?

Open your PageFly page and click on Add custom Code button Now you need to decide if you want to apply the custom font to the whole page or to the specific element.


1 Answers

Use @font-face in your CSS.

@font-face {
  font-family: "my-font";
  src: url("../assets/myfonts.ttf");  // Give relative path to your css file.
}

Add code to your css file at top. And then you can easily use font-family my-font where ever you need.

Example:

CSS

.class-myfont { 
    font-family: my-font;
}

HTML

<span class="class-myfont">Hello there</span>
like image 107
Harish Kommuri Avatar answered Oct 16 '22 06:10

Harish Kommuri