Hi @all,
afaik fonts will be automatically embedded in pdf if the font is available for the jvm.
So copy my fonts (e.g. mscorefonts on linux or barcode-fonts) into the jvm works as expected - pdf is created and printable on linux and windows.
Because I don't want to copy the fonts after each update I've created a method to load additional fonts from a folder.
/**
* Register custom fonts.
* @param theFontDirectory the directory to load fonts from
*/
private void registerFonts(final File theFontDirectory)
{
if (!theFontDirectory.isDirectory())
return;
try
{
final GraphicsEnvironment _ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (final File _f : FileUtil.findFiles(theFontDirectory, null, true))
{
if (FileUtil.getFilenameEnding(_f.getName()).toLowerCase().equals("ttf"))
{
try
{
LoggerFactory.getDefaultLogger().info("register font: " + _f.getAbsolutePath());
final Font _font = Font.createFont(Font.TRUETYPE_FONT, _f);
_ge.registerFont(_font);
}
catch (Exception _e)
{
LoggerFactory.getDefaultLogger().log(java.util.logging.Level.SEVERE,
"error registering font " + _f.getAbsolutePath(), _e);
}
}
}
}
catch (Exception _e)
{
LoggerFactory.getDefaultLogger().log(java.util.logging.Level.SEVERE, "error registering fonts", _e);
}
}
This works as expected but unfortunately this does not embed the fonts into the pdf.
If I copy the fonts into the jre the fonts are embedded.
Now I'm looking for a solution to register my fonts in CR (or somewhere else) to ensure that they will be embedded into the pdf.
Has anyone an idea to do this?
Markus