@Override public boolean additionFailed(final Rect cause, final int attemptNumber) { // Heavy hammer -- might consider doing something different packer.clear(); stringLocations.clear(); mGlyphProducer.clearAllCacheEntries(); if (DEBUG) { System.err.println( " *** Cleared all text because addition failed ***"); } if (attemptNumber == 0) { return true; } return false; }
mGlyphProducer.clearCacheEntry(unicodeToClearFromCache);
rect.h()); producer.register(this);
mGlyphProducer = new GlyphProducer(font.getNumGlyphs());
private Glyph getGlyph(final int unicodeID, final GlyphVector singleUnicodeGlyphVector, final GlyphMetrics metrics) { final int glyphCode = singleUnicodeGlyphVector.getGlyphCode(0); // Have seen huge glyph codes (65536) coming out of some fonts in some Unicode situations if (glyphCode >= glyphCache.length) { return null; } final Glyph glyph = new Glyph(unicodeID, glyphCode, metrics.getAdvance(), singleUnicodeGlyphVector, this); register(glyph); return glyph; } }
private Glyph getGlyph(final CharSequence inString, final GlyphMetrics glyphMetrics, final int index) { final char unicodeID = inString.charAt(index); if (unicodeID >= unicodes2Glyphs.length) { return null; } final int glyphID = unicodes2Glyphs[unicodeID]; if (glyphID != undefined) { return glyphCache[glyphID]; } // Must fabricate the glyph singleUnicode[0] = unicodeID; final GlyphVector gv = font.createGlyphVector(getFontRenderContext(), singleUnicode); return getGlyph(unicodeID, gv, glyphMetrics); }
public float getGlyphPixelWidth(final char unicodeID) { final Glyph glyph = getGlyph(unicodeID); if (glyph != null) { return glyph.getAdvance(); } // Have to do this the hard / uncached way singleUnicode[0] = unicodeID; if( null == fontRenderContext ) { // FIXME: Never initialized! throw new InternalError("fontRenderContext never initialized!"); } final GlyphVector gv = font.createGlyphVector(fontRenderContext, singleUnicode); return gv.getGlyphMetrics(0).getAdvance(); }
/** Returns the pixel width of the given character. */ public float getCharWidth(final char inChar) { return mGlyphProducer.getGlyphPixelWidth(inChar); }
private Glyph getGlyph(final int unicodeID) { if (unicodeID >= unicodes2Glyphs.length) { return null; } final int glyphID = unicodes2Glyphs[unicodeID]; if (glyphID != undefined) { return glyphCache[glyphID]; } singleUnicode[0] = (char) unicodeID; final GlyphVector gv = font.createGlyphVector(getFontRenderContext(), singleUnicode); return getGlyph(unicodeID, gv, gv.getGlyphMetrics(0)); }
GlyphProducer(final int fontLengthInGlyphs) { unicodes2Glyphs = new int[512]; glyphCache = new Glyph[fontLengthInGlyphs]; clearAllCacheEntries(); }
public void clearAllCacheEntries() { for (int i = 0; i < unicodes2Glyphs.length; i++) { clearCacheEntry(i); } }
private void internal_draw3D(final CharSequence str, float x, final float y, final float z, final float scaleFactor) { for (final Glyph glyph : mGlyphProducer.getGlyphs(str)) { final float advance = glyph.draw3D(x, y, z, scaleFactor); x += advance * scaleFactor; } }