chrisg 2002/11/25 09:01:48
Modified: . Tag: fop-0_20_2-maintain CHANGES
src/org/apache/fop/render/awt Tag: fop-0_20_2-maintain
AWTFontMetrics.java AWTRenderer.java FontSetup.java
Log:
Improved AWT Font-measuring/rendering (see bug #14657)
Submitted by: Ralph LaChance <[EMAIL PROTECTED]>
Revision Changes Path
No revision
No revision
1.10.2.31 +2 -0 xml-fop/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/xml-fop/CHANGES,v
retrieving revision 1.10.2.30
retrieving revision 1.10.2.31
diff -u -r1.10.2.30 -r1.10.2.31
--- CHANGES 25 Nov 2002 11:56:51 -0000 1.10.2.30
+++ CHANGES 25 Nov 2002 17:01:47 -0000 1.10.2.31
@@ -1,6 +1,8 @@
==============================================================================
Done since 0.20.4 release
+- Improved AWT Font-measuring/rendering (see bug #14657)
+ Submitted by: Ralph LaChance <[EMAIL PROTECTED]>
- Updated examples/fo files to remove all errors and warnings during build
Submitted by: Manuel Mall <[EMAIL PROTECTED]> (see bug #13867)
- Perfomance tuning (reduced object creation etc.) (see bug #14103)
No revision
No revision
1.3.2.4 +18 -6 xml-fop/src/org/apache/fop/render/awt/AWTFontMetrics.java
Index: AWTFontMetrics.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/awt/AWTFontMetrics.java,v
retrieving revision 1.3.2.3
retrieving revision 1.3.2.4
diff -u -r1.3.2.3 -r1.3.2.4
--- AWTFontMetrics.java 8 Nov 2002 10:25:27 -0000 1.3.2.3
+++ AWTFontMetrics.java 25 Nov 2002 17:01:48 -0000 1.3.2.4
@@ -177,14 +177,26 @@
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;
}
/**
1.38.2.10 +12 -1 xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java
Index: AWTRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java,v
retrieving revision 1.38.2.9
retrieving revision 1.38.2.10
diff -u -r1.38.2.9 -r1.38.2.10
--- AWTRenderer.java 8 Nov 2002 10:25:27 -0000 1.38.2.9
+++ AWTRenderer.java 25 Nov 2002 17:01:48 -0000 1.38.2.10
@@ -373,6 +373,11 @@
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();
@@ -859,6 +864,12 @@
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;
1.3.2.5 +10 -3 xml-fop/src/org/apache/fop/render/awt/FontSetup.java
Index: FontSetup.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/awt/FontSetup.java,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -r1.3.2.4 -r1.3.2.5
--- FontSetup.java 8 Nov 2002 10:25:27 -0000 1.3.2.4
+++ FontSetup.java 25 Nov 2002 17:01:48 -0000 1.3.2.5
@@ -20,6 +20,7 @@
import java.awt.Font;
import java.awt.Graphics2D;
import java.util.List;
+import java.awt.RenderingHints ;
import java.net.URL;
/**
@@ -46,8 +47,8 @@
* 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 {
@@ -55,6 +56,12 @@
FontMetricsMapper metric;
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:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]