int stringWidth(String text) { int width = 0; for (int i = 0; i < text.length; i++) { width += charWidth(text.codeUnitAt(i)); } return width; }