当前位置: 首页>>代码示例>>Java>>正文


Java GlyphRun类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun的典型用法代码示例。如果您正苦于以下问题:Java GlyphRun类的具体用法?Java GlyphRun怎么用?Java GlyphRun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GlyphRun类属于com.badlogic.gdx.graphics.g2d.GlyphLayout包,在下文中一共展示了GlyphRun类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addMissingGlyphs

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
/** 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++;
			glyphCount++;
			glyphLeft--;
			glyphs.add(glyphCache.get(cachedGlyphCharIndex));
		}
	}
}
 
开发者ID:rafaskb,项目名称:typing-label,代码行数:41,代码来源:TypingLabel.java

示例2: getGlyphs

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
@Override
public void getGlyphs (GlyphRun run, CharSequence str, int start, int end, boolean tightBounds) {
	if (packer != null) packer.setPackToTexture(true); // All glyphs added after this are packed directly to the texture.
	super.getGlyphs(run, str, start, end, tightBounds);
	if (dirty) {
		dirty = false;
		packer.updateTextureRegions(regions, parameter.minFilter, parameter.magFilter, parameter.genMipMaps);
	}
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:10,代码来源:FreeTypeFontGenerator.java

示例3: getGlyphs

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
public void getGlyphs (GlyphRun run, CharSequence str, int start, int end, boolean tightBounds) {
	if (packer != null) packer.setPackToTexture(true); // All glyphs added after this are packed directly to the texture.
	super.getGlyphs(run, str, start, end, tightBounds);
	if (dirty) {
		dirty = false;
		packer.updateTextureRegions(regions, parameter.minFilter, parameter.magFilter, parameter.genMipMaps);
	}
}
 
开发者ID:intrigus,项目名称:gdx-freetype-gwt,代码行数:9,代码来源:FreeTypeFontGenerator.java

示例4: drawUnderline

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
private void drawUnderline(Batch batch, GlyphLayout glyphLayout, float dx, float dy) {
    if (!style.isUnderlined()) {
        // Not underlined -> abort
        return;
    }

    float thickness = underlineMetrics.getUnderlineThickness();

    float underlineDy = underlineMetrics.getUnderlinePosition() - font.getCapHeight();
    if (ydown) {
        underlineDy = -underlineDy;
    }
    underlineDy -= font.getAscent();

    float x = getX() + dx;
    float y = getY() + dy + underlineDy - thickness / 2;

    for (GlyphRun run : glyphLayout.runs) {
        float runX = run.x + run.xAdvances.get(0);

        float runWidth = 0f;
        for (int n = 0; n < run.glyphs.size; n++) {
            runWidth += run.xAdvances.get(1 + n); // Glyph offsets start at index 1
        }

        batch.draw(getBlankTexture(), x + runX, y + run.y, runWidth, thickness);
    }
}
 
开发者ID:anonl,项目名称:gdx-styledtext,代码行数:29,代码来源:GdxTextElement.java

示例5: getGlyph

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
private static Glyph getGlyph(GlyphLayout layout, int index) {
    int offset = 0;
    for (GlyphRun run : layout.runs) {
        if (index < offset) {
            break;
        }
        if (index - offset < run.glyphs.size) {
            return run.glyphs.get(index - offset);
        }
        offset += run.glyphs.size;
    }
    throw new ArrayIndexOutOfBoundsException(index);
}
 
开发者ID:anonl,项目名称:gdx-styledtext,代码行数:14,代码来源:GdxTextElement.java

示例6: getGlyphCount

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
private static int getGlyphCount(GlyphLayout layout) {
    int count = 0;
    for (GlyphRun run : layout.runs) {
        count += run.glyphs.size;
    }
    return count;
}
 
开发者ID:anonl,项目名称:gdx-styledtext,代码行数:8,代码来源:GdxTextElement.java

示例7: addToCache

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
private void addToCache (GlyphLayout layout, float x, float y) {
//		y += 5f * font.getScaleY();
		// Check if the number of font pages has changed.
		int pageCount = font.regions.size;
		if (pageVertices.length < pageCount) {
			float[][] newPageVertices = new float[pageCount][];
			System.arraycopy(pageVertices, 0, newPageVertices, 0, pageVertices.length);
			pageVertices = newPageVertices;

			int[] newIdx = new int[pageCount];
			System.arraycopy(idx, 0, newIdx, 0, idx.length);
			idx = newIdx;

			IntArray[] newPageGlyphIndices = new IntArray[pageCount];
			int pageGlyphIndicesLength = 0;
			if (pageGlyphIndices != null) {
				pageGlyphIndicesLength = pageGlyphIndices.length;
				System.arraycopy(pageGlyphIndices, 0, newPageGlyphIndices, 0, pageGlyphIndices.length);
			}
			for (int i = pageGlyphIndicesLength; i < pageCount; i++)
				newPageGlyphIndices[i] = new IntArray();
			pageGlyphIndices = newPageGlyphIndices;

			tempGlyphCount = new int[pageCount];
		}

		layouts.add(layout);
		requireGlyphs(layout);
		for (int i = 0, n = layout.runs.size; i < n; i++) {
			GlyphRun run = layout.runs.get(i);
			Array<Glyph> glyphs = run.glyphs;
			FloatArray xAdvances = run.xAdvances;
			float color = run.color.toFloatBits();
			float gx = x + run.x, gy = y + run.y;
			for (int ii = 0, nn = glyphs.size; ii < nn; ii++) {
				Glyph glyph = glyphs.get(ii);
				gx += xAdvances.get(ii);
				addGlyph(glyph, gx, gy, color);
			}
		}

		currentTint = whiteTint; // Cached glyphs have changed, reset the current tint.
	}
 
开发者ID:Osaris31,项目名称:exterminate,代码行数:44,代码来源:BitmapFontCache.java

示例8: draw

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
public void draw(Batch batch, float dx, float dy, float visibleGlyphs) {
    if (visibleGlyphs == 0 || glyphLayout.runs.size == 0) {
        return; // Nothing to draw
    }

    applyScale();
    {
        if (visibleGlyphs < 0f || visibleGlyphs >= glyphCount) {
            // Text fully visible
            drawUnderline(batch, glyphLayout, dx, dy);
            drawLayout(batch, glyphLayout, dx, dy);
        } else {
            // Text partially visible
            int visible = (int)visibleGlyphs;

            GlyphRun run = glyphLayout.runs.first();
            Array<Glyph> glyphs = run.glyphs;
            FloatArray xAdvances = run.xAdvances;

            Object[] oldGlyphs = glyphs.items;
            float[] oldXAdvances = xAdvances.items;
            int oldSize = glyphs.size;
            if (isRightToLeft()) {
                int invisible = oldSize - visible;
                for (int n = 0; n < invisible; n++) {
                    dx += xAdvances.get(n);
                }

                setGlyphs(glyphs, Arrays.copyOfRange(oldGlyphs, invisible, oldSize));
                xAdvances.items = Arrays.copyOfRange(oldXAdvances, invisible, xAdvances.size);
            }
            glyphs.size = visible;

            drawUnderline(batch, glyphLayout, dx, dy);
            drawLayout(batch, glyphLayout, dx, dy);

            if (isRightToLeft()) {
                setGlyphs(glyphs, oldGlyphs);
                xAdvances.items = oldXAdvances;
            }
            glyphs.size = oldSize;
        }
    }
    resetScale();
}
 
开发者ID:anonl,项目名称:gdx-styledtext,代码行数:46,代码来源:GdxTextElement.java

示例9: updateDisplayText

import com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun; //导入依赖的package包/类
void updateDisplayText() {
    BitmapFont font = style.font;
    BitmapFontData data = font.getData();
    String text = this.text;
    int textLength = text.length();

    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < textLength; i++) {
        char c = text.charAt(i);
        buffer.append(data.hasGlyph(c) ? c : ' ');
    }
    String newDisplayText = buffer.toString();

    if (passwordMode && data.hasGlyph(passwordCharacter)) {
        if (passwordBuffer == null)
            passwordBuffer = new StringBuilder(newDisplayText.length());
        if (passwordBuffer.length() > textLength)
            passwordBuffer.setLength(textLength);
        else {
            for (int i = passwordBuffer.length(); i < textLength; i++)
                passwordBuffer.append(passwordCharacter);
        }
        displayText = passwordBuffer;
    } else
        displayText = newDisplayText;

    layout.setText(font, displayText);
    glyphPositions.clear();
    float x = 0;
    if (layout.runs.size > 0) {
        GlyphRun run = layout.runs.first();
        FloatArray xAdvances = run.xAdvances;
        fontOffset = xAdvances.first();
        for (int i = 1, n = xAdvances.size; i < n; i++) {
            glyphPositions.add(x);
            x += xAdvances.get(i);
        }
    } else
        fontOffset = 0;
    glyphPositions.add(x);

    if (selectionStart > newDisplayText.length())
        selectionStart = textLength;
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:45,代码来源:TextField.java


注:本文中的com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。