Hi,
This patch fixes the getLogicalBounds, getVisualBounds, and getOutline
methods in FreetypeGlyphVector. Individual glyphs need to be translated
to their position in the string before their bounds or outline is
appended.
Cheers,
Francis
2006-10-17 Francis Kung <[EMAIL PROTECTED]>
PR 29450
* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(getLogicalBounds): Translate individual glyphs before appending
bounds.
(getOutline): Translate individual glyphs before appending outline.
Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.10
diff -u -r1.10 FreetypeGlyphVector.java
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java 21 Sep 2006 23:05:55 -0000 1.10
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java 17 Oct 2006 18:04:55 -0000
@@ -424,10 +424,18 @@
return logicalBounds;
Rectangle2D rect = (Rectangle2D)getGlyphLogicalBounds( 0 );
+ AffineTransform tx = new AffineTransform();
for( int i = 1; i < nGlyphs; i++ )
{
- Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
- rect = rect.createUnion( r2 );
+ Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
+
+ // Translate to the glyph's position
+ tx.setToTranslation(glyphPositions[i*2], glyphPositions[i*2+1]);
+ Point2D pt = new Point2D.Double(r2.getMinX(), r2.getMinY());
+ tx.transform(pt, pt);
+ r2.setRect(pt.getX(), pt.getY(), r2.getWidth(), r2.getHeight());
+
+ rect = rect.createUnion( r2 );
}
logicalBounds = rect;
@@ -448,8 +456,14 @@
public Shape getOutline()
{
GeneralPath path = new GeneralPath();
+ AffineTransform tx = new AffineTransform();
for( int i = 0; i < getNumGlyphs(); i++ )
- path.append( getGlyphOutline( i ), false );
+ {
+ Shape outline = getGlyphOutline(i);
+ tx.setToTranslation(glyphPositions[i*2], glyphPositions[i*2 +1]);
+ outline = tx.createTransformedShape(outline);
+ path.append(outline, false);
+ }
return path;
}