use of org.apache.fop.fonts.DefaultFontConfigurator in project grafikon by jub77.
the class DrawOutput method processPdf.
private void processPdf(Collection<Image> images, OutputStream stream, DrawLayout layout) throws OutputException {
PDFDocumentGraphics2D g2d;
try {
g2d = new PDFDocumentGraphics2D();
g2d.setGraphicContext(new GraphicContext());
FopFactory fopFactory = PdfTransformer.createFopFactory();
FOUserAgent userAgent = fopFactory.newFOUserAgent();
FontConfig fc = userAgent.getRendererConfig(MimeConstants.MIME_PDF, new PDFRendererConfigParser()).getFontInfoConfig();
FontManager fontManager = fopFactory.getFontManager();
DefaultFontConfigurator fontInfoConfigurator = new DefaultFontConfigurator(fontManager, null, false);
List<EmbedFontInfo> fontInfoList = fontInfoConfigurator.configure(fc);
FontInfo fontInfo = new FontInfo();
FontSetup.setup(fontInfo, fontInfoList, userAgent.getResourceResolver(), fontManager.isBase14KerningEnabled());
g2d.setFontInfo(fontInfo);
g2d.setFont(new Font("SansCondensed", Font.PLAIN, g2d.getFont().getSize()));
List<Dimension> sizes = this.getSizes(images, g2d);
Dimension size = this.getTotalSize(sizes, layout);
g2d.setupDocument(stream, size.width, size.height);
this.drawImages(sizes, images, g2d, layout);
g2d.finish();
} catch (IOException | FOPException e) {
throw new OutputException(e.getMessage(), e);
}
}
Aggregations