This fixes some glitches in the autohinter and adds support for passing
flags to the hinter.

2006-12-16  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/awt/font/FontDelegate.java
        (FLAG_FITTED): New constant field.
        (FLAG_NO_HINT_HORIZONTAL): New constant field.
        (FLAG_NO_HINT_VERTICAL): New constant field.w
        (FLAG_NO_HINT_EDGE_POINTS): New constant field.
        (FLAG_NO_HINT_STRONG_POINTS): New constant field.
        (FLAG_NO_HINT_WEAK_POINTS): New constant field.
        (TYPE_FITTED): Replaced by flags above.
        (TYPE_SCALED): Replaced by flags above.
        (TYPE_ORIGINAL): Replaced by flags above.
        * gnu/java/awt/font/GNUGlyphVector.java
        (getGlyphOutline): Use FLAG_FITTED.
        * gnu/java/awt/font/autofit/AutoHinter.java
        (setFlags): New method. Sets hinting flags.
        * gnu/java/awt/font/autofit/GlyphHints.java
        (flags): New field.
        (alignStrongPoint): Use 16.16 fixed arithmetic.
        (doAlignEdgePoints): New helper method.
        (doAlignStrongPoints): New helper method.
        (doAlignWeakPoints): New helper method.
        (doHorizonal): Check flags.
        (doVertical): Check flags.
        * gnu/java/awt/font/autofit/Latin.java
        (applyHints): Check hinting flags.
        (computeEdges): Also initialize fitted position.
        (scaleMetricsDim): Commented out buggy block.
        * gnu/java/awt/font/opentype/Hinter.java
        (setFlags): New method.
        * gnu/java/awt/font/opentype/OpenTypeFont.java
        (checkHinter): Accept flags parameter.
        (createGlyphVector): Pass flags to hinter.
        (getGlyphOutline): Pass flags to hinter.
        * gnu/java/awt/font/opentype/truetype/Fixed.java
        (floatValue16): New method.
        * gnu/java/awt/font/opentype/truetype/Zone.java
        (getX): Use new flags.
        (getY): Use new flags.

/Roman

Index: gnu/java/awt/font/FontDelegate.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/FontDelegate.java,v
retrieving revision 1.2
diff -u -1 -5 -r1.2 FontDelegate.java
--- gnu/java/awt/font/FontDelegate.java	15 Dec 2006 21:43:48 -0000	1.2
+++ gnu/java/awt/font/FontDelegate.java	16 Dec 2006 20:49:49 -0000
@@ -49,33 +49,36 @@
 
 
 /**
  * The interface that all font delegate objects implement,
  * irrespective of where they get their information from.
  *
  * <p><b>Thread Safety:</b> All classes that implement the
  * <code>FontDelegate</code> interface must allow calling these
  * methods from multiple concurrent threads. The delegates are
  * responsible for performing the necessary synchronization.
  *
  * @author Sascha Brawer ([EMAIL PROTECTED])
  */
 public interface FontDelegate
 {
-  public static final int TYPE_ORIGINAL = 0;
-  public static final int TYPE_SCALED = 1;
-  public static final int TYPE_FITTED = 2;
+  public static final int FLAG_FITTED = 1 << 0;
+  public static final int FLAG_NO_HINT_HORIZONTAL = 1 << 1;
+  public static final int FLAG_NO_HINT_VERTICAL = 1 << 2;
+  public static final int FLAG_NO_HINT_EDGE_POINTS = 1 << 3;
+  public static final int FLAG_NO_HINT_STRONG_POINTS = 1 << 4;
+  public static final int FLAG_NO_HINT_WEAK_POINTS = 1 << 5;
 
   /**
    * Returns the full name of this font face in the specified
    * locale, for example <i>&#x201c;Univers Light&#x201d;</i>.
    *
    * @param locale the locale for which to localize the name.
    *
    * @return the face name.
    */
   public String getFullName(Locale locale);
   
   
   /**
    * Returns the name of the family to which this font face belongs,
    * for example <i>&#x201c;Univers&#x201d;</i>.
Index: gnu/java/awt/font/GNUGlyphVector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/GNUGlyphVector.java,v
retrieving revision 1.3
diff -u -1 -5 -r1.3 GNUGlyphVector.java
--- gnu/java/awt/font/GNUGlyphVector.java	15 Dec 2006 21:43:49 -0000	1.3
+++ gnu/java/awt/font/GNUGlyphVector.java	16 Dec 2006 20:49:49 -0000
@@ -316,31 +316,31 @@
 
     validate();
 
     if ((transforms != null)
         && ((glyphTx = transforms[glyphIndex]) != null))
     {
       tx =  new AffineTransform(transform);
       tx.concatenate(glyphTx);
     }
     else
       tx = transform;
 
     path = fontDelegate.getGlyphOutline(glyphs[glyphIndex], fontSize, tx,
                                         renderContext.isAntiAliased(),
                                         renderContext.usesFractionalMetrics(),
-                                        FontDelegate.TYPE_FITTED);
+                                        FontDelegate.FLAG_FITTED);
 
     tx = new AffineTransform();
     tx.translate(pos[glyphIndex * 2], pos[glyphIndex * 2 + 1]);
     path.transform(tx);
     return path;
   }
 
   public Shape getGlyphOutline(int glyphIndex, int type)
   {
     AffineTransform tx, glyphTx;
     GeneralPath path;
 
     validate();
 
     if ((transforms != null)
Index: gnu/java/awt/font/autofit/AutoHinter.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/autofit/AutoHinter.java,v
retrieving revision 1.3
diff -u -1 -5 -r1.3 AutoHinter.java
--- gnu/java/awt/font/autofit/AutoHinter.java	15 Dec 2006 00:59:46 -0000	1.3
+++ gnu/java/awt/font/autofit/AutoHinter.java	16 Dec 2006 20:49:50 -0000
@@ -61,16 +61,23 @@
     metrics = new LatinMetrics(font);
     latinScript.initMetrics(metrics, font);
     scaler.face = font;
   }
 
   public void applyHints(Zone outline)
   {
     if (hints == null)
       hints = new GlyphHints();
     scaler.xScale = Fixed.valueOf16(outline.scaleX * 64);
     scaler.yScale = Fixed.valueOf16(outline.scaleY * 64);
     latinScript.scaleMetrics(metrics, scaler);
     latinScript.applyHints(hints, outline, metrics);
   }
 
+  public void setFlags(int flags)
+  {
+    if (hints == null)
+      hints = new GlyphHints();
+    hints.flags = flags;
+  }
+
 }
Index: gnu/java/awt/font/autofit/GlyphHints.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/autofit/GlyphHints.java,v
retrieving revision 1.5
diff -u -1 -5 -r1.5 GlyphHints.java
--- gnu/java/awt/font/autofit/GlyphHints.java	15 Dec 2006 21:43:49 -0000	1.5
+++ gnu/java/awt/font/autofit/GlyphHints.java	16 Dec 2006 20:49:50 -0000
@@ -26,59 +26,61 @@
 As a special exception, the copyright holders of this library give you
 permission to link this library with independent modules to produce an
 executable, regardless of the license terms of these independent
 modules, and to copy and distribute the resulting executable under
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 
 package gnu.java.awt.font.autofit;
 
+import gnu.java.awt.font.FontDelegate;
 import gnu.java.awt.font.opentype.truetype.Fixed;
 import gnu.java.awt.font.opentype.truetype.Point;
 import gnu.java.awt.font.opentype.truetype.Zone;
 
 /**
  * The data and methods used for the actual hinting process.
  */
 class GlyphHints
   implements Constants
 {
 
   int xScale;
   int xDelta;
   int yScale;
   int yDelta;
 
   AxisHints[] axis;
 
   Point[] points;
   int numPoints;
   int maxPoints;
 
   Point[] contours;
   int numContours;
   int maxContours;
 
   ScriptMetrics metrics;
 
-  
+  int flags;
+
   GlyphHints()
   {
     axis = new AxisHints[Constants.DIMENSION_MAX];
     axis[Constants.DIMENSION_VERT] = new AxisHints();
     axis[Constants.DIMENSION_HORZ] = new AxisHints();
 
     xScale = Fixed.ONE;
     yScale = Fixed.ONE;
   }
 
   void rescale(ScriptMetrics m)
   {
     metrics = m;
     // TODO: Copy scalerFlags.
   }
@@ -275,36 +277,36 @@
                     start.addFlags(Point.FLAG_INFLECTION);
                     start = start.getNext();
                   } while (start != end);
                 start.addFlags(Point.FLAG_INFLECTION);
               }
             start = end;
             end = after;
             angleSeg = angleOut;
             diffIn = diffOut;
           } while (! finished);
       }
   }
 
   boolean doHorizontal()
   {
-    return true; // Check scaler flags here.
+    return (flags & FontDelegate.FLAG_NO_HINT_HORIZONTAL) == 0;
   }
 
   boolean doVertical()
   {
-    return true; // Check scaler flags here.
+    return (flags & FontDelegate.FLAG_NO_HINT_VERTICAL) == 0;
   }
 
   void alignWeakPoints(int dim)
   {
     short touchFlag;
     Point point;
     // PASS 1 : Move segments to edge positions.
     if (dim == DIMENSION_HORZ)
       {
         touchFlag = Point.FLAG_DONE_X;
         for (int p = 0; p < numPoints; p++)
           {
             point = points[p];
             point.setU(point.getX());
             point.setV(point.getScaledX());
@@ -539,39 +541,39 @@
                         else
                           {
                             // Directly on the edge.
                             u = edge.pos;
                             storePoint(point, u, dim, touchFlag);
                             found = true;
                             break;
                           }
                       }
                     if (! found)
                       {
                         Edge before = edges[min - 1];
                         Edge after = edges[min];
                         if (before.scale == 0)
                           {
-                            before.scale = Fixed.div(after.pos - before.pos,
+                            before.scale = Fixed.div16(after.pos - before.pos,
                                                      after.fpos - before.fpos);
                           }
-                        u = before.pos + Fixed.mul(fu - before.fpos,
-                                                   before.scale);
+                        u = before.pos + Fixed.mul16(fu - before.fpos,
+                                                     before.scale);
                       }
+                    storePoint(point, u, dim, touchFlag);
                   }
               }
-            storePoint(point, u, dim, touchFlag);
           }
       }
   }
 
   private void storePoint(Point p, int u, int dim, short touchFlag)
   {
     if (dim == DIMENSION_HORZ)
       p.setX(u);
     else
       p.setY(u);
     p.addFlags(touchFlag);
   }
 
   void alignEdgePoints(int dim)
   {
@@ -607,16 +609,31 @@
   }
 
   private int getPointIndex(Point p)
   {
     int idx = -1;
     for (int i = 0; i < numPoints; i++)
       {
         if (p == points[i])
           {
             idx = i;
             break;
           }
       }
     return idx;
   }
+
+  public boolean doAlignEdgePoints()
+  {
+    return (flags & FontDelegate.FLAG_NO_HINT_EDGE_POINTS) == 0;
+  }
+
+  public boolean doAlignStrongPoints()
+  {
+    return (flags & FontDelegate.FLAG_NO_HINT_STRONG_POINTS) == 0;
+  }
+
+  public boolean doAlignWeakPoints()
+  {
+    return (flags & FontDelegate.FLAG_NO_HINT_WEAK_POINTS) == 0;
+  }
 }
Index: gnu/java/awt/font/autofit/Latin.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/autofit/Latin.java,v
retrieving revision 1.6
diff -u -1 -5 -r1.6 Latin.java
--- gnu/java/awt/font/autofit/Latin.java	15 Dec 2006 21:43:49 -0000	1.6
+++ gnu/java/awt/font/autofit/Latin.java	16 Dec 2006 20:49:50 -0000
@@ -85,33 +85,36 @@
       {
         detectFeatures(hints, DIMENSION_HORZ);
       }
     if (hints.doVertical())
       {
         detectFeatures(hints, DIMENSION_VERT);
         computeBlueEdges(hints, (LatinMetrics) metrics);
       }
     // Grid-fit the outline.
     for (int dim = 0; dim < DIMENSION_MAX; dim++)
       {
         if (dim == DIMENSION_HORZ && hints.doHorizontal()
             || dim == DIMENSION_VERT && hints.doVertical())
           {
             hintEdges(hints, dim);
-            hints.alignEdgePoints(dim);
-            hints.alignStrongPoints(dim);
-            hints.alignWeakPoints(dim);
+            if (hints.doAlignEdgePoints())
+              hints.alignEdgePoints(dim);
+            if (hints.doAlignStrongPoints())
+              hints.alignStrongPoints(dim);
+            if (hints.doAlignWeakPoints())
+              hints.alignWeakPoints(dim);
             
          }
       }
     // FreeType does a save call here. I guess that's not needed as we operate
     // on the live glyph data anyway.
   }
 
   private void hintEdges(GlyphHints hints, int dim)
   {
     AxisHints axis = hints.axis[dim];
     Edge[] edges = axis.edges;
     int numEdges = axis.numEdges;
     Edge anchor = null;
     int hasSerifs = 0;
 
@@ -271,31 +274,33 @@
                 int curPos1 = Utils.pixRound(orgPos);
                 int delta1 = curPos1 + (curLen >> 1) - orgCenter;
                 if (delta1 < 0)
                   delta1 = -delta1;
                 int curPos2 = Utils.pixRound(orgPos + orgLen) - curLen;
                 int delta2 = curPos2 + (curLen >> 1) - orgCenter;
                 if (delta2 < 0)
                   delta2 = -delta2;
                 edge.pos = (delta1 < delta2) ? curPos1 : curPos2;
                 edge2.pos = edge.pos + curLen;
               }
             edge.flags |= Segment.FLAG_EDGE_DONE;
             edge2.flags |= Segment.FLAG_EDGE_DONE;
 
             if (e > 0 && edge.pos < edges[e - 1].pos)
-              edge.pos = edges[e - 1].pos;
+              {
+                edge.pos = edges[e - 1].pos;
+              }
           }
       }
     // TODO: Implement the lowercase m symmetry thing.
 
     // Now we hint the remaining edges (serifs and singles) in order
     // to complete our processing.
     if (hasSerifs > 0 || anchor == null)
       {
         for (int e = 0; e < numEdges; e++)
           {
             Edge edge = edges[e];
             if ((edge.flags & Segment.FLAG_EDGE_DONE) != 0)
               continue;
             if (edge.serif != null)
               {
@@ -583,57 +588,57 @@
       {
         scale = scaler.yScale;
         delta = scaler.yDelta;
       }
     LatinAxis axis = lm.axis[dim];
     if (axis.orgScale == scale && axis.orgDelta == delta)
       // No change, no need to adjust.
       return;
     axis.orgScale = scale;
     axis.orgDelta = delta;
 
     // Correct X and Y scale to optimize the alignment of the top small
     // letters to the pixel grid.
     LatinAxis axis2 = lm.axis[DIMENSION_VERT];
     LatinBlue blue = null;
-    for (int nn = 0; nn < axis2.blueCount; nn++)
-      {
-        if ((axis2.blues[nn].flags & LatinBlue.FLAG_ADJUSTMENT) != 0)
-          {
-            blue = axis2.blues[nn];
-            break;
-          }
-      }
-    if (blue != null)
-      {
-        int scaled = Fixed.mul16(blue.shoot.org, scaler.yScale);
-        int fitted = Utils.pixRound(scaled);
-        if (scaled != fitted)
-          {
-            if (dim == DIMENSION_HORZ)
-              {
-                if (fitted < scaled)
-                  {
-                    scale -= scale / 50;
-                  }
-              }
-            else
-              {
-                scale = Utils.mulDiv(scale, fitted, scaled);
-              }
-          }
-      }
+//    for (int nn = 0; nn < axis2.blueCount; nn++)
+//      {
+//        if ((axis2.blues[nn].flags & LatinBlue.FLAG_ADJUSTMENT) != 0)
+//          {
+//            blue = axis2.blues[nn];
+//            break;
+//          }
+//      }
+//    if (blue != null)
+//      {
+//        int scaled = Fixed.mul16(blue.shoot.org, scaler.yScale);
+//        int fitted = Utils.pixRound(scaled);
+//        if (scaled != fitted)
+//          {
+//            if (dim == DIMENSION_HORZ)
+//              {
+//                if (fitted < scaled)
+//                  {
+//                    scale -= scale / 50;
+//                  }
+//              }
+//            else
+//              {
+//                scale = Utils.mulDiv(scale, fitted, scaled);
+//              }
+//          }
+//      }
     axis.scale = scale;
     axis.delta = delta;
     if (dim == DIMENSION_HORZ)
       {
         lm.scaler.xScale = scale;
         lm.scaler.xDelta = delta;
       }
     else
       {
         lm.scaler.yScale = scale;
         lm.scaler.yDelta = delta;
       }
     // Scale the standard widths.
     for (int nn = 0; nn < axis.widthCount; nn++)
       {
@@ -657,31 +662,31 @@
               {
                 int delta1 = blue.shoot.org - blue.ref.org;
                 int delta2 = delta1;
                 if (delta1 < 0)
                   delta2 = -delta2;
                 delta2 = Fixed.mul16(delta2, scale);
                 if (delta2 < 32)
                   delta2 = 0;
                 else if (delta2 < 64)
                   delta2 = 32 + (((delta2 - 32) + 16) & ~31);
                 else
                   delta2 = Utils.pixRound(delta2);
                 if (delta1 < 0)
                   delta2 = -delta2;
                 blue.ref.fit = Utils.pixRound(blue.ref.cur);
-                blue.shoot.fit = blue.ref.fit+ delta2;
+                blue.shoot.fit = blue.ref.fit + delta2;
                 blue.flags |= LatinBlue.FLAG_BLUE_ACTIVE;
               }
           }
       }
   }
 
   /**
    * Determines the standard stem widths.
    *
    * @param metrics the metrics to use
    * @param face the font face
    * @param ch the character that is used for getting the widths
    */
   private void initWidths(LatinMetrics metrics, OpenTypeFont face, char ch)
   {
@@ -1151,31 +1156,31 @@
               dist = -dist;
             if (dist < edgeDistanceThreshold)
               {
                 found = edge;
                 break;
               }
           }
         if (found == null)
           {
             // Insert new edge in the list and sort according to
             // the position.
             Edge edge = axis.newEdge(seg.pos);
             edge.first = seg;
             edge.last = seg;
             edge.fpos = seg.pos;
-            edge.opos = Fixed.mul16(seg.pos, scale);
+            edge.opos = edge.pos = Fixed.mul16(seg.pos, scale);
             seg.edgeNext = seg;
             seg.edge = edge;
           }
         else
           {
             seg.edgeNext = found.first;
             found.last.edgeNext = seg;
             found.last = seg;
             seg.edge = found;
           }
       }
     // Good. We will now compute each edge's properties according to
     // segments found on its position. Basically these are:
     // - Edge's main direction.
     // - Stem edge, serif edge, or both (which defaults to stem edge).
Index: gnu/java/awt/font/opentype/Hinter.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/Hinter.java,v
retrieving revision 1.2
diff -u -1 -5 -r1.2 Hinter.java
--- gnu/java/awt/font/opentype/Hinter.java	14 Dec 2006 20:32:54 -0000	1.2
+++ gnu/java/awt/font/opentype/Hinter.java	16 Dec 2006 20:49:50 -0000
@@ -46,16 +46,18 @@
 public interface Hinter
 {
   /**
    * Initializes the hinter.
    *
    * @param face the font for which the hinter should be used
    */
   void init(OpenTypeFont face);
 
   /**
    * Hints the specified outline.
    *
    * @param outline the outline to hint
    */
   void applyHints(Zone outline);
+
+  void setFlags(int flags);
 }
Index: gnu/java/awt/font/opentype/OpenTypeFont.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/OpenTypeFont.java,v
retrieving revision 1.5
diff -u -1 -5 -r1.5 OpenTypeFont.java
--- gnu/java/awt/font/opentype/OpenTypeFont.java	15 Dec 2006 21:43:49 -0000	1.5
+++ gnu/java/awt/font/opentype/OpenTypeFont.java	16 Dec 2006 20:49:51 -0000
@@ -570,31 +570,31 @@
    * will only be accurate if the passed
    * <code>FontRenderContext</code> correctly reflects the relevant
    * parameters. Hence, <code>frc</code> should be obtained from the
    * same <code>Graphics2D</code> that will be used for drawing, and
    * any rendering hints should be set to the desired values before
    * obtaining <code>frc</code>.
    *
    * @param ci a CharacterIterator for iterating over the
    * characters to be displayed.
    */
   public synchronized GlyphVector createGlyphVector(Font font,
                                                     FontRenderContext frc,
                                                     CharacterIterator ci)
   {
     // Initialize hinter if necessary.
-    checkHinter();
+    checkHinter(FontDelegate.FLAG_FITTED);
 
     CharGlyphMap cmap;    
     int numGlyphs;
     int[] glyphs;
     int glyph;
     int c;
 
     cmap = getCharGlyphMap();
     numGlyphs = ci.getEndIndex() - ci.getBeginIndex();
     glyphs = new int[numGlyphs];
     glyph = 0;
     for (c = ci.first(); c != CharacterIterator.DONE; c = ci.next())
     {
       /* handle surrogate pairs */
       if (c >> 10 == 0x36) // U+D800 .. U+DBFF: High surrogate
@@ -683,38 +683,38 @@
    * <code>false</code> for normal rendering. For hinted fonts, this
    * parameter may indeed affect the result.
    *
    * @param fractionalMetrics <code>true</code> for fractional
    * metrics, <code>false</code> for rounding the result to a pixel
    * boundary.
    *
    * @return the scaled and grid-fitted outline of the specified
    * glyph, or <code>null</code> for bitmap fonts.
    */
   public synchronized GeneralPath getGlyphOutline(int glyph,
                                                   float pointSize,
                                                   AffineTransform transform,
                                                   boolean antialias,
                                                   boolean fractionalMetrics,
-                                                  int type)
+                                                  int flags)
   {
     /* The synchronization is needed because the scaler is not
      * synchronized.
      */
-    checkHinter();
+    checkHinter(flags);
     return scaler.getOutline(glyph, pointSize, transform,
-                             antialias, fractionalMetrics, hinter, type);
+                             antialias, fractionalMetrics, hinter, flags);
   }
 
   /**
    * Fetches the raw glyph outline for the specified glyph index. This is used
    * for the autofitter only ATM and is otherwise not usable for outside code.
    *
    * @param glyph the glyph index to fetch
    * @param transform the transform to apply
    *
    * @return the raw outline of that glyph
    */
   public synchronized Zone getRawGlyphOutline(int glyph,
                                               AffineTransform transform)
   {
     return scaler.getRawOutline(glyph, transform);
@@ -836,36 +836,37 @@
    * <code>name</code> or <code>glyf</code>.
    */
   static String tagToString(int tag)
   {
     char[] c = new char[4];
     c[0] = (char) ((tag >> 24) & 0xff);
     c[1] = (char) ((tag >> 16) & 0xff);
     c[2] = (char) ((tag >> 8) & 0xff);
     c[3] = (char) (tag & 0xff);
     return new String(c);
   }
 
   /**
    * Checks if a hinter is installed and installs one when not.
    */
-  private void checkHinter()
+  private void checkHinter(int flags)
   {
     // When another hinting impl gets added (maybe a true TrueType hinter)
     // then add some options here. The Hinter interface might need to be
     // tweaked.
     if (hinter == null)
       {
         try
           {
             hinter = new AutoHinter();
             hinter.init(this);
           }
         catch (Exception ex)
           {
             // Protect from problems inside hinter.
             hinter = null;
             ex.printStackTrace();
           }
       }
+    hinter.setFlags(flags);
   }
 }
Index: gnu/java/awt/font/opentype/truetype/Fixed.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/truetype/Fixed.java,v
retrieving revision 1.3
diff -u -1 -5 -r1.3 Fixed.java
--- gnu/java/awt/font/opentype/truetype/Fixed.java	15 Dec 2006 00:59:46 -0000	1.3
+++ gnu/java/awt/font/opentype/truetype/Fixed.java	16 Dec 2006 20:49:51 -0000
@@ -114,31 +114,34 @@
     fy = ((float) y) / 64.0f;
     return (int) (Math.sqrt(fx * fx + fy * fy) * 64.0);
   }
 
 
   public static int intValue(int f)
   {
     return f >> 6;
   }
 
 
   public static float floatValue(int f)
   {
     return ((float) f) / 64;
   }
-
+  public static float floatValue16(int f)
+  {
+    return ((float) f) / 65536;
+  }
 
   public static double doubleValue(int f)
   {
     return ((double) f) / 64;
   }
 
 
   public static int valueOf(float f)
   {
     return (int) (f * 64);
   }
 
 
   public static int valueOf(double d)
   {
Index: gnu/java/awt/font/opentype/truetype/Zone.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/truetype/Zone.java,v
retrieving revision 1.6
diff -u -1 -5 -r1.6 Zone.java
--- gnu/java/awt/font/opentype/truetype/Zone.java	15 Dec 2006 21:43:49 -0000	1.6
+++ gnu/java/awt/font/opentype/truetype/Zone.java	16 Dec 2006 20:49:51 -0000
@@ -61,93 +61,73 @@
 
   public int getCapacity()
   {
     return points.length;
   }
 
 
   public int getSize()
   {
     return numPoints;
   }
 
 
   public int getX(int point)
   {
-    return getX(point, FontDelegate.TYPE_FITTED);
+    return getX(point, FontDelegate.FLAG_FITTED);
   }
 
-  public int getX(int point, int type)
+  public int getX(int point, int flags)
   {
     int x;
-    switch (type)
-    {
-      case FontDelegate.TYPE_FITTED:
-        x = points[point].x;
-        break;
-      case FontDelegate.TYPE_ORIGINAL:
-        x = points[point].origX;
-        break;
-      case FontDelegate.TYPE_SCALED:
-        x = points[point].scaledX;
-        break;
-      default:
-        x = points[point].x;
-    }
+    if ((flags & FontDelegate.FLAG_FITTED) != 0)
+      x = points[point].x;
+    else
+      x = points[point].scaledX;
     return x;
   }
 
 
   public void setX(int point, int value, boolean touch)
   {
     points[point].scaledX = value;
     points[point].x = value;
     if (touch)
       points[point].flags |= Point.FLAG_TOUCHED_X;
   }
 
 
   public void setY(int point, int value, boolean touch)
   {
     points[point].scaledY = value;
     points[point].y = value;
     if (touch)
       points[point].flags |= Point.FLAG_TOUCHED_Y;
   }
 
   public int getY(int point)
   {
-    return getY(point, FontDelegate.TYPE_FITTED);
+    return getY(point, FontDelegate.FLAG_FITTED);
   }
 
-  public int getY(int point, int type)
+  public int getY(int point, int flags)
   {
     int y;
-    switch (type)
-    {
-      case FontDelegate.TYPE_FITTED:
-        y = points[point].y;
-        break;
-      case FontDelegate.TYPE_ORIGINAL:
-        y = points[point].origY;
-        break;
-      case FontDelegate.TYPE_SCALED:
-        y = points[point].scaledY;
-        break;
-      default:
-        y = points[point].y;
-    }
+    if ((flags & FontDelegate.FLAG_FITTED) != 0)
+      y = points[point].y;
+    else
+      y = points[point].scaledY;
     return y;
   }
 
 
   public int getOriginalX(int point)
   {
     return points[point].origX;
   }
 
 
   public int getOriginalY(int point)
   {
     return points[point].origY;
   }
 

Reply via email to