Methods Summary |
---|
public int | charWidth(int ch)Returns the advance width of the specified char of the Font describing
this FontMetricsImpl object.
if (ch < 256) {
return widths[ch];
}
return getFontPeer().charWidth((char) ch);
|
public int | charWidth(char ch)Returns the advance width of the specified char of the Font describing
this FontMetricsImpl object.
if (ch < 256) {
return widths[ch];
}
return (int) (getFontPeer().charWidth(ch) * scaleX);
|
public int | getAscent()Returns the ascent of the Font describing this FontMetricsImpl object.
return this.ascent;
|
public int | getDescent()Returns the descent of the Font describing this FontMetricsImpl object.
return this.descent;
|
public FontPeerImpl | getFontPeer()Returns FontPeer implementation of the Font describing this
FontMetricsImpl object.
if (peer == null) {
peer = (FontPeerImpl) font.getPeer();
}
return peer;
|
public int | getLeading()Returns the leading of the Font describing this FontMetricsImpl object.
return this.leading;
|
public int | getMaxAdvance()Returns the maximum advance of the Font describing this FontMetricsImpl
object.
return this.maxAdvance;
|
public int | getMaxAscent()Returns the maximum ascent of the Font describing this FontMetricsImpl
object.
return this.maxAscent;
|
public int | getMaxDecent()Returns the maximum descent of the Font describing this FontMetricsImpl
object.
return this.maxDescent;
|
public int | getMaxDescent()Returns the maximum descent of the Font describing this FontMetricsImpl
object.
return this.maxDescent;
|
public int[] | getWidths()Returns the advance widths of the first 256 characters in the Font
describing this FontMetricsImpl object.
return this.widths;
|
private void | initWidths()Initialize the array of the first 256 chars' advance widths of the Font
describing this FontMetricsImpl object.
this.widths = new int[256];
for (int chr = 0; chr < 256; chr++) {
widths[chr] = (int) (getFontPeer().charWidth((char) chr) * scaleX);
}
|
public int | stringWidth(java.lang.String str)Returns the total advance width of the specified string in the metrics of
the Font describing this FontMetricsImpl object.
int width = 0;
char chr;
for (int i = 0; i < str.length(); i++) {
chr = str.charAt(i);
width += charWidth(chr);
}
return width;
/*
* float res = 0; int ln = str.length(); char[] c = new char[ln]; float[] f =
* new float[ln]; str.getChars(0, ln, c, 0); mSg.getPaint().getTextWidths(c, 0,
* ln, f);
*
* for(int i = 0; i < f.length; i++) { res += f[i]; } return (int)res;
*/
|