Java源码示例:com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun

示例1
@Override
public void getGlyphs (GlyphRun run, CharSequence str, int start, int end, Glyph lastGlyph) {
	if (packer != null) packer.setPackToTexture(true); // All glyphs added after this are packed directly to the texture.
	super.getGlyphs(run, str, start, end, lastGlyph);
	if (dirty) {
		dirty = false;
		packer.updateTextureRegions(regions, parameter.minFilter, parameter.magFilter, parameter.genMipMaps);
	}
}
 
示例2
/** Adds cached glyphs to the active BitmapFontCache as the char index progresses. */
private void addMissingGlyphs() {
    // Add additional glyphs to layout array, if any
    int glyphLeft = glyphCharIndex - cachedGlyphCharIndex;
    if(glyphLeft < 1) return;

    // Get runs
    GlyphLayout layout = super.getGlyphLayout();
    Array<GlyphRun> runs = layout.runs;

    // Iterate through GlyphRuns to find the next glyph spot
    int glyphCount = 0;
    for(int runIndex = 0; runIndex < glyphRunCapacities.size; runIndex++) {
        int runCapacity = glyphRunCapacities.get(runIndex);
        if((glyphCount + runCapacity) < cachedGlyphCharIndex) {
            glyphCount += runCapacity;
            continue;
        }

        // Get run and increase glyphCount up to its current size
        Array<Glyph> glyphs = runs.get(runIndex).glyphs;
        glyphCount += glyphs.size;

        // Next glyphs go here
        while(glyphLeft > 0) {

            // Skip run if this one is full
            int runSize = glyphs.size;
            if(runCapacity == runSize) {
                break;
            }

            // Put new glyph to this run
            cachedGlyphCharIndex++;
            TypingGlyph glyph = glyphCache.get(cachedGlyphCharIndex);
            glyphs.add(glyph);

            // Cache glyph's vertex index
            glyph.internalIndex = glyphCount;

            // Advance glyph count
            glyphCount++;
            glyphLeft--;
        }
    }
}