==============================================================================
Done since 0.20.4 release
+- Improved AWT Font-measuring/rendering (see bug #14657)
+ Submitted by: Ralph LaChance <Ralph_LaChance@compuserve.com>
- Updated examples/fo files to remove all errors and warnings during build
Submitted by: Manuel Mall <mm@arcus.com.au> (see bug #13867)
- Perfomance tuning (reduced object creation etc.) (see bug #14103)
public int width(int i, String family, int style, int size) {
int w;
setFont(family, style, size);
+
+ // Nov 18, 2002, aml/rlc
+ // measure character width using getStringBounds for better results
+
+ char [] ac = new char [1];
+ ac [0] = (char)i;
+
+ double dWidth = fmt.getStringBounds (ac, 0, 1, graphics).getWidth() * FONT_FACTOR;
+
+ // The following was left in based on this comment from the past (may be vestigial)
+
// the output seems to look a little better if the
// space is rendered larger than given by
// the FontMetrics object
- if (i <= 32)
- w = (int)(1.4 * fmt.charWidth(i) * FONT_FACTOR);
- else
- w = (int)(fmt.charWidth(i) * FONT_FACTOR);
- return w;
+
+ if (i <=32) {
+ dWidth = dWidth * 1.4;
+ }
+
+ return (int) dWidth;
}
/**
graphics = pageImage.createGraphics();
+ // Nov 18, 2002 - [aml/rlc] eliminates layout problems at various scaling
+
+ graphics.setRenderingHint (RenderingHints.KEY_FRACTIONALMETRICS,
+ RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+
transform(graphics, scaleFactor, 0);
drawFrame();
int oldPageNumber = pageNumber;
graphics = (Graphics2D)g;
+
+ // Nov 18, 2002 - [aml/rlc] eliminates layout problems at various scaling
+
+ graphics.setRenderingHint (RenderingHints.KEY_FRACTIONALMETRICS,
+ RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+
Page aPage = (Page)pageList.get(pageIndex);
renderPage(aPage);
graphics = oldGraphics;
import java.awt.Font;
import java.awt.Graphics2D;
import java.util.List;
+import java.awt.RenderingHints ;
import java.net.URL;
/**
* triplets for lookup
*
* @param fontInfo the font info object to set up
- * @param graphics Graphics2D to work on
- * @throws FOPException in case of an error during font setup
+ * @param parent needed, since a live AWT component is needed
+ * to get a valid java.awt.FontMetrics object
*/
public static void setup(FontInfo fontInfo, Graphics2D graphics)
throws FOPException {
MessageHandler.logln("setting up fonts");
+ // Nov 18, 2002 - [aml/rlc] eliminates layout problems at various scaling
+
+ graphics.setRenderingHint (RenderingHints.KEY_FRACTIONALMETRICS,
+ RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+
+
/*
* available java fonts are:
* Serif - bold, normal, italic, bold-italic