// Class for displaying text in my partial uppercase-only fonts class CapsFont { PImage[] images; int w, h; PImage bigImage; boolean inited; void init() { int imageCount = 42; images = new PImage[imageCount]; w = bigImage.width / imageCount; h = bigImage.height; println("w = " + w + " h = " + h); for (int i = 0; i < imageCount; i++) { images[i] = bigImage.get(w*i,0,w,h); } inited = true; } CapsFont(String imageFile) { bigImage = loadImage(imageFile); inited = false; } CapsFont(CapsFont other, color toReplace, color replacement) { bigImage = other.bigImage.get(0,0,other.bigImage.width,other.bigImage.height); inited = false; for (int i = 0; i < bigImage.width; i++) { for (int j = 0; j < bigImage.height; j++) { if (bigImage.get(i,j) == toReplace) { bigImage.set(i,j,replacement); } } } init(); } void Draw(float xpos, float ypos, int c, int scaling) { if (!inited) init(); image(images[c], xpos, ypos, w*scaling, h*scaling); } void Draw(float xpos, float ypos, char c, int scaling) { if (c == '.') Draw(xpos,ypos,40,scaling); else if (c == '/') Draw(xpos,ypos,41,scaling); else if (c == '?') Draw(xpos,ypos,26,scaling); else if (c == ':') Draw(xpos,ypos,37,scaling); else if (c == '!') Draw(xpos,ypos,38,scaling); else if (c == '\'') Draw(xpos,ypos,39,scaling); else if (int(c) >= int('0') && int(c) <= int('9')) { Draw(xpos, ypos, 27+int(c)-int('0'), scaling); } else { int i = int(c); if (i > 65+26) i -= 32; i -= 65; if (i >= 0 && i < 26) Draw(xpos, ypos, i, scaling); } } void DrawCentered(float xpos, float ypos, String words, int scaling) { xpos -= w * scaling * words.length() / 2.0; Draw(xpos, ypos, words, scaling); } void Draw(float xpos, float ypos, String words, int scaling) { int len = words.length(); for (int i = 0; i < len; i++) { Draw(xpos + i * w * scaling, ypos, words.charAt(i), scaling); } } }