MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / stringWidth

Method stringWidth

CodenameOne/src/com/codename1/ui/Font.java:637–648  ·  view source on GitHub ↗
(String str)

Source from the content-addressed store, hash-verified

635 ///
636 /// the width of the given string in this font instance
637 public int stringWidth(String str) {
638 // this happens often for icons without text and can cost a bit more in the native platform
639 if (str == null || str.length() == 0) {
640 return 0;
641 }
642 // Its common to use a space character to create a label that takes up space but the value
643 // of string width in this case becomes less important
644 if (" ".equals(str)) {
645 return 5;
646 }
647 return Display.impl.stringWidth(font, str);
648 }
649
650 /// Return the width of the specific character when rendered alone
651 ///

Callers 15

drawArrowMethod · 0.95
drawAttributionMethod · 0.95
paintLoadingTextMethod · 0.95
drawMarkerMethod · 0.95
placeMethod · 0.95
drawImageMethod · 0.95
pointerReleasedMethod · 0.95
initRowStringMethod · 0.95
paintMethod · 0.95
calculateTextAreaSpanMethod · 0.95
drawTextAreaMethod · 0.95
getPreferredSizeMethod · 0.95

Calls 2

lengthMethod · 0.65
equalsMethod · 0.65

Tested by 5

makeDigitFrameMethod · 0.76
paintMethod · 0.76
loadTextImageMethod · 0.76
loadTextImageMethod · 0.76