I'm sure this is getting a bit off topic but I was wondering if someone
here could help me understand this.
I'm guessing someone here has a better understanding of font graphics
since I started trying to understand it by digging through the FOP
classes used for loading custom fonts and displaying them in the AWT
viewer.

I'm trying to use this code:
          fontGraphics.setFont(baseFont);
          frc = fontGraphics.getFontRenderContext();
          Rectangle2D r2d = baseFont.getStringBounds("A", frc);
          baseCharWidth = r2d.getWidth();

I need this value in 2 places.
The second place works fine.  baseCharWidth gets a value of 0.60253906
which is what I want.
The first place returns a value of 1.0.
The baseFont object is the same java.awt.Font object in both places.
The fontGraphics in both places is created from a
bufferedImage.getGraphics().
So the only difference is the BufferedImage.
The second one creates the image from a
javax.swing.JPanel(java.awt.Component).createImage(w,h).
The first one doesn't have any GUI yet so I created a dummy image from a
GraphicsConfiguration.createCompatibleImage(w,h).

What am I missing?

Reply via email to