< prev index next >
src/java.desktop/share/classes/sun/font/FontDesignMetrics.java
Print this page
@@ -31,10 +31,11 @@
import java.awt.FontMetrics;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
+import java.awt.geom.Rectangle2D;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -517,10 +518,32 @@
return (int) (0.5 + width);
}
/**
+ * This method is called from java.awt.Font only after verifying
+ * the arguments and that the text is simple and there are no
+ * layout attributes, font transform etc.
+ */
+ public Rectangle2D getSimpleBounds(char data[], int off, int len) {
+
+ float width = 0;
+ int limit = off + len;
+ for (int i=off; i < limit; i++) {
+ char ch = data[i];
+ if (ch < 0x100) {
+ width += getLatinCharWidth(ch);
+ } else {
+ width += handleCharWidth(ch);
+ }
+ }
+
+ float height = ascent + descent + leading;
+ return new Rectangle2D.Float(0f, ascent, width, height);
+ }
+
+ /**
* Gets the advance widths of the first 256 characters in the
* {@code Font}. The advance is the
* distance from the leftmost point to the rightmost point on the
* character's baseline. Note that the advance of a
* {@code String} is not necessarily the sum of the advances
< prev index next >