public Face newMemoryFace(ByteBuffer buffer, int faceIndex) { long face = newMemoryFace(address, buffer, buffer.remaining(), faceIndex); if(face == 0) { if (BufferUtils.isUnsafeByteBuffer(buffer)) BufferUtils.disposeUnsafeByteBuffer(buffer); throw new GdxRuntimeException("Couldn't load font, FreeType error code: " + getLastErrorCode()); } else { fontData.put(face, buffer); return new Face(face, this); } }
SizeMetrics fontMetrics = face.getSize().getMetrics(); data.flipped = parameter.flip; data.ascent = FreeType.toInt(fontMetrics.getAscender()); for (int c = 32; c < (32 + face.getNumGlyphs()); c++) { if (loadChar(c, flags)) { int lh = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); data.lineHeight = (lh > data.lineHeight) ? lh : data.lineHeight; data.spaceXadvance = FreeType.toInt(face.getGlyph().getMetrics().getHoriAdvance()); } else { data.spaceXadvance = face.getMaxAdvanceWidth(); // Possibly very wrong. data.xHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); break; data.capHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()) + Math.abs(parameter.shadowOffsetY); break; int height = loadChar(c, flags) ? FreeType.toInt(face.getGlyph().getMetrics().getHeight()) : 0; heights[i] = height; parameter.kerning &= face.hasKerning(); if (parameter.kerning) { for (int i = 0; i < charactersLength; i++) { Glyph first = data.getGlyph(firstChar); if (first == null) continue; int firstIndex = face.getCharIndex(firstChar);
SizeMetrics fontMetrics = face.getSize().getMetrics(); data.flipped = parameter.flip; data.ascent = FreeType.toInt(fontMetrics.getAscender()); for (int c = 32; c < (32 + face.getNumGlyphs()); c++) { if (loadChar(c, flags)) { int lh = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); data.lineHeight = (lh > data.lineHeight) ? lh : data.lineHeight; data.spaceXadvance = FreeType.toInt(face.getGlyph().getMetrics().getHoriAdvance()); } else { data.spaceXadvance = face.getMaxAdvanceWidth(); // Possibly very wrong. data.xHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); break; data.capHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()) + Math.abs(parameter.shadowOffsetY); break; int height = loadChar(c, flags) ? FreeType.toInt(face.getGlyph().getMetrics().getHeight()) : 0; heights[i] = height; parameter.kerning &= face.hasKerning(); if (parameter.kerning) { for (int i = 0; i < charactersLength; i++) { Glyph first = data.getGlyph(firstChar); if (first == null) continue; int firstIndex = face.getCharIndex(firstChar);
PixmapPacker packer) { boolean missing = face.getCharIndex(c) == 0 && c != 0; if (missing) return null; GlyphSlot slot = face.getGlyph(); FreeType.Glyph mainGlyph = slot.getGlyph(); try {
SizeMetrics fontMetrics = face.getSize().getMetrics(); if (!face.loadChar(xChar, FreeType.FT_LOAD_DEFAULT)) continue; data.xHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); break; throw new GdxRuntimeException("No x-height character found in font"); for (char capChar : data.capChars) { if (!face.loadChar(capChar, FreeType.FT_LOAD_DEFAULT)) continue; data.capHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); break;
setPixelSizes(0, size); SizeMetrics fontMetrics = face.getSize().getMetrics(); int baseline = FreeType.toInt(fontMetrics.getAscender()); if (face.getCharIndex(c) == 0) { return null; GlyphSlot slot = face.getGlyph();
@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; }
private static native int getKerning(long face, int leftGlyph, int rightGlyph, int kernMode); /* FT_Vector kerning;
private static native int getAscender(long face); /* return ((FT_Face)face)->ascender;
private static native int getDescender(long face); /* return ((FT_Face)face)->descender;
private static native int getCharIndex(long face, int charCode); /* return FT_Get_Char_Index((FT_Face)face, charCode);
private static native int getHeight(long face); /* return ((FT_Face)face)->height;
private static native long getGlyph(long face); /* return (jlong)((FT_Face)face)->glyph;
private static native int getFaceFlags(long face); /* return ((FT_Face)face)->face_flags;
private boolean checkForBitmapFont () { int faceFlags = face.getFaceFlags(); if (((faceFlags & FreeType.FT_FACE_FLAG_FIXED_SIZES) == FreeType.FT_FACE_FLAG_FIXED_SIZES) && ((faceFlags & FreeType.FT_FACE_FLAG_HORIZONTAL) == FreeType.FT_FACE_FLAG_HORIZONTAL)) { if (loadChar(32)) { GlyphSlot slot = face.getGlyph(); if (slot.getFormat() == 1651078259) { bitmapped = true; } } } return bitmapped; }
@Override public void dispose() { doneFace(address); ByteBuffer buffer = library.fontData.get(address); if(buffer != null) { library.fontData.remove(address); if (BufferUtils.isUnsafeByteBuffer(buffer)) BufferUtils.disposeUnsafeByteBuffer(buffer); } }
public Face newMemoryFace(ByteBuffer buffer, int faceIndex) { long face = newMemoryFace(address, buffer, buffer.remaining(), faceIndex); if(face == 0) { if (BufferUtils.isUnsafeByteBuffer(buffer)) BufferUtils.disposeUnsafeByteBuffer(buffer); throw new GdxRuntimeException("Couldn't load font, FreeType error code: " + getLastErrorCode()); } else { fontData.put(face, buffer); return new Face(face, this); } }
/** Cleans up all resources of the generator. Call this if you no longer use the generator. */ @Override public void dispose () { face.dispose(); library.dispose(); }
SizeMetrics fontMetrics = face.getSize().getMetrics(); data.flipped = parameter.flip; data.ascent = FreeType.toInt(fontMetrics.getAscender()); for (int c = 32; c < (32 + face.getNumGlyphs()); c++) { if (loadChar(c, flags)) { int lh = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); data.lineHeight = (lh > data.lineHeight) ? lh : data.lineHeight; data.spaceXadvance = FreeType.toInt(face.getGlyph().getMetrics().getHoriAdvance()); } else { data.spaceXadvance = face.getMaxAdvanceWidth(); // Possibly very wrong. data.xHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()); break; data.capHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight()) + Math.abs(parameter.shadowOffsetY); break; int height = loadChar(c, flags) ? FreeType.toInt(face.getGlyph().getMetrics().getHeight()) : 0; heights[i] = height; parameter.kerning &= face.hasKerning(); if (parameter.kerning) { for (int i = 0; i < charactersLength; i++) { Glyph first = data.getGlyph(firstChar); if (first == null) continue; int firstIndex = face.getCharIndex(firstChar);
PixmapPacker packer) { boolean missing = face.getCharIndex(c) == 0 && c != 0; if (missing) return null; GlyphSlot slot = face.getGlyph(); FreeType.Glyph mainGlyph = slot.getGlyph(); try {