Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Google Web Font in an iPhone app built with PhoneGap?

We would like to use Google Web Fonts in a PhoneGap app built for iOS devices, but we would like to host the font files within the app's bundle instead of using the code to dynamically fetch the font over the web.

If the device is offline, the fonts won't be available unless the font files are bundled into the app.

Google offers the ability to download the web fonts, but how are we supposed to reference the local font files inside the HTML app?

like image 520
Crashalot Avatar asked Aug 01 '12 05:08

Crashalot


1 Answers

we put the font file in .ttf Format somewhere in our assets/www folder.

Declaration:

@font-face {
  font-family: "Droid Serif";
  src: url('fonts/DroidSerif.ttf');/* relative path from the css file */
}

and then use it like this:

.someClass, #someId, someTag{
  font-family: Droid Serif;
}
like image 95
最白目 Avatar answered Sep 25 '22 00:09

最白目