Subversion Repository Public Repository

litesoft

Diff Revisions 49 vs 934 for /trunk/Java/KeyHole/src/org/litesoft/aokeyhole/toolkit/BoxedText.java

Diff revisions: vs.
  @@ -1,6 +1,8 @@
1 1 // This Source Code is in the Public Domain per: http://litesoft.org/License.txt
2 2 package org.litesoft.aokeyhole.toolkit;
3 3
4 + import org.litesoft.aokeyhole.swing.*;
5 +
4 6 import java.awt.*;
5 7 import java.awt.geom.*;
6 8
  @@ -90,11 +92,15 @@
90 92 mUnfinished = false;
91 93
92 94 FontMetrics metrics = pGraphics.getFontMetrics();
95 + Font zFont = metrics.getFont();
96 + mFont = AdjustFont.common( zFont );
97 + if (mFont != zFont) {
98 + metrics = pGraphics.getFontMetrics( mFont );
99 + }
100 + mFontDecent = metrics.getDescent();
93 101 Rectangle2D bounds = metrics.getStringBounds( mName, null );
94 102 mBoxHeight = (mTextHeight = (int) (bounds.getHeight() + 0.99)) + 3;
95 103 mBoxWidth = (mTextWidth = (int) (bounds.getWidth() + 0.99)) + 5;
96 - mFontDecent = metrics.getDescent();
97 - mFont = metrics.getFont();
98 104 }
99 105 }
100 106
  @@ -201,7 +207,7 @@
201 207 int atX = (mAtX - (mTextWidth + 1) / 2) + 1;
202 208 int atY = (mAtY - (mTextHeight + 1) / 2) + mTextHeight - (mFontDecent + 1);
203 209
204 - Font curFont = pGraphics.getFont();
210 + Font curFont = AdjustFont.common( pGraphics.getFont() );
205 211 if ( mFont.equals( curFont ) )
206 212 {
207 213 pGraphics.drawString( mName, atX, atY );