com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FreeTypeFontGenerator.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #2
Source File: TypingLabel.java    From typing-label with MIT License 4 votes vote down vote up
/** 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--;
        }
    }
}