|
3 | 3 | import java.awt.Canvas; |
4 | 4 | import java.awt.Font; |
5 | 5 | import java.awt.FontMetrics; |
6 | | -import java.awt.Graphics2D; |
7 | 6 | import java.awt.Shape; |
8 | 7 | import java.awt.Toolkit; |
9 | 8 | import java.awt.font.FontRenderContext; |
@@ -1196,26 +1195,25 @@ protected void disableTexturing(int target) { |
1196 | 1195 |
|
1197 | 1196 | @Override |
1198 | 1197 | protected int getFontAscent(Font font) { |
1199 | | - //FontMetrics metrics = pg.parent.getFontMetrics(font); |
1200 | 1198 | @SuppressWarnings("deprecation") |
1201 | 1199 | FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(font); |
1202 | 1200 | return metrics.getAscent(); |
1203 | 1201 | } |
1204 | 1202 |
|
1205 | 1203 |
|
1206 | 1204 | protected int getFontDescent(Object font) { |
| 1205 | + FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics((Font)font); |
1207 | 1206 | // FontMetrics metrics = pg.parent.getFontMetrics((Font)font); |
1208 | | -// return metrics.getDescent(); |
1209 | | - return 0; |
| 1207 | + return metrics.getDescent(); |
1210 | 1208 | } |
1211 | 1209 |
|
1212 | 1210 |
|
1213 | 1211 | protected int getTextWidth(Object font, char buffer[], int start, int stop) { |
1214 | 1212 | // maybe should use one of the newer/fancier functions for this? |
1215 | | -// int length = stop - start; |
| 1213 | + int length = stop - start; |
1216 | 1214 | // FontMetrics metrics = pg.parent.getFontMetrics((Font)font); |
1217 | | -// return metrics.charsWidth(buffer, start, length); |
1218 | | - return 0; |
| 1215 | + FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics((Font)font); |
| 1216 | + return metrics.charsWidth(buffer, start, length); |
1219 | 1217 | } |
1220 | 1218 |
|
1221 | 1219 |
|
@@ -1399,8 +1397,8 @@ protected class FontOutline implements PGL.FontOutline { |
1399 | 1397 |
|
1400 | 1398 | public FontOutline(char ch, Object font) { |
1401 | 1399 | char textArray[] = new char[] { ch }; |
1402 | | - Graphics2D graphics = (Graphics2D) pg.parent.frame.getGraphics(); |
1403 | | - FontRenderContext frc = graphics.getFontRenderContext(); |
| 1400 | +// Graphics2D graphics = (Graphics2D) pg.parent.frame.getGraphics(); |
| 1401 | + FontRenderContext frc = pg.getFontRenderContext((Font)font); |
1404 | 1402 | GlyphVector gv = ((Font)font).createGlyphVector(frc, textArray); |
1405 | 1403 | Shape shp = gv.getOutline(); |
1406 | 1404 | iter = shp.getPathIterator(null); |
|
0 commit comments