/** Makes the specified glyphs fixed width. This can be useful to make the numbers in a font fixed width. Eg, when horizontally * centering a score or loading percentage text, it will not jump around as different numbers are shown. */ public void setFixedWidthGlyphs (CharSequence glyphs) { BitmapFontData data = this.data; int maxAdvance = 0; for (int index = 0, end = glyphs.length(); index < end; index++) { Glyph g = data.getGlyph(glyphs.charAt(index)); if (g != null && g.xadvance > maxAdvance) maxAdvance = g.xadvance; } for (int index = 0, end = glyphs.length(); index < end; index++) { Glyph g = data.getGlyph(glyphs.charAt(index)); if (g == null) continue; g.xoffset += Math.round((maxAdvance - g.xadvance) / 2); g.xadvance = maxAdvance; g.kerning = null; g.fixedWidth = true; } }
/** Makes the specified glyphs fixed width. This can be useful to make the numbers in a font fixed width. Eg, when horizontally * centering a score or loading percentage text, it will not jump around as different numbers are shown. */ public void setFixedWidthGlyphs (CharSequence glyphs) { BitmapFontData data = this.data; int maxAdvance = 0; for (int index = 0, end = glyphs.length(); index < end; index++) { Glyph g = data.getGlyph(glyphs.charAt(index)); if (g != null && g.xadvance > maxAdvance) maxAdvance = g.xadvance; } for (int index = 0, end = glyphs.length(); index < end; index++) { Glyph g = data.getGlyph(glyphs.charAt(index)); if (g == null) continue; g.xoffset += Math.round((maxAdvance - g.xadvance) / 2); g.xadvance = maxAdvance; g.kerning = null; g.fixedWidth = true; } }
int second = Integer.parseInt(tokens.nextToken()); if (first < 0 || first > Character.MAX_VALUE || second < 0 || second > Character.MAX_VALUE) continue; Glyph glyph = getGlyph((char)first); tokens.nextToken(); int amount = Integer.parseInt(tokens.nextToken()); Glyph spaceGlyph = getGlyph(' '); if (spaceGlyph == null) { spaceGlyph = new Glyph(); spaceGlyph.id = (int)' '; Glyph xadvanceGlyph = getGlyph('l'); if (xadvanceGlyph == null) xadvanceGlyph = getFirstGlyph(); spaceGlyph.xadvance = xadvanceGlyph.xadvance; xGlyph = getGlyph(xChar); if (xGlyph != null) break; capGlyph = getGlyph(capChar); if (capGlyph != null) break;
public void setRenderType (RenderType renderType) { this.renderType = renderType; if (renderType != RenderType.FreeType) { if (bitmapFont != null) { bitmapFont.dispose(); generator.dispose(); } } else { String fontFile = getFontFile(); if (fontFile != null) { generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontFile)); FreeTypeFontParameter param = new FreeTypeFontParameter(); param.size = font.getSize(); param.incremental = true; param.flip = true; param.mono = mono; param.gamma = gamma; bitmapFont = generator.generateFont(param); if (bitmapFont.getData().missingGlyph == null) bitmapFont.getData().missingGlyph = bitmapFont.getData().getGlyph('\ufffd'); cache = bitmapFont.newFontCache(); layout = new GlyphLayout(); } } }
/** Makes the specified glyphs fixed width. This can be useful to make the numbers in a font fixed width. Eg, when horizontally * centering a score or loading percentage text, it will not jump around as different numbers are shown. */ public void setFixedWidthGlyphs (CharSequence glyphs) { BitmapFontData data = this.data; int maxAdvance = 0; for (int index = 0, end = glyphs.length(); index < end; index++) { Glyph g = data.getGlyph(glyphs.charAt(index)); if (g != null && g.xadvance > maxAdvance) maxAdvance = g.xadvance; } for (int index = 0, end = glyphs.length(); index < end; index++) { Glyph g = data.getGlyph(glyphs.charAt(index)); if (g == null) continue; g.xoffset += Math.round((maxAdvance - g.xadvance) / 2); g.xadvance = maxAdvance; g.kerning = null; g.fixedWidth = true; } }
/** Returns true if the font has the glyph, or if the font has a {@link #missingGlyph}. */ public boolean hasGlyph (char ch) { if (missingGlyph != null) return true; return getGlyph(ch) != null; }
int second = Integer.parseInt(tokens.nextToken()); if (first < 0 || first > Character.MAX_VALUE || second < 0 || second > Character.MAX_VALUE) continue; Glyph glyph = getGlyph((char)first); tokens.nextToken(); int amount = Integer.parseInt(tokens.nextToken()); Glyph spaceGlyph = getGlyph(' '); if (spaceGlyph == null) { spaceGlyph = new Glyph(); spaceGlyph.id = (int)' '; Glyph xadvanceGlyph = getGlyph('l'); if (xadvanceGlyph == null) xadvanceGlyph = getFirstGlyph(); spaceGlyph.xadvance = xadvanceGlyph.xadvance; xGlyph = getGlyph(xChar); if (xGlyph != null) break; capGlyph = getGlyph(capChar); if (capGlyph != null) break;
if (unicodeFont.getRenderType() == RenderType.FreeType && unicodeFont.bitmapFont != null) { BitmapFontData data = unicodeFont.bitmapFont.getData(); BitmapFont.Glyph g = data.getGlyph((char)glyph.getCodePoint()); Pixmap fontPixmap = unicodeFont.bitmapFont.getRegions().get(g.page).getTexture().getTextureData().consumePixmap();
if (unicodeFont.getRenderType() == RenderType.FreeType && unicodeFont.bitmapFont != null) { BitmapFontData data = unicodeFont.bitmapFont.getData(); BitmapFont.Glyph g = data.getGlyph((char)glyph.getCodePoint()); Pixmap fontPixmap = unicodeFont.bitmapFont.getRegions().get(g.page).getTexture().getTextureData().consumePixmap();
skin.getFont("default-font").getData().getGlyph('B').setKerning('B', -5);
BitmapFont.Glyph g = unicodeFont.bitmapFont.getData().getGlyph((char)codePoint); if (g == null) isMissing = true;
BitmapFont.Glyph g = unicodeFont.bitmapFont.getData().getGlyph((char)codePoint); if (g == null) isMissing = true;
Glyph glyph = getGlyph(ch); if (glyph == null) { if (missingGlyph == null) continue;
Glyph glyph = getGlyph(ch); if (glyph == null) { if (missingGlyph == null) continue;
public void setRenderType (RenderType renderType) { this.renderType = renderType; if (renderType != RenderType.FreeType) { if (bitmapFont != null) { bitmapFont.dispose(); generator.dispose(); } } else { String fontFile = getFontFile(); if (fontFile != null) { generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontFile)); FreeTypeFontParameter param = new FreeTypeFontParameter(); param.size = font.getSize(); param.incremental = true; param.flip = true; param.mono = mono; param.gamma = gamma; bitmapFont = generator.generateFont(param); if (bitmapFont.getData().missingGlyph == null) bitmapFont.getData().missingGlyph = bitmapFont.getData().getGlyph('\ufffd'); cache = bitmapFont.newFontCache(); layout = new GlyphLayout(); } } }
public void setRenderType (RenderType renderType) { this.renderType = renderType; if (renderType != RenderType.FreeType) { if (bitmapFont != null) { bitmapFont.dispose(); generator.dispose(); } } else { String fontFile = getFontFile(); if (fontFile != null) { generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontFile)); FreeTypeFontParameter param = new FreeTypeFontParameter(); param.size = font.getSize(); param.incremental = true; param.flip = true; param.mono = mono; param.gamma = gamma; bitmapFont = generator.generateFont(param); if (bitmapFont.getData().missingGlyph == null) bitmapFont.getData().missingGlyph = bitmapFont.getData().getGlyph('\ufffd'); cache = bitmapFont.newFontCache(); layout = new GlyphLayout(); } } }
@Override public Glyph getGlyph (char ch) { Glyph glyph = super.getGlyph(ch); if (glyph == null && generator != null) { generator.setPixelSizes(0, parameter.size); float baseline = ((flipped ? -ascent : ascent) + capHeight) / scaleY; glyph = generator.createGlyph(ch, this, parameter, stroker, baseline, packer); if (glyph == null) return missingGlyph; setGlyphRegion(glyph, regions.get(glyph.page)); setGlyph(ch, glyph); glyphs.add(glyph); dirty = true; Face face = generator.face; if (parameter.kerning) { int glyphIndex = face.getCharIndex(ch); for (int i = 0, n = glyphs.size; i < n; i++) { Glyph other = glyphs.get(i); int otherIndex = face.getCharIndex(other.id); int kerning = face.getKerning(glyphIndex, otherIndex, 0); if (kerning != 0) glyph.setKerning(other.id, FreeType.toInt(kerning)); kerning = face.getKerning(otherIndex, glyphIndex, 0); if (kerning != 0) other.setKerning(ch, FreeType.toInt(kerning)); } } } return glyph; }
@Override public Glyph getGlyph (char ch) { Glyph glyph = super.getGlyph(ch); if (glyph == null && generator != null) { generator.setPixelSizes(0, parameter.size); float baseline = ((flipped ? -ascent : ascent) + capHeight) / scaleY; glyph = generator.createGlyph(ch, this, parameter, stroker, baseline, packer); if (glyph == null) return missingGlyph; setGlyphRegion(glyph, regions.get(glyph.page)); setGlyph(ch, glyph); glyphs.add(glyph); dirty = true; Face face = generator.face; if (parameter.kerning) { int glyphIndex = face.getCharIndex(ch); for (int i = 0, n = glyphs.size; i < n; i++) { Glyph other = glyphs.get(i); int otherIndex = face.getCharIndex(other.id); int kerning = face.getKerning(glyphIndex, otherIndex, 0); if (kerning != 0) glyph.setKerning(other.id, FreeType.toInt(kerning)); kerning = face.getKerning(otherIndex, glyphIndex, 0); if (kerning != 0) other.setKerning(ch, FreeType.toInt(kerning)); } } } return glyph; }
/** Returns true if the font has the glyph, or if the font has a {@link #missingGlyph}. */ public boolean hasGlyph (char ch) { if (missingGlyph != null) return true; return getGlyph(ch) != null; }
/** Returns true if the font has the glyph, or if the font has a {@link #missingGlyph}. */ public boolean hasGlyph (char ch) { if (missingGlyph != null) return true; return getGlyph(ch) != null; }