You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2002/11/19 00:01:37 UTC
DO NOT REPLY [Bug 14657] New: -
[PATCH] Awt measuring/rendering problems
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14657>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14657
[PATCH] Awt measuring/rendering problems
Summary: [PATCH] Awt measuring/rendering problems
Product: Fop
Version: 0.20.4
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: awt renderer
AssignedTo: fop-dev@xml.apache.org
ReportedBy: Ralph_LaChance@compuserve.com
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) {
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 ;
+
}
/**
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:
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org