1 |
/* GdkFontMetrics.java |
/* GdkFontMetrics.java |
2 |
Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc. |
Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
63 |
static final int TEXT_METRICS_X_ADVANCE = 4; |
static final int TEXT_METRICS_X_ADVANCE = 4; |
64 |
static final int TEXT_METRICS_Y_ADVANCE = 5; |
static final int TEXT_METRICS_Y_ADVANCE = 5; |
65 |
|
|
66 |
|
/** |
67 |
|
* Makes sure to return a Font based on the given Font that has as |
68 |
|
* peer a GdkFontPeer. Used in the initializer. |
69 |
|
*/ |
70 |
|
private static Font initFont(Font font) |
71 |
|
{ |
72 |
|
if (font == null) |
73 |
|
return new Font("Dialog", Font.PLAIN, 12); |
74 |
|
else if (font.getPeer() instanceof GdkFontPeer) |
75 |
|
return font; |
76 |
|
else |
77 |
|
{ |
78 |
|
ClasspathToolkit toolkit; |
79 |
|
toolkit = (ClasspathToolkit) Toolkit.getDefaultToolkit(); |
80 |
|
return toolkit.getFont(font.getName(), font.getAttributes()); |
81 |
|
} |
82 |
|
} |
83 |
|
|
84 |
public GdkFontMetrics (Font font) |
public GdkFontMetrics (Font font) |
85 |
{ |
{ |
86 |
super ((font == null) |
super(initFont(font)); |
|
? new Font("Dialog", Font.PLAIN, 12) |
|
|
: font.getPeer() instanceof GdkFontPeer |
|
|
? font |
|
|
: ((ClasspathToolkit)(Toolkit.getDefaultToolkit ())) |
|
|
.getFont (font.getName(), font.getAttributes ())); |
|
|
|
|
87 |
peer = (GdkFontPeer) this.font.getPeer(); |
peer = (GdkFontPeer) this.font.getPeer(); |
88 |
|
|
89 |
font_metrics = new int[5]; |
font_metrics = new int[5]; |