@Override public int getGlyphId(int characterCode) { int gid = cmap.getGlyphId(characterCode); String[] scriptTags = OpenTypeScript.getScriptTags(characterCode); return gsub.getSubstitution(gid, scriptTags, enabledFeatures); }
@Override public String getName() throws IOException { if (getNaming() != null) { return getNaming().getPostScriptName(); } else { return null; } }
public GsubData getGsubData() throws IOException { GlyphSubstitutionTable table = getGsub(); if (table == null) { return GsubData.NO_DATA_FOUND; } return table.getGsubData(); }
@Override public float getHeight(int code) throws IOException { // todo: really we want the BBox, (for text extraction:) return (ttf.getHorizontalHeader().getAscender() + -ttf.getHorizontalHeader().getDescender()) / ttf.getUnitsPerEm(); // todo: shouldn't this be the yMax/yMin? }
private GlyphData getGlyphData(int gid) throws IOException { GlyphData glyph = new GlyphData(); HorizontalMetricsTable hmt = font.getHorizontalMetrics(); int leftSideBearing = hmt == null ? 0 : hmt.getLeftSideBearing(gid); glyph.initData(this, data, leftSideBearing); // resolve composite glyph if (glyph.getDescription().isComposite()) { glyph.getDescription().resolve(); } return glyph; } }
@Override public boolean hasGlyph(String name) throws IOException { int gid = ttf.nameToGID(name); return !(gid == 0 || gid >= ttf.getMaximumProfile().getNumGlyphs()); }
/** * Parse an input stream and return a TrueType font. * * @param inputStream The TTF data stream to parse from. It will be closed before returning. * @return A TrueType font. * @throws IOException If there is an error parsing the TrueType font. */ public TrueTypeFont parse(InputStream inputStream) throws IOException { return parse(new MemoryTTFDataStream(inputStream)); }
private void readSubtable0Format0(TTFDataStream data) throws IOException { pairs = new PairData0Format0(); pairs.read(data); }
/** * Run the callback for each TT font in the collection. * * @param trueTypeFontProcessor the object with the callback method. * @throws IOException */ public void processAllFonts(TrueTypeFontProcessor trueTypeFontProcessor) throws IOException { for (int i = 0; i < numFonts; i++) { TrueTypeFont font = getFontAtIndex(i); trueTypeFontProcessor.process(font); } }
@Override public boolean hasGlyph(String name) throws IOException { return nameToGID(name) != 0; }
@Override public List<Integer> getCharCodes(int gid) { return cmap.getCharCodes(gsub.getUnsubstitution(gid)); } }
@Override public void close() throws IOException { stream.close(); } }
/** * Read the hinting instructions. * @param bais the stream to be read * @param count the number of instructions to be read * @throws IOException is thrown if something went wrong */ protected void readInstructions(TTFDataStream bais, int count) throws IOException { instructions = bais.readUnsignedByteArray(count); }
@Override public void seek(long pos) throws IOException { stream.seek(pos); }
@Override public long getCurrentPosition() throws IOException { return stream.getCurrentPosition(); }
/** * Get the OS/2 table for this TTF. * * @return The OS/2 table. * @throws IOException if there was an error reading the table. */ public OS2WindowsMetricsTable getOS2Windows() throws IOException { return (OS2WindowsMetricsTable) getTable(OS2WindowsMetricsTable.TAG); }
/** * Get the data size of the TrueType Font program representing the stream used to build this * object (normally from the TTFParser object). * * @return the size. */ public long getOriginalDataSize() { return data.getOriginalDataSize(); }
/** * Parse an input stream and return a TrueType font that is to be embedded. * * @param inputStream The TTF data stream to parse from. It will be closed before returning. * @return A TrueType font. * @throws IOException If there is an error parsing the TrueType font. */ public TrueTypeFont parseEmbedded(InputStream inputStream) throws IOException { this.isEmbedded = true; return parse(new MemoryTTFDataStream(inputStream)); }
@Override public void close() throws IOException { data.close(); }