Cannot include custom fonts in my Android App

359 views
Skip to first unread message

Trausti Dagsson

unread,
Jul 26, 2014, 5:32:19 PM7/26/14
to phon...@googlegroups.com
Hello everyone.
I am making my first PhoneGap App which is going quite well except for one thing, it is impossible for me to make my custom fonts appear in my App. I followed these instructions (http://therockncoder.blogspot.co.uk/2014/02/using-google-fonts-in-phonegap-app.html) and am not using 'EB Garamond' from Google Fonts.
The directory structure is like this:

www/res/fonts/EBGaramond.[ttf / woff]
www/css/style.css

And I'm referring to the font files like this in www/css/style.css:

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400;
  src: url('../res/fonts/EBGaramond.woff') format('woff');
  src: url('../res/fonts/EBGaramond.ttf') format('truetype');
}

The strange thing is that in buth Ripple Emulator and the Phonegap Developer App (phonegap serve) the font appear but not in the PhoneGap build from build.phonegap.com or the local build by the command 'cordova build'. If I however link the font to the App directly from Google Fonts (<link href='http://fonts.googleapis.com/css?family=EB+Garamond' rel='stylesheet' type='text/css'>), then the font appears in my build, but I really dont want the font to be loaded from there.

Note: I have used both src: url('../res/[...]') and src: url('res/[....]') but neither work.

I am quite experienced web-developer but this thing is driving me crazy!
Does anyone have a clue for me? Thanks.

Kerri Shotts

unread,
Jul 29, 2014, 2:06:18 PM7/29/14
to phon...@googlegroups.com
Could it be that the font isn't being packaged in the APK? Inspect the APK from PG Build and see if the font is included (rename to zip and extract).

Trausti Dagsson

unread,
Aug 2, 2014, 1:01:35 PM8/2/14
to phon...@googlegroups.com
Found the solution (if that is a solution), if I build it using 'cordova build android', then the font appears. Its strange, but it works for me.
Reply all
Reply to author
Forward
0 new messages