protected PImage getTintedGlyphImage(PFont.Glyph glyph, int tintColor) { if (textFontInfo.tintCache == null) { textFontInfo.tintCache = new LinkedHashMap<Integer, PImage[]>(16, 0.75f, true) { @Override protected boolean removeEldestEntry(Map.Entry<Integer, PImage[]> eldest) { return size() > FontInfo.MAX_CACHED_COLORS_PER_FONT; } }; } PImage[] tintedGlyphs = textFontInfo.tintCache.get(tintColor); int index = glyph.index; if (tintedGlyphs == null || tintedGlyphs.length <= index) { PImage[] newArray = new PImage[textFont.getGlyphCount()]; if (tintedGlyphs != null) { System.arraycopy(tintedGlyphs, 0, newArray, 0, tintedGlyphs.length); } tintedGlyphs = newArray; textFontInfo.tintCache.put(tintColor, tintedGlyphs); } PImage tintedGlyph = tintedGlyphs[index]; if (tintedGlyph == null) { tintedGlyph = glyph.image.copy(); tintedGlyphs[index] = tintedGlyph; } return tintedGlyph; }
public void addAllGlyphsToTexture(PGraphicsOpenGL pg, PFont font) { // loop over current glyphs. for (int i = 0; i < font.getGlyphCount(); i++) { addToTexture(pg, i, font.getGlyph(i)); } }
public void addAllGlyphsToTexture(PGraphicsOpenGL pg, PFont font) { // loop over current glyphs. for (int i = 0; i < font.getGlyphCount(); i++) { addToTexture(pg, i, font.getGlyph(i)); } }
protected void initTexture(PGraphicsOpenGL pg, PFont font) { currentTex = -1; lastTex = -1; int spow = PGL.nextPowerOfTwo(font.getSize()); minSize = PApplet.min(PGraphicsOpenGL.maxTextureSize, PApplet.max(PGL.MIN_FONT_TEX_SIZE, spow)); maxSize = PApplet.min(PGraphicsOpenGL.maxTextureSize, PApplet.max(PGL.MAX_FONT_TEX_SIZE, 2 * spow)); if (maxSize < spow) { PGraphics.showWarning("The font size is too large to be properly " + "displayed with OpenGL"); } addTexture(pg); offsetX = 0; offsetY = 0; lineHeight = 0; texinfoMap = new HashMap<PFont.Glyph, TextureInfo>(); glyphTexinfos = new TextureInfo[font.getGlyphCount()]; addAllGlyphsToTexture(pg, font); }
protected void initTexture(PGraphicsOpenGL pg, PFont font) { lastTex = -1; int spow = PGL.nextPowerOfTwo(font.getSize()); minSize = PApplet.min(PGraphicsOpenGL.maxTextureSize, PApplet.max(PGL.MIN_FONT_TEX_SIZE, spow)); maxSize = PApplet.min(PGraphicsOpenGL.maxTextureSize, PApplet.max(PGL.MAX_FONT_TEX_SIZE, 2 * spow)); if (maxSize < spow) { PGraphics.showWarning("The font size is too large to be properly " + "displayed with OpenGL"); } addTexture(pg); offsetX = 0; offsetY = 0; lineHeight = 0; texinfoMap = new HashMap<PFont.Glyph, TextureInfo>(); glyphTexinfos = new TextureInfo[font.getGlyphCount()]; addAllGlyphsToTexture(pg, font); }