Chris Fong wrote:
Hi everyone,
I'm a relative newbie so forgive me if this question has been asked
before. I want my application to generate a pdf that uses a TTF font,
and looking at the example docs I would do something like this:
BaseFont bfComic =
BaseFont.createFont("c:\\windows\\fonts\\comicbd.ttf",
BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Font font = new Font(bfComic, 12);
That's just an example. I'll go deeper into this matter in the book on iText
(I'm still working on it).
This is all well and good on Windows, but my application is supposed
to work on other platforms (ie. Linux, OS X). What I've tried so far
is to copy the font I want to use into my application directory so
that I don't need to include the absolute path to the font. Is this
the best way to do this?
That's one possible solution.
Can I stick the font in a jar file?
Yes, that's possible too.
Any insights on how people handle this situation would be appreciated.
Take a look at http://itextdocs.lowagie.com/tutorial/fonts/getting/
more specifically the section on 'Registering font files'.
If you use the method registerDirectories():
http://itextdocs.lowagie.com/docs/com/lowagie/text/FontFactory.html#registerDirectories()
The fonts of the following directories will be registered:
c:/windows/fonts
c:/winnt/fonts
d:/windows/fonts
d:/winnt/fonts
/usr/X/lib/X11/fonts/TrueType
/usr/openwin/lib/X11/fonts/TrueType
/usr/share/fonts/default/TrueType
/usr/X11R6/lib/X11/fonts/ttf
/Library/Fonts
/System/LIbrary/Fonts
As you can see, this lists contains windows, UNIX, Linux and Mac
directories.
You only need to call registerDirectories once in your JVM (for instance
when
you start up the application server). From that moment you can use any
static
getFont method in class FontFactory.
br,
Bruno
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions