1

I want to embed font into my Java program and I know how to do it using standard Java libraries. However, how do I do it using iText?

I don't want anything outside of my project (or later jar file) to be tampered with if it's not absolutely necessary (I want my program to work on all Java supporting platforms).

I'm importing font using *.ttf file.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Karlovsky120
  • 6,212
  • 8
  • 41
  • 94

1 Answers1

0

Define a font

public static String[] FONT = 
    {"path/to/fonts/xxx.ttf", BaseFont.WINANSI};

then use

BaseFont bf = BaseFont.createFont(FONT[0], FONT[1], BaseFont.EMBEDDED);
Font font = new Font(bf, 24);

with the document.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • That doesn't work for some reason... http://stackoverflow.com/questions/12333018/creating-fonts-from-ttf-files-using-itext – Karlovsky120 Sep 08 '12 at 17:50