This is a migrated thread and some comments may be shown as answers.

Xamarin - how to import custom font with the FontProvider

2 Answers 307 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Guittier
Top achievements
Rank 1
Guittier asked on 24 Feb 2021, 02:11 PM

Hello,

I'm trying to create a PDF file from a Xamarin app.

Everything went well until I add text with accent (it's quite embarasing for me, because all my texts are in French).

I know that the 14 Standard fonts are withou accent. 

 

So i try to add a FontsProvider to add a MyriadPro.ttf file (which is also Embedded a ressource in my Android and Ios projets),  as explained here : https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/cross-platform , with the using of the Environment.SpecialFolder.Fonts folder

I put the provider class and initiate it in my create method.

But when i don't know how to add the .tff file to the Environment.SpecialFolder.Fonts

 

 

When a call my fontfamily with this line (from the Xamarin sample app) :  this.SetTextProperties(block, RgbColors.Black, 25, new FontFamily("MyriadPro"))

The custom Fontprovider is called as expected, but a have a exception, because the folder : /data/user/0/com.xxx.xxxx/files/.fonts is not found

My question is : how to add my ttf to the SpecialFolder.fonts , in my Android and Ios project ?

 

Thanks for you help, 

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 25 Feb 2021, 01:07 PM

Hello Guittier,

Please take a look at the following kb article which demonstrates how you can add a non-embedded font to Xamarin project and register it through the PdfProcessing FontsRepository class:

How to embed TrueType fonts in PdfViewer with PdfProcessing library

Basically, you should add the .ttf file to the Xamarin.Forms project as Embedded Resource, then extract the font data and apply it through the RegisterFont and TryCreateFont methods of the FontsRepository class.

Please give it a try and let me know if you have any additional questions or concerns.

Regards,
Yana
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Guittier
Top achievements
Rank 1
answered on 25 Feb 2021, 01:38 PM

Thanks for your answer, it works !!!

 

Tags
PdfProcessing
Asked by
Guittier
Top achievements
Rank 1
Answers by
Yana
Telerik team
Guittier
Top achievements
Rank 1
Share this question
or