static Pt centerTextInRect(Font font, S s, Rect r) { FontMetrics fm = getFontMetrics(font); int tw = fm.stringWidth(s), th = fm.getHeight(); ret pt(r.x + (r.w-tw)/2, r.y + (r.h-th)/2 + fm.getAscent()); }