deweese     01/12/10 14:01:00

  Modified:    sources/org/apache/batik/gvt/font AWTGVTGlyphVector.java
               sources/org/apache/batik/gvt/text GlyphLayout.java
  Log:
  1) Fixed the last text layout issues on Mac OS X (GlyphVector was
     returning the metrics for the first char for all chars in the vector.
     We now use the difference in defaultGlyphPositions to get the
     character advances).
  
  Revision  Changes    Path
  1.15      +14 -12    
xml-batik/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java
  
  Index: AWTGVTGlyphVector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AWTGVTGlyphVector.java    2001/12/10 18:30:34     1.14
  +++ AWTGVTGlyphVector.java    2001/12/10 22:00:59     1.15
  @@ -34,7 +34,7 @@
    * This is a wrapper class for a java.awt.font.GlyphVector instance.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Bella Robinson</a>
  - * @version $Id: AWTGVTGlyphVector.java,v 1.14 2001/12/10 18:30:34 deweese Exp $
  + * @version $Id: AWTGVTGlyphVector.java,v 1.15 2001/12/10 22:00:59 deweese Exp $
    */
   public class AWTGVTGlyphVector implements GVTGlyphVector {
   
  @@ -349,16 +349,18 @@
       public GVTGlyphMetrics getGlyphMetrics(int glyphIndex) {
           if (glyphMetrics[glyphIndex] == null) {
               GlyphMetrics gm = awtGlyphVector.getGlyphMetrics(glyphIndex);
  -            Rectangle2D gmBounds = gm.getBounds2D();
  -
  -            Rectangle2D bounds = 
  -                new Rectangle2D.Double(gmBounds.getX()      * scaleFactor, 
  -                                       gmBounds.getY()      * scaleFactor,
  -                                       gmBounds.getWidth()  * scaleFactor, 
  -                                       gmBounds.getHeight() * scaleFactor);
  -
  +            Rectangle2D gmB = gm.getBounds2D();
  +            Rectangle2D bounds = new Rectangle2D.Double
  +                (gmB.getX()     * scaleFactor, gmB.getY()      * scaleFactor,
  +                 gmB.getWidth() * scaleFactor, gmB.getHeight() * scaleFactor);
  +            
  +            // defaultGlyphPositions has one more entry than glyphs
  +            // the last entry stores the total advance for the
  +            // glyphVector.
  +            float adv = (float)(defaultGlyphPositions[glyphIndex+1].getX()-
  +                                defaultGlyphPositions[glyphIndex]  .getX());
               glyphMetrics[glyphIndex] =  new GVTGlyphMetrics
  -                (gm.getAdvance()*scaleFactor, (ascent+descent), 
  +                (adv*scaleFactor, (ascent+descent), 
                    bounds, GlyphMetrics.STANDARD);
           }
           return glyphMetrics[glyphIndex];
  @@ -536,8 +538,8 @@
       public void performDefaultLayout() {
           if (defaultGlyphPositions == null) {
               awtGlyphVector.performDefaultLayout();
  -            defaultGlyphPositions = new Point2D.Float[getNumGlyphs()];
  -            for (int i = 0; i < getNumGlyphs(); i++)
  +            defaultGlyphPositions = new Point2D.Float[getNumGlyphs()+1];
  +            for (int i = 0; i <= getNumGlyphs(); i++)
                   defaultGlyphPositions[i] = awtGlyphVector.getGlyphPosition(i);
           }
   
  
  
  
  1.32      +4 -4      xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java
  
  Index: GlyphLayout.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- GlyphLayout.java  2001/12/10 18:30:34     1.31
  +++ GlyphLayout.java  2001/12/10 22:00:59     1.32
  @@ -42,7 +42,7 @@
    * @see org.apache.batik.gvt.text.TextSpanLayout
    *
    * @author <a href="[EMAIL PROTECTED]>Bill Haneman</a>
  - * @version $Id: GlyphLayout.java,v 1.31 2001/12/10 18:30:34 deweese Exp $
  + * @version $Id: GlyphLayout.java,v 1.32 2001/12/10 22:00:59 deweese Exp $
    */
   public class GlyphLayout implements TextSpanLayout {
   
  @@ -907,9 +907,9 @@
           }
           int currentChar = aci.getBeginIndex();
   
  -        // calculate the offset of the first glyph
  -        // the offset will be 0 if the glyph is on the path (ie. not adjusted by
  -        // a dy or dx)
  +        // calculate the offset of the first glyph the offset will be
  +        // 0 if the glyph is on the path (ie. not adjusted by a dy or
  +        // dx)
           Point2D firstGlyphPosition = gv.getGlyphPosition(0);
           float glyphOffset = 0;   // offset perpendicular to path
           if (offsetApplied) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to