/** Creates a new instance of HmtxTable */ protected HmtxTable(TrueTypeFont ttf) { super (TrueTypeTable.HMTX_TABLE); // the number of glyphs stored in the maxp table may be incorrect // in the case of subsetted fonts produced by some pdf generators MaxpTable maxp = (MaxpTable) ttf.getTable("maxp"); int numGlyphs = maxp.getNumGlyphs(); HheaTable hhea = (HheaTable) ttf.getTable("hhea"); int numOfLongHorMetrics = hhea.getNumOfLongHorMetrics(); advanceWidths = new short[numOfLongHorMetrics]; leftSideBearings = new short[numGlyphs]; }
/** Creates a new instance of HmtxTable */ protected LocaTable(TrueTypeFont ttf) { super (TrueTypeTable.LOCA_TABLE); MaxpTable maxp = (MaxpTable) ttf.getTable("maxp"); int numGlyphs = maxp.getNumGlyphs(); HeadTable head = (HeadTable) ttf.getTable("head"); short format = head.getIndexToLocFormat(); isLong = (format == 1); offsets = new int[numGlyphs + 1]; }
/** Creates a new instance of HmtxTable */ protected LocaTable(TrueTypeFont ttf) { super (TrueTypeTable.LOCA_TABLE); MaxpTable maxp = (MaxpTable) ttf.getTable("maxp"); int numGlyphs = maxp.getNumGlyphs(); HeadTable head = (HeadTable) ttf.getTable("head"); short format = head.getIndexToLocFormat(); isLong = (format == 1); offsets = new int[numGlyphs + 1]; }
/** Creates a new instance of HmtxTable */ protected HmtxTable(TrueTypeFont ttf) { super (TrueTypeTable.HMTX_TABLE); // the number of glyphs stored in the maxp table may be incorrect // in the case of subsetted fonts produced by some pdf generators MaxpTable maxp = (MaxpTable) ttf.getTable("maxp"); int numGlyphs = maxp.getNumGlyphs(); HheaTable hhea = (HheaTable) ttf.getTable("hhea"); int numOfLongHorMetrics = hhea.getNumOfLongHorMetrics(); advanceWidths = new short[numOfLongHorMetrics]; leftSideBearings = new short[numGlyphs]; }
/** Creates a new instance of HmtxTable */ protected LocaTable(TrueTypeFont ttf) { super (TrueTypeTable.LOCA_TABLE); MaxpTable maxp = (MaxpTable) ttf.getTable("maxp"); int numGlyphs = maxp.getNumGlyphs(); HeadTable head = (HeadTable) ttf.getTable("head"); short format = head.getIndexToLocFormat(); isLong = (format == 1); offsets = new int[numGlyphs + 1]; }
/** Creates a new instance of HmtxTable */ protected HmtxTable(TrueTypeFont ttf) { super (TrueTypeTable.HMTX_TABLE); // the number of glyphs stored in the maxp table may be incorrect // in the case of subsetted fonts produced by some pdf generators MaxpTable maxp = (MaxpTable) ttf.getTable("maxp"); int numGlyphs = maxp.getNumGlyphs(); HheaTable hhea = (HheaTable) ttf.getTable("hhea"); int numOfLongHorMetrics = hhea.getNumOfLongHorMetrics(); advanceWidths = new short[numOfLongHorMetrics]; leftSideBearings = new short[numGlyphs]; }
public Collection<String> getNames() { NameTable table = (NameTable) getTable("name"); if (table != null) { return table.getNames(); } else { return Collections.emptyList(); } }
/** * Write the font to a pretty string */ public String toString () { StringBuffer buf = new StringBuffer (); System.out.println ("Type : " + getType ()); System.out.println ("NumTables : " + getNumTables ()); System.out.println ("SearchRange : " + getSearchRange ()); System.out.println ("EntrySelector: " + getEntrySelector ()); System.out.println ("RangeShift : " + getRangeShift ()); for (Iterator i = tables.entrySet ().iterator (); i.hasNext ();) { Map.Entry e = (Map.Entry) i.next (); TrueTypeTable table = null; if (e.getValue () instanceof ByteBuffer) { table = getTable ((String) e.getKey ()); } else { table = (TrueTypeTable) e.getValue (); } System.out.println (table); } return buf.toString (); }
/** * Write the font to a pretty string */ public String toString () { StringBuffer buf = new StringBuffer (); System.out.println ("Type : " + getType ()); System.out.println ("NumTables : " + getNumTables ()); System.out.println ("SearchRange : " + getSearchRange ()); System.out.println ("EntrySelector: " + getEntrySelector ()); System.out.println ("RangeShift : " + getRangeShift ()); for (Iterator i = tables.entrySet ().iterator (); i.hasNext ();) { Map.Entry e = (Map.Entry) i.next (); TrueTypeTable table = null; if (e.getValue () instanceof ByteBuffer) { table = getTable ((String) e.getKey ()); } else { table = (TrueTypeTable) e.getValue (); } System.out.println (table); } return buf.toString (); }
/** * Write the font to a pretty string */ public String toString () { StringBuffer buf = new StringBuffer (); System.out.println ("Type : " + getType ()); System.out.println ("NumTables : " + getNumTables ()); System.out.println ("SearchRange : " + getSearchRange ()); System.out.println ("EntrySelector: " + getEntrySelector ()); System.out.println ("RangeShift : " + getRangeShift ()); for (Iterator i = tables.entrySet ().iterator (); i.hasNext ();) { Map.Entry e = (Map.Entry) i.next (); TrueTypeTable table = null; if (e.getValue () instanceof ByteBuffer) { table = getTable ((String) e.getKey ()); } else { table = (TrueTypeTable) e.getValue (); } System.out.println (table); } return buf.toString (); }
/** * Get the outline of a character given the character name */ protected synchronized GeneralPath getOutline (String name, float width) { int idx; PostTable post = (PostTable) font.getTable ("post"); if (post != null) { idx = post.getGlyphNameIndex (name); if (idx != 0) { return getOutline (idx, width); } return null; } Integer res = AdobeGlyphList.getGlyphNameIndex (name); if (res != null) { idx = res; return getOutlineFromCMaps ((char) idx, width); } return null; }
/** * Get the outline of a character given the character name */ protected synchronized GeneralPath getOutline (String name, float width) { int idx; PostTable post = (PostTable) font.getTable ("post"); if (post != null) { idx = post.getGlyphNameIndex (name); if (idx != 0) { return getOutline (idx, width); } return null; } Integer res = AdobeGlyphList.getGlyphNameIndex (name); if (res != null) { idx = res; return getOutlineFromCMaps ((char) idx, width); } return null; }
/** * Get the outline of a character given the character name */ protected synchronized GeneralPath getOutline (String name, float width) { int idx; PostTable post = (PostTable) font.getTable ("post"); if (post != null) { idx = post.getGlyphNameIndex (name); if (idx != 0) { return getOutline (idx, width); } return null; } Integer res = AdobeGlyphList.getGlyphNameIndex (name); if (res != null) { idx = res; return getOutlineFromCMaps ((char) idx, width); } return null; }
/** * lookup the outline using the CMAPs, as specified in 32000-1:2008, * 9.6.6.4, when an Encoding is specified. * * @param val * @param width * @return GeneralPath */ protected synchronized GeneralPath getOutlineFromCMaps (char val, float width) { // find the cmaps CmapTable cmap = (CmapTable) font.getTable ("cmap"); if (cmap == null) { return null; } // try maps in required order of (3, 1), (1, 0) CMap map = cmap.getCMap ((short) 3, (short) 1); if (map == null) { map = cmap.getCMap ((short) 1, (short) 0); } int idx = map.map (val); if (idx != 0) { return getOutline (idx, width); } return null; }
/** * Get the outline of a character given the character code */ protected synchronized GeneralPath getOutline (char src, float width) { // find the cmaps CmapTable cmap = (CmapTable) font.getTable ("cmap"); // if there are no cmaps, this is (hopefully) a cid-mapped font, // so just trust the value we were given for src if (cmap == null) { return getOutline ((int) src, width); } CMap[] maps = cmap.getCMaps (); // try the maps in order for (int i = 0; i < maps.length; i++) { int idx = maps[i].map (src); if (idx != 0) { return getOutline (idx, width); } } // not found, return the empty glyph return getOutline (0, width); }
/** * Get the outline of a character given the character code */ protected synchronized GeneralPath getOutline (char src, float width) { // find the cmaps CmapTable cmap = (CmapTable) font.getTable ("cmap"); // if there are no cmaps, this is (hopefully) a cid-mapped font, // so just trust the value we were given for src if (cmap == null) { return getOutline ((int) src, width); } CMap[] maps = cmap.getCMaps (); // try the maps in order for (int i = 0; i < maps.length; i++) { int idx = maps[i].map (src); if (idx != 0) { return getOutline (idx, width); } } // not found, return the empty glyph return getOutline (0, width); }
/** * Get the outline of a character given the character code */ protected synchronized GeneralPath getOutline (char src, float width) { // find the cmaps CmapTable cmap = (CmapTable) font.getTable ("cmap"); // if there are no cmaps, this is (hopefully) a cid-mapped font, // so just trust the value we were given for src if (cmap == null) { return getOutline ((int) src, width); } CMap[] maps = cmap.getCMaps (); // try the maps in order for (int i = 0; i < maps.length; i++) { int idx = maps[i].map (src); if (idx != 0) { return getOutline (idx, width); } } // not found, return the empty glyph return getOutline (0, width); }