Use Custom font with Unity3D and ItextSharp

Because I need to use special characters, integrated itextsharp font cant handle them, I need to use my own custom font. The integration of custom font in my app is working in Editor but in Android device not.

Does any body know how to access font on android for use with itextsharp?

For my font path I’m using:

string fontPath = Application.dataPath + "/" + "FreeSans" + ".ttf";

i tried also

string fontPath = Application.persistentDataPath + "/" + "FreeSans" + ".ttf";

And for font creation I use:

BaseFont bf = BaseFont.CreateFont(fontPath , BaseFont.CP1250, true);

When I use first option it works in Unity Editor.


So. After hours of scratching my head I finally got it right.

The first part of solution is written here. You have to put some DLL files to project folder. Which one, depends what encoding you have to use.

The second part goes like this:

First of all you have to make path to Android system font directory with font name:

 path = Path.Combine("/system/fonts/", "DroidSans.ttf");

Register that font with FontFactory:

  iTextSharp.text.FontFactory.Register(path, "DroidSans");

After that you just declare font with FontFactory.GetFont:

font = iTextSharp.text.FontFactory.GetFont("DroidSans", 

And thats it!