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 |
|
|
|
static native void getPeerFontMetrics(GdkFontPeer peer, double [] metrics); |
|
|
static native void getPeerTextMetrics(GdkFontPeer peer, String str, double [] metrics); |
|
66 |
|
|
67 |
public GdkFontMetrics (Font font) |
public GdkFontMetrics (Font font) |
68 |
{ |
{ |
75 |
|
|
76 |
font_metrics = new int[5]; |
font_metrics = new int[5]; |
77 |
double [] hires = new double[5]; |
double [] hires = new double[5]; |
78 |
|
peer.getFontMetrics (hires); |
|
if (GtkToolkit.useGraphics2D ()) |
|
|
GdkGraphics2D.getPeerFontMetrics(peer, hires); |
|
|
else |
|
|
getPeerFontMetrics (peer, hires); |
|
|
|
|
79 |
for (int i = 0; i < 5; ++i) |
for (int i = 0; i < 5; ++i) |
80 |
font_metrics[i] = (int) hires[i]; |
font_metrics[i] = (int) hires[i]; |
81 |
} |
} |
83 |
public int stringWidth (String str) |
public int stringWidth (String str) |
84 |
{ |
{ |
85 |
double [] hires = new double[6]; |
double [] hires = new double[6]; |
86 |
if (GtkToolkit.useGraphics2D()) |
peer.getTextMetrics(str, hires); |
|
GdkGraphics2D.getPeerTextMetrics(peer, str, hires); |
|
|
else |
|
|
getPeerTextMetrics(peer, str, hires); |
|
87 |
return (int) hires [TEXT_METRICS_WIDTH]; |
return (int) hires [TEXT_METRICS_WIDTH]; |
88 |
} |
} |
89 |
|
|
105 |
public int getLeading () |
public int getLeading () |
106 |
{ |
{ |
107 |
return 1; |
return 1; |
|
// return metrics[ASCENT] + metrics[DESCENT]; |
|
108 |
} |
} |
109 |
|
|
110 |
public int getAscent () |
public int getAscent () |