< prev index next >
src/java.desktop/share/classes/javax/swing/text/GlyphPainter1.java
Print this page
*** 57,67 ****
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,
justificationData);
SegmentCache.releaseSharedSegment(text);
return width;
}
--- 57,68 ----
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);
!
! float width = Utilities.getTabbedTextWidth(v, text, metrics, x, e, p0,
justificationData);
SegmentCache.releaseSharedSegment(text);
return width;
}
*** 220,233 ****
}
@SuppressWarnings("deprecation")
void sync(GlyphView v) {
Font f = v.getFont();
! if ((metrics == null) || (! f.equals(metrics.getFont()))) {
! // fetch a new FontMetrics
Container c = v.getContainer();
! metrics = (c != null) ? c.getFontMetrics(f) :
Toolkit.getDefaultToolkit().getFontMetrics(f);
}
}
--- 221,239 ----
}
@SuppressWarnings("deprecation")
void sync(GlyphView v) {
Font f = v.getFont();
! FontMetrics fm = null;
Container c = v.getContainer();
! 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 >