< prev index next >
src/java.desktop/share/classes/javax/swing/text/GlyphPainter1.java
Print this page
@@ -57,11 +57,12 @@
public float getSpan(GlyphView v, int p0, int p1,
TabExpander e, float x) {
sync(v);
Segment text = v.getText(p0, p1);
int[] justificationData = getJustificationData(v);
- int width = Utilities.getTabbedTextWidth(v, text, metrics, (int) x, e, p0,
+
+ float width = Utilities.getTabbedTextWidth(v, text, metrics, x, e, p0,
justificationData);
SegmentCache.releaseSharedSegment(text);
return width;
}
@@ -220,14 +221,19 @@
}
@SuppressWarnings("deprecation")
void sync(GlyphView v) {
Font f = v.getFont();
- if ((metrics == null) || (! f.equals(metrics.getFont()))) {
- // fetch a new FontMetrics
+ FontMetrics fm = null;
Container c = v.getContainer();
- metrics = (c != null) ? c.getFontMetrics(f) :
+ if (c != null) {
+ fm = c.getFontMetrics(f);
+ }
+ if ((metrics == null) || (! f.equals(metrics.getFont()))
+ || (! metrics.equals(fm))) {
+ // fetch a new FontMetrics
+ metrics = (c != null) ? fm :
Toolkit.getDefaultToolkit().getFontMetrics(f);
}
}
< prev index next >