pdf export on Android - font deployment

Amazing component.


Having a bit of an issue deploying it on Android though, with fonts.  I get an error 'the folder /data/data/<appname>/files/Fonts does not contain any file of type *.ttf"

In XE7, I've set it to deploy the font file to "files\Fonts" (remote path) but I still get the error.

Your document UsingFlexCelPdfExport.pdf says deploy to "Assets/fonts" but that also doesn't appear to work.

Any suggestions?

- Niels

Hi,


Thanks! :)


Try deploying to:
assets\internal\Fonts

We should put this in the android documentation: sadly I never get the time to write the doc (as we do have to ios).

Bu you can see why is assets\internal here:
http://docwiki.embarcadero.com/RADStudio/XE7/en/Creating_an_Android_App#Loading_and_Deploying_Files

Basically, by default in android FlexCel will search at


        FontPath := TPath.Combine(TPath.GetDocumentsPath, TPdfTokens.GetString(TPdfToken.FontFolder));

where TPdfTokens.GetString(TPdfToken.FontFolder) is "Fonts". So they are at GetDocumentsPath\Fonts. From the link above, GetDocumentPaths is assets\internal

There is also a little bit of confussion in the docs because it comes from FlexCel.NET, and in Xamarin you have "real" android assets, and FlexCel can use those when you put an "@" in the fontpath. But in delphi, as we don't have an easy way to create assets, it doesn't make sense to support that.

Some other notes:
1)Note that if you don't like that default location you can change it. You have the GetFontFolder event where you can specify any folder, and the GetFontData event where you can provide directly the bytes of the font file, if you have the fonts in a place like a db.

2)For iOS (And osx) there is no need for any of this, since iOS allows direct access to the system font definitions, different from android. Also iOS comes with a good font selection, instead of Android which comes with "Roboto" in 4 variants (seriously...).  I guess roboto should be enough for everyone.

3)If you don't want to mess with fonts, you can use PDF internal fonts. Those are an "arial (or helvetica) like, a times new roman like, and a courier like. IF you set pdf.FontMapping to TFontMapping.ReplaceAllFonts, you won't need to ship fonts with your app. But then, you'll only get arial or times new roman in the generated pdfs. For more accuracy, you need to ship your fonts, since android only has roboto.

As always, a fantastic reply.  Thanks, that fixes it.