Details
-
Bug
-
Status: Closed
-
Resolution: Fixed
-
0.20.4
-
None
-
None
-
Operating System: All
Platform: PC
-
14657
Description
The AWT Renderer and its subclass Print renderer (lives in the PrintStarter)
sizes text
incorrectly at certain zoom scalings. It is especially with
bold text. The problem shows up
differently with jre 1.3.x and 1.4.x
The solution requires two actions:
1) to enable the
Rendering Hint - FractionalMetrics
2) to use getStringBounds to obtain the size of a
character
rather than charWidth.
3 files in package ...fop.render.awt are affected,
AWTRenderer,
AWTFontMetrics, and FontSetup.
Diff file follows below
'best
-
Ralph LaChance
Index: xml-
fop/src/org/apache/fop/render/awt/AWTFontMetrics.java
===================================================================
RCS
file: /home/cvspublic/xml-
fop/src/org/apache/fop/render/awt/AWTFontMetrics.java,v
retrieving revision
1.3.2.3
diff -u -r1.3.2.3 AWTFontMetrics.java
— xml-
fop/src/org/apache/fop/render/awt/AWTFontMetrics.java 8 Nov 2002 10:25:27 -
0000 1.3.2.3
+++ xml-fop/src/org/apache/fop/render/awt/AWTFontMetrics.java 18 Nov
2002 22:41:37 -0000
@@ -177,14 +177,26 @@
public int width(int i, String family, int style,
int size)
/**
Index: xml-
fop/src/org/apache/fop/render/awt/AWTRenderer.java
===================================================================
RCS
file: /home/cvspublic/xml-
fop/src/org/apache/fop/render/awt/AWTRenderer.java,v
retrieving revision
1.38.2.9
diff -u -r1.38.2.9 AWTRenderer.java
— xml-
fop/src/org/apache/fop/render/awt/AWTRenderer.java 8 Nov 2002 10:25:27 -
0000 1.38.2.9
+++ xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java 18 Nov 2002
22:41:38 -0000
@@ -15,6 +15,7 @@
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.render.pdf.*;
import org.apache.fop.svg.*;
+import
org.apache.fop.render.pdf.*;
import org.apache.fop.viewer.*;
import
org.w3c.dom.svg.*;
@@ -373,6 +374,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,7 +865,13 @@
int oldPageNumber = pageNumber;
graphics =
(Graphics2D)g;
- Page aPage = (Page)pageList.get(pageIndex);
+
+ // Nov 18, 2002 -
[aml/rlc] eliminates layout problems at various scaling
+
+ graphics.setRenderingHint
(RenderingHints.KEY_FRACTIONALMETRICS,
+
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+
+ Page aPage =
(Page)pageList.elementAt(pageIndex);
renderPage(aPage);
graphics = oldGraphics;
Index: xml-
fop/src/org/apache/fop/render/awt/FontSetup.java
===================================================================
RCS
file: /home/cvspublic/xml-
fop/src/org/apache/fop/render/awt/FontSetup.java,v
retrieving revision
1.3.2.4
diff -u -r1.3.2.4 FontSetup.java
— xml-
fop/src/org/apache/fop/render/awt/FontSetup.java 8 Nov 2002 10:25:27 -
0000 1.3.2.4
+++ xml-fop/src/org/apache/fop/render/awt/FontSetup.java 18 Nov 2002
22:41:38 -0000
@@ -19,8 +19,8 @@
// Java
import java.awt.Font;
import
java.awt.Graphics2D;
-import java.util.List;
-import java.net.URL;
+import
java.awt.RenderingHints ;
+import java.util.Vector;
/**
- sets up the AWT fonts. It
is similar to
@@ -46,8 +46,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 +55,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: