You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by dv...@apache.org on 2009/01/04 15:59:12 UTC

svn commit: r731265 - in /xmlgraphics/batik/trunk: CHANGES sources/org/apache/batik/gvt/font/AWTGVTFont.java sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java

Author: dvholten
Date: Sun Jan  4 06:59:12 2009
New Revision: 731265

URL: http://svn.apache.org/viewvc?rev=731265&view=rev
Log:
fixes bug 43411 : having scale as a float in AWTGVTFont couldn't deliver enough bits into graphics2D.scale() at AWTGVTGlyphVector:926

Modified:
    xmlgraphics/batik/trunk/CHANGES
    xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTFont.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java

Modified: xmlgraphics/batik/trunk/CHANGES
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/CHANGES?rev=731265&r1=731264&r2=731265&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/CHANGES (original)
+++ xmlgraphics/batik/trunk/CHANGES Sun Jan  4 06:59:12 2009
@@ -10,7 +10,7 @@
 1. Bugzilla problem reports fixed:
 
     44590, 44919, 44936, 44966, 45112, 45114, 45117, 45520, 45883, 
-    44553, 45958, 46072, 46124, 46430, 46431
+    44553, 45958, 46072, 46124, 46430, 46431, 43411
 
 2. New features
 

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTFont.java?rev=731265&r1=731264&r2=731265&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTFont.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTFont.java Sun Jan  4 06:59:12 2009
@@ -44,9 +44,9 @@
  */
 public class AWTGVTFont implements GVTFont {
 
-    protected Font  awtFont;
-    protected float size;
-    protected float scale;
+    protected Font   awtFont;
+    protected double size;
+    protected double scale;
 
     /**
      * Creates a new AWTGVTFont that wraps the given Font.
@@ -66,7 +66,7 @@
      * @param font The font object to wrap.
      * @param scale The scale factor to apply to font...
      */
-    public AWTGVTFont(Font font, float scale) {
+    public AWTGVTFont(Font font, double scale) {
         this.size = font.getSize2D()*scale;
         this.awtFont = font.deriveFont(FONT_SIZE);
         this.scale = size/awtFont.getSize2D();
@@ -223,7 +223,7 @@
                                          int limit,
                                          FontRenderContext frc) {
         return new GVTLineMetrics
-            (awtFont.getLineMetrics(chars, beginIndex, limit, frc), scale);
+            (awtFont.getLineMetrics(chars, beginIndex, limit, frc), (float)scale);
     }
 
     /**
@@ -234,7 +234,7 @@
                                          int limit,
                                          FontRenderContext frc) {
         return new GVTLineMetrics
-            (awtFont.getLineMetrics(ci, beginIndex, limit, frc), scale);
+            (awtFont.getLineMetrics(ci, beginIndex, limit, frc), (float)scale);
     }
 
     /**
@@ -242,7 +242,7 @@
      *  FontRenderContext.
      */
     public GVTLineMetrics getLineMetrics(String str, FontRenderContext frc) {
-        return new GVTLineMetrics(awtFont.getLineMetrics(str, frc), scale);
+        return new GVTLineMetrics(awtFont.getLineMetrics(str, frc), (float)scale);
     }
 
     /**
@@ -253,33 +253,33 @@
                                          int limit,
                                          FontRenderContext frc) {
         return new GVTLineMetrics
-            (awtFont.getLineMetrics(str, beginIndex, limit, frc), scale);
+            (awtFont.getLineMetrics(str, beginIndex, limit, frc), (float)scale);
     }
 
     /**
      * Returns the size of this font.
      */
     public float getSize() {
-        return size;
+        return (float)size;
     }
 
     /**
      * Returns the horizontal kerning value for this glyph pair.
      */
     public float getHKern(int glyphCode1, int glyphCode2) {
-        return 0f;
+        return 0.0f;
     }
 
     /**
      * Returns the vertical kerning value for this glyph pair.
      */
     public float getVKern(int glyphCode1, int glyphCode2) {
-        return 0f;
+        return 0.0f;
     }
 
     /////////////////////////////////////////////////////////////////////////
 
-    public static final float FONT_SIZE = 48f;
+    public static final float FONT_SIZE = 48.0f;
 
     /**
      * Returns the geometry of the specified character. This method also put

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java?rev=731265&r1=731264&r2=731265&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java Sun Jan  4 06:59:12 2009
@@ -73,7 +73,7 @@
     private Rectangle2D visualBounds;
     private Rectangle2D logicalBounds;
     private Rectangle2D bounds2D;
-    private float scaleFactor;
+    private double scaleFactor;
     private float ascent;
     private float descent;
     private TextPaintInfo cacheTPI;
@@ -93,7 +93,7 @@
      */
     public AWTGVTGlyphVector(GlyphVector glyphVector,
                              AWTGVTFont font,
-                             float scaleFactor,
+                             double scaleFactor,
                              CharacterIterator ci) {
 
         this.awtGlyphVector = glyphVector;
@@ -245,8 +245,8 @@
         Shape[] tempLogicalBounds = new Shape[getNumGlyphs()];
         boolean[] rotated  = new boolean[getNumGlyphs()];
 
-        double maxWidth = -1;
-        double maxHeight = -1;
+        double maxWidth = -1.0;
+        double maxHeight = -1.0;
         for (int i = 0; i < getNumGlyphs(); i++) {
 
             if (!glyphVisible[i]) {
@@ -258,11 +258,11 @@
             AffineTransform glyphTransform = getGlyphTransform(i);
             GVTGlyphMetrics glyphMetrics   = getGlyphMetrics(i);
 
-            float glyphX      = 0;
-            float glyphY      = -ascent/scaleFactor;
-            float glyphWidth  = (glyphMetrics.getHorizontalAdvance()/
+            float glyphX      = 0.0f;
+            float glyphY      = (float)(-ascent/scaleFactor);
+            float glyphWidth  = (float)(glyphMetrics.getHorizontalAdvance()/
                                  scaleFactor);
-            float glyphHeight = (glyphMetrics.getVerticalAdvance()/
+            float glyphHeight = (float)(glyphMetrics.getVerticalAdvance()/
                                  scaleFactor);
             Rectangle2D glyphBounds = new Rectangle2D.Double(glyphX,
                                                              glyphY,
@@ -429,7 +429,7 @@
         float adv = (float)(defaultGlyphPositions[glyphIndex+1].getX()-
                             defaultGlyphPositions[glyphIndex]  .getX());
         glyphMetrics[glyphIndex] =  new GVTGlyphMetrics
-            (adv*scaleFactor, (ascent+descent),
+            ((float)(adv*scaleFactor), (ascent+descent),
              bounds, GlyphMetrics.STANDARD);
 
         return glyphMetrics[glyphIndex];
@@ -925,8 +925,8 @@
             }
             graphics2D.scale(sf, sf);
             graphics2D.setPaint(fillPaint);
-            graphics2D.drawGlyphVector(awtGlyphVector, 0, 0);
-            graphics2D.scale(1/sf, 1/sf);
+            graphics2D.drawGlyphVector(awtGlyphVector, 0.0f, 0.0f);
+            graphics2D.scale(1.0/sf, 1.0/sf);
 
             for (int i=0; i< numGlyphs; i++) {
                 Point2D         pos = defaultGlyphPositions[i];