classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: fix for java.awt.FontMetrics


From: Roman Kennke
Subject: [cp-patches] FYI: fix for java.awt.FontMetrics
Date: Wed, 03 Aug 2005 16:43:59 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

There was a bug in FontMetrics.charsWidth. This method iterated from offset to len, which is only ok in the case when offset == 0. In all other cases this yields false results. It should of course iterate from offset to offset + len. This is fixed.

2005-08-03  Roman Kennke  <address@hidden>

        * java/awt/FontMetrics.java
        (charsWidth): Iterate to len + offset instead to len.

/Roman
Index: java/awt/FontMetrics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/FontMetrics.java,v
retrieving revision 1.13
diff -u -r1.13 FontMetrics.java
--- java/awt/FontMetrics.java   2 Jul 2005 20:32:24 -0000       1.13
+++ java/awt/FontMetrics.java   3 Aug 2005 14:41:33 -0000
@@ -235,7 +235,8 @@
   public int charsWidth(char[] buf, int offset, int len)
   {
     int total_width = 0;
-    for (int i = offset; i < len; i++)
+    int endOffset = offset + len;
+    for (int i = offset; i < endOffset; i++)
       total_width += charWidth(buf[i]);
     return total_width;
   }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]