I need to get the pixel height of a line of text with javascript. I've written a gwt method that works in Firefox and Chrome and does ok with IE8. But it doesn't work at all in IE7. My code follows, if anyone knows a solution I'd appreciate it.
public static int getFontHeight() {
HTML sizeText = new HTML("Abcdefghij <br/>klmno<br />pqrst<br /> uvwxyz");
sizeText.addStyleName("page");
AbsolutePanel ap = new AbsolutePanel();
ap.setSize("100%", "100%");
ap.add(sizeText, 50, 50);
sizeText.getElement().getStyle().setZIndex(-50);
RootPanel.get().add(ap);
int height = (int) sizeText.getOffsetHeight() / 4;
RootPanel.get().remove(ap);
if (DetectBrowser.isIE8()) return height + 2;
return height;
}