Font Size Changes When Creating Image

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
gw1500se
Posts: 21
Joined: Tue Nov 21, 2017 3:36 pm
antibot: No, of course not.

Font Size Changes When Creating Image

Post by gw1500se » Wed Jun 06, 2018 4:52 pm

I have a chart that contains markers with labels in 10 pt font. I create an image to be added to an itextpdf document:

Code: Select all

float sizeX=page.getHeight();
float sizeY=page.getWidth();
float scale=.68f;
float marginY=10.f;
PdfContentByte cb=writer.getDirectContent();
PdfTemplate tp=cb.createTemplate(sizeX*scale+1,sizeY*scale+1);
PdfGraphics2D g2d=new PdfGraphics2D(tp,sizeX*scale+1,sizeY*scale+1);
tp.setWidth(sizeX*scale+1);
tp.setHeight(sizeY*scale+1);
Chart.getInstance().getChart().draw(g2d, new java.awt.geom.Rectangle2D.Float(0,0,sizeX*scale,sizeY*scale));
g2d.dispose();
Image image=Image.getInstance(tp);
The problem is that the font size of the label on the image changes so that it no longer properly fits on the chart in the image. Why does the size of that font change (none of the others do) and how do I fix that? TIA

Post Reply