Why aren't my fonts getting registered?

I have 156 TTF files under my /usr/share/fonts directory tree. Why aren't these being registered?

31st May 2016
admin-marketing

I have a program using iTextSharp that includes the code

 

FontFactory.RegisterDirectories();
foreach (string fontname in FontFactory.RegisteredFonts) {
   Log.Info("**** Found registered font: " + fontname);
}
When I run it (using Mono on a CentOS box), the log shows only the core PostScript fonts:
  • zapfdingbats
  • times-roman
  • times-italic
  • helvetica-boldoblique
  • courier-boldoblique
  • helvetica-bold
  • helvetica
  • courier-oblique
  • helvetica-oblique
  • courier-bold
  • times-bolditalic
  • courier
  • times-bold
  • symbol

But I have 156 TTF files under my /usr/share/fonts directory tree (which is one of the directories mentioned in the code for the RegisterDirectories function). Why aren't these being registered?

Posted on StackOverflow on Nov 29, 2013 by dan04

There are subtle differences between iText and iText for C#. Java is platform independent, so we have to look for the 'usual suspects'. C# is Windows specific, so we can depend on the environment to tell us where to find fonts.

Your question tells us that Mono doesn't support this, so you'll have to use PdfFontFactory.RegisterDirectory("/usr/share/fonts");

Click this link if you want to see how to answer this question in iText 5.



Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now