3

I am using iText to generate PDF files, which may include embedded fonts. iText includes a DefaultFontMapper class which allows us to specify a directory from which to load fonts that may then be embedded in the generated PDF files as needed. The program itself is run across a range of environments (Windows, Linux, Solaris...) and manually specifying directories has resulted in errors in the past (Due to directories being omitted).

My question is, "Is there a way in java to get all the directories from which fonts are loaded?"

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
tofarr
  • 7,682
  • 5
  • 22
  • 30

1 Answers1

3

I think it is only possible to list fontNames that are currently used (can be tricky due to GraphicsEnvironment being used on headless environment)

GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getAvailableFontFamilyNames();
Wojciech Owczarczyk
  • 5,595
  • 2
  • 33
  • 55
  • 1
    I guess I am trying to get a something that the API designers were deliberately trying to abstract away. Thanks for the reply. – tofarr Oct 24 '11 at 12:06
  • See also [this example](http://stackoverflow.com/questions/6965038/getting-fonts-sizes-bold-etc/6965149#6965149). – Andrew Thompson Oct 24 '11 at 14:35
  • Listing fonts is fairly easy - unfortunately fonts do not include info on the file from which they were loaded, so there does not seem to be a simple way to do this. I ended up setting a configuration file which may be used to specify additional font directories - not perfect, but it will have to do for now – tofarr Oct 25 '11 at 11:19