I'm trying to export a Draw2D Figure to a PDF file, using PDFBox.
The software will be used on both Windows and Mac OS X.
From the Figure I can get SWT font objects (org.eclipse.swt.graphics.Font
). Available fonts are obtained from the JFace FontRegistry.
To embed a font in the PDF, I can embed a TrueType font with PDTrueTypeFont.loadTTF( PDDocument doc, File file )
or variants.
Given an SWT font object or a font name, how can I get the file path to the font file?
EDIT:
There's a similar question here: Get font file as a File object or get its path. However, the accepted answer is fragile and platform-specific. It relied on an internal API that changed between Java 6 and Java 7. This question seeks a solution that is cross-platform and does not couple to internal implementation details.