public static int getScreenResolution() {
return toPixelSize("1in");
}
public static Dimension getStringBoxSize(Element span, final String str) {
final BodyElement body = Document.get().getBody();
span.setInnerText(str);
setStyleAttribute(span, "left", "");
setStyleAttribute(span, "top", "");
setStyleAttribute(span, "position", "absolute");
setStyleAttribute(span, "visibility", "hidden");
// force "auto" width
setStyleAttribute(span, "width", "0px");
setStyleAttribute(span, "height", "0px");
span.getOffsetWidth();
span.getOffsetHeight();
setStyleAttribute(span, "width", "auto");
setStyleAttribute(span, "height", "auto");
try {
body.appendChild(span);
return getBoxSize(span);
} finally {
body.removeChild(span);
}
}