Glyph missingGlyph = createGlyph('\0', data, parameter, stroker, baseLine, packer); if (missingGlyph != null && missingGlyph.width != 0 && missingGlyph.height != 0) { data.setGlyph('\0', missingGlyph); data.missingGlyph = missingGlyph; if (incremental) data.glyphs.add(missingGlyph); if (data.getGlyph(c) == null) { Glyph glyph = createGlyph(c, data, parameter, stroker, baseLine, packer); if (glyph != null) { data.setGlyph(c, glyph); if (incremental) data.glyphs.add(glyph); for (int i = 0; i < charactersLength; i++) { char firstChar = characters[i]; Glyph first = data.getGlyph(firstChar); if (first == null) continue; int firstIndex = face.getCharIndex(firstChar); for (int ii = i; ii < charactersLength; ii++) { char secondChar = characters[ii]; Glyph second = data.getGlyph(secondChar); if (second == null) continue; int secondIndex = face.getCharIndex(secondChar); Glyph spaceGlyph = data.getGlyph(' '); if (spaceGlyph == null) { spaceGlyph = new Glyph(); spaceGlyph.xadvance = (int)data.spaceXadvance + parameter.spaceX; spaceGlyph.id = (int)' '; data.setGlyph(' ', spaceGlyph);
if (data.getGlyph(c) == null || data.getGlyph(c) == data.missingGlyph) { Glyph glyph = createGlyph(c, data, parameter, stroker, baseLine, packer); if (glyph != null) { data.setGlyph(c, glyph); if (incremental) data.glyphs.add(glyph); data.addGenerator(this); data.parameter = parameter; data.stroker = stroker; for (int i = 0; i < charactersLength; i++) { char firstChar = characters[i]; Glyph first = data.getGlyph(firstChar); if (first == null) continue; int firstIndex = face.getCharIndex(firstChar); for (int ii = i; ii < charactersLength; ii++) { char secondChar = characters[ii]; Glyph second = data.getGlyph(secondChar); if (second == null) continue; int secondIndex = face.getCharIndex(secondChar); Glyph spaceGlyph = data.getGlyph(' '); if (spaceGlyph == null) { spaceGlyph = new Glyph(); spaceGlyph.xadvance = (int)data.spaceXadvance + parameter.spaceX; spaceGlyph.id = (int)' '; data.setGlyph(' ', spaceGlyph);
ftFontDataDefault.addGenerator(cjkFontGenerator); FreeTypeFontGenerator.FreeTypeBitmapFontData ftFontDataSmall = (FreeTypeFontGenerator.FreeTypeBitmapFontData) fontSmall.getData(); ftFontDataSmall.addGenerator(cjkFontGenerator); FreeTypeFontGenerator.FreeTypeBitmapFontData ftFontDataBig = (FreeTypeFontGenerator.FreeTypeBitmapFontData) fontBig.getData(); ftFontDataBig.addGenerator(cjkFontGenerator);
@Override public Glyph getGlyph (char ch) { Glyph glyph = super.getGlyph(ch); if (glyph != null && glyph != missingGlyph) return glyph; for (int i = 0; i < generators.size; i++) { FreeTypeFontGenerator generator = generators.get(i); generator.setPixelSizes(0, parameter.size); float baseline = ((flipped ? -ascent : ascent) + capHeight) / scaleY; glyph = generator.createGlyph(ch, this, parameter, stroker, baseline, packer); if (glyph == null) continue; 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 j = 0, n = glyphs.size; j < n; j++) { Glyph other = glyphs.get(j); 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; } return missingGlyph; }
protected Glyph generateGlyph(char ch) { GlyphAndBitmap gab = generator.generateGlyphAndBitmap(ch, fontSize, false); if (gab == null || gab.bitmap == null) return null; //modified by STH99 on 2017-6-10 Pixmap map = gab.bitmap.getPixmap(Format.RGBA8888, Color.WHITE, 1.0f); TextureRegion rg = null; if(Game.setting.newTextRender){ if(lazyBitmapFontTexture == null) lazyBitmapFontTexture = new LazyBitmapFontTexture(); rg = lazyBitmapFontTexture.draw(map); if(rg == null) rg = (lazyBitmapFontTexture = new LazyBitmapFontTexture()).draw(map); map.dispose(); font.getRegions().add(rg); }else{ rg = new TextureRegion(new Texture(map)); rg.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); map.dispose(); font.getRegions().add(rg); } gab.glyph.page = page++; super.setGlyph(ch, gab.glyph); setGlyphRegion(gab.glyph, rg); return gab.glyph; }
public FreeTypeBitmapFontData generateData (FreeTypeFontParameter parameter) { return generateData(parameter, new FreeTypeBitmapFontData()); }
public BitmapFont generateFont (FreeTypeFontParameter parameter) { return generateFont(parameter, new FreeTypeBitmapFontData()); }
public Glyph getGlyph(char ch) { Glyph glyph = super.getGlyph(ch); if (glyph == null && ch != 0){ glyph = generateGlyph(ch); } return glyph; }
@Override public void dispose() { setOwnsTexture(true); super.dispose(); data.dispose(); }
Glyph missingGlyph = createGlyph('\0', data, parameter, stroker, baseLine, packer); if (missingGlyph != null && missingGlyph.width != 0 && missingGlyph.height != 0) { data.setGlyph('\0', missingGlyph); data.missingGlyph = missingGlyph; if (incremental) data.glyphs.add(missingGlyph); if (data.getGlyph(c) == null) { Glyph glyph = createGlyph(c, data, parameter, stroker, baseLine, packer); if (glyph != null) { data.setGlyph(c, glyph); if (incremental) data.glyphs.add(glyph); for (int i = 0; i < charactersLength; i++) { char firstChar = characters[i]; Glyph first = data.getGlyph(firstChar); if (first == null) continue; int firstIndex = face.getCharIndex(firstChar); for (int ii = i; ii < charactersLength; ii++) { char secondChar = characters[ii]; Glyph second = data.getGlyph(secondChar); if (second == null) continue; int secondIndex = face.getCharIndex(secondChar); Glyph spaceGlyph = data.getGlyph(' '); if (spaceGlyph == null) { spaceGlyph = new Glyph(); spaceGlyph.xadvance = (int)data.spaceXadvance + parameter.spaceX; spaceGlyph.id = (int)' '; data.setGlyph(' ', spaceGlyph);
@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; }
public FreeTypeBitmapFontData generateData (FreeTypeFontParameter parameter) { return generateData(parameter, new FreeTypeBitmapFontData()); }
public BitmapFont generateFont (FreeTypeFontParameter parameter) { return generateFont(parameter, new FreeTypeBitmapFontData()); }
public FreeTypeBitmapFontData generateData (FreeTypeFontParameter parameter) { return generateData(parameter, new FreeTypeBitmapFontData()); }
public BitmapFont generateFont (FreeTypeFontParameter parameter) { return generateFont(parameter, new FreeTypeBitmapFontData()); }