How can i import a new font to POI API with extensions ttf & otf , without install these fonts into the environment ?
Is there a jar that i should update it with the path of the new font ?
How can i import a new font to POI API with extensions ttf & otf , without install these fonts into the environment ?
Is there a jar that i should update it with the path of the new font ?
You cannot add fonts... You can think your (office) files just like HTML. Font lives outside the document. You just set the font name, family, etc.
However, someone has already tried to do that. Using embedded files, you could add font files.
Link:
http://apache-poi.1045710.n5.nabble.com/Font-embedding-into-XSLF-td5713937.html
It is far from easy. There's no easy way to insert embedded files.
In the meantime I've implemented an API to embed the fonts easily. This version goes live with POI 4.1.0.
POI can't consume .ttf/.otf directly, but needs some help from googles sfntly. My demo project can be found under github/poi-font-mbender.
I won't provide a copy & paste of the sample class as you also need the rest of the sfntly library, which is not available as maven artifact.