/** * Implementation of returning the text width of * the chars [start, stop) in the buffer. * Unlike the previous version that was inside PFont, this will * return the size not of a 1 pixel font, but the actual current size. */ protected float textWidthImpl(char buffer[], int start, int stop) { float wide = 0; for (int i = start; i < stop; i++) { // could add kerning here, but it just ain't implemented wide += textFont.width(buffer[i]) * textSize; } return wide; }
/** * Implementation of returning the text width of * the chars [start, stop) in the buffer. * Unlike the previous version that was inside PFont, this will * return the size not of a 1 pixel font, but the actual current size. */ protected float textWidthImpl(char buffer[], int start, int stop) { float wide = 0; for (int i = start; i < stop; i++) { // could add kerning here, but it just ain't implemented wide += textFont.width(buffer[i]) * textSize; } return wide; }
/** * Width of this character for a font of size 1. */ public float width(char c) { if (c == 32) return width('i'); int cc = index(c); if (cc == -1) return 0; return ((float) glyphs[cc].setWidth / (float) size); }
/** * Width of this character for a font of size 1. */ public float width(char c) { if (c == 32) return width('i'); int cc = index(c); if (cc == -1) return 0; return ((float) glyphs[cc].setWidth / (float) size); }