| stringadvance |
(String str) |
typedict.Graphics |
| |
Returns a
Dimension
that represents the distance the current point would move horizontally
and vertically in user space if the string
str
were printed by
show
on
drawable
using the current
font.
The value stored in the dimension's width field matches the number
returned by
stringwidth.
In addition, all currently supported fonts store
0
in the dimension's height field, but that may change in a future release.
| |
| Example: |
The program,
import yoix.*.*;
JFrame f = {
Color background = Color.black;
Graphics graphics = {
String font = "Lucida-bold-24";
};
paint(Rectangle r) {
Dimension advance;
String text = "hello, world";
graphics { // "named block"
gsave();
rectclip(r);
translate(144, 144);
rotate(15);
moveto(0, 0);
rlineto(72*3, 0);
moveto(0, 0);
rlineto(0, 72*3);
setrgbcolor(1, 1, 1);
stroke();
advance = stringadvance(text);
moveto(-advance.width/2, -advance.height/2);
setrgbcolor(1, 0, 0);
show(text);
grestore();
}
}
};
f.visible = TRUE;
defines a paint function in a frame that draws coordinate axes
and then uses
stringadvance
to figure out how to print a string so its center end up near the origin.
| | |
| Return: |
Dimension
| | |
| See Also: |
ashow,
awidthshow,
charpath,
imagepath,
kshow,
show,
showimage,
stringbounds,
stringwidth,
widthshow
|
|
Yoix is a registered trademark of AT&T Inc.
|