/** get the data in this map as a ByteBuffer */ public ByteBuffer getData() { int size = getLength(); ByteBuffer buf = ByteBuffer.allocate(size); // write the metrics for (int i = 0; i < leftSideBearings.length; i++) { if (i < advanceWidths.length) { buf.putShort(advanceWidths[i]); } buf.putShort(leftSideBearings[i]); } // reset the start pointer buf.flip(); return buf; }
/** * Get the outline of a character given the glyph id */ protected synchronized GeneralPath getOutline (int glyphId, float width) { // find the glyph itself GlyfTable glyf = (GlyfTable) font.getTable ("glyf"); Glyf g = glyf.getGlyph (glyphId); GeneralPath gp = null; if (g instanceof GlyfSimple) { gp = renderSimpleGlyph ((GlyfSimple) g); } else if (g instanceof GlyfCompound) { gp = renderCompoundGlyph (glyf, (GlyfCompound) g); } else { gp = new GeneralPath (); } // calculate the advance HmtxTable hmtx = (HmtxTable) font.getTable ("hmtx"); float advance = (float) hmtx.getAdvance (glyphId) / (float) unitsPerEm; // scale the glyph to match the desired advance float widthfactor = width / advance; // the base transform scales the glyph to 1x1 AffineTransform at = AffineTransform.getScaleInstance (1 / unitsPerEm, 1 / unitsPerEm); at.concatenate (AffineTransform.getScaleInstance (widthfactor, 1)); gp.transform (at); return gp; }
break; case HMTX_TABLE: outTable = new HmtxTable(ttf); break; case LOCA_TABLE:
/** * Get the outline of a character given the glyph id */ protected synchronized GeneralPath getOutline (int glyphId, float width) { // find the glyph itself GlyfTable glyf = (GlyfTable) font.getTable ("glyf"); Glyf g = glyf.getGlyph (glyphId); GeneralPath gp = null; if (g instanceof GlyfSimple) { gp = renderSimpleGlyph ((GlyfSimple) g); } else if (g instanceof GlyfCompound) { gp = renderCompoundGlyph (glyf, (GlyfCompound) g); } else { gp = new GeneralPath (); } // calculate the advance HmtxTable hmtx = (HmtxTable) font.getTable ("hmtx"); float advance = (float) hmtx.getAdvance (glyphId) / (float) unitsPerEm; // scale the glyph to match the desired advance float widthfactor = width / advance; // the base transform scales the glyph to 1x1 AffineTransform at = AffineTransform.getScaleInstance (1 / unitsPerEm, 1 / unitsPerEm); at.concatenate (AffineTransform.getScaleInstance (widthfactor, 1)); gp.transform (at); return gp; }
break; case HMTX_TABLE: outTable = new HmtxTable(ttf); break; case LOCA_TABLE:
/** * Get the outline of a character given the glyph id */ protected synchronized GeneralPath getOutline (int glyphId, float width) { // find the glyph itself GlyfTable glyf = (GlyfTable) font.getTable ("glyf"); Glyf g = glyf.getGlyph (glyphId); GeneralPath gp = null; if (g instanceof GlyfSimple) { gp = renderSimpleGlyph ((GlyfSimple) g); } else if (g instanceof GlyfCompound) { gp = renderCompoundGlyph (glyf, (GlyfCompound) g); } else { gp = new GeneralPath (); } // calculate the advance HmtxTable hmtx = (HmtxTable) font.getTable ("hmtx"); float advance = (float) hmtx.getAdvance (glyphId) / (float) unitsPerEm; // scale the glyph to match the desired advance float widthfactor = width / advance; // the base transform scales the glyph to 1x1 AffineTransform at = AffineTransform.getScaleInstance (1 / unitsPerEm, 1 / unitsPerEm); at.concatenate (AffineTransform.getScaleInstance (widthfactor, 1)); gp.transform (at); return gp; }
/** get the data in this map as a ByteBuffer */ public ByteBuffer getData() { int size = getLength(); ByteBuffer buf = ByteBuffer.allocate(size); // write the metrics for (int i = 0; i < leftSideBearings.length; i++) { if (i < advanceWidths.length) { buf.putShort(advanceWidths[i]); } buf.putShort(leftSideBearings[i]); } // reset the start pointer buf.flip(); return buf; }
break; case HMTX_TABLE: outTable = new HmtxTable(ttf); break; case LOCA_TABLE:
float advance = (float) hmtxTable.getAdvance (glyphID) / (float) unitsPerEm;
/** get the data in this map as a ByteBuffer */ public ByteBuffer getData() { int size = getLength(); ByteBuffer buf = ByteBuffer.allocate(size); // write the metrics for (int i = 0; i < leftSideBearings.length; i++) { if (i < advanceWidths.length) { buf.putShort(advanceWidths[i]); } buf.putShort(leftSideBearings[i]); } // reset the start pointer buf.flip(); return buf; }
float advance = (float) hmtxTable.getAdvance (glyphID) / (float) unitsPerEm;
float advance = (float) hmtxTable.getAdvance (glyphID) / (float) unitsPerEm;