@Override public int codeToGID(int code) { int cid = codeToCID(code); if (cidFont != null) { // The CIDs shall be used to determine the GID value for the glyph procedure using the // charset table in the CFF program return cidFont.getCharset().getGIDForCID(cid); } else { // The CIDs shall be used directly as GID values return cid; } }
@Override public boolean hasGlyph(String name) { int sid = charset.getSID(name); int gid = charset.getGIDForSID(sid); return gid != 0; }
private Format0Encoding readFormat0Encoding(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException { Format0Encoding encoding = new Format0Encoding(); encoding.format = format; encoding.nCodes = dataInput.readCard8(); encoding.add(0, 0, ".notdef"); for (int gid = 1; gid <= encoding.nCodes; gid++) { int code = dataInput.readCard8(); int sid = charset.getSIDForGID(gid); encoding.add(code, sid, readString(sid)); } if ((format & 0x80) != 0) { readSupplement(dataInput, encoding); } return encoding; }
StringBuilder sb = new StringBuilder(); for (Map.Entry<Integer, Integer> gid : gids.entrySet()) { String name = font.getCharset().getNameForGID(gid.getKey()); sb.append(String.format("dup %d /%s put", gid.getValue(), name)).append('\n'); max = Math.max(max, gid.getValue());
private Format1Encoding readFormat1Encoding(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException { Format1Encoding encoding = new Format1Encoding(); encoding.format = format; encoding.nRanges = dataInput.readCard8(); encoding.add(0, 0, ".notdef"); int gid = 1; for (int i = 0; i < encoding.nRanges; i++) { int rangeFirst = dataInput.readCard8(); int rangeLeft = dataInput.readCard8(); for (int j = 0; j < 1 + rangeLeft; j++) { int sid = charset.getSIDForGID(gid); int code = rangeFirst + j; encoding.add(code, sid, readString(sid)); gid++; } } if ((format & 0x80) != 0) { readSupplement(dataInput, encoding); } return encoding; }
Type1CharStringFormatter formatter = new Type1CharStringFormatter(); for (int gid : gids.keySet()) { String mapping = font.getCharset().getNameForGID(gid); byte[] type1Bytes = formatter.format(font.getType1CharString(mapping).getType1Sequence()); byte[] charstringBytes = Type1FontUtil.charstringEncrypt(type1Bytes, 4);
/** * Returns the GID for the given PostScript glyph name. * * @param name a PostScript glyph name. * @return GID */ public int nameToGID(String name) { // some fonts have glyphs beyond their encoding, so we look up by charset SID int sid = charset.getSID(name); return charset.getGIDForSID(sid); }
/** * Returns the Type 2 charstring for the given CID. * * @param cid CID * @throws IOException if the charstring could not be read */ @Override public CIDKeyedType2CharString getType2CharString(int cid) throws IOException { CIDKeyedType2CharString type2 = charStringCache.get(cid); if (type2 == null) { int gid = charset.getGIDForCID(cid); byte[] bytes = charStrings[gid]; if (bytes == null) { bytes = charStrings[0]; // .notdef } Type2CharStringParser parser = new Type2CharStringParser(fontName, cid); List<Object> type2seq = parser.parse(bytes, globalSubrIndex, getLocalSubrIndex(gid)); type2 = new CIDKeyedType2CharString(reader, fontName, cid, gid, type2seq, getDefaultWidthX(gid), getNominalWidthX(gid)); charStringCache.put(cid, type2); } return type2; }
private Format0Encoding readFormat0Encoding(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException { Format0Encoding encoding = new Format0Encoding(); encoding.format = format; encoding.nCodes = dataInput.readCard8(); encoding.add(0, 0, ".notdef"); for (int gid = 1; gid <= encoding.nCodes; gid++) { int code = dataInput.readCard8(); int sid = charset.getSIDForGID(gid); encoding.add(code, sid, readString(sid)); } if ((format & 0x80) != 0) { readSupplement(dataInput, encoding); } return encoding; }
@Override public boolean hasGlyph(String name) { int sid = charset.getSID(name); int gid = charset.getGIDForSID(sid); return gid != 0; }
@Override public int codeToGID(int code) { int cid = codeToCID(code); if (cidFont != null) { // The CIDs shall be used to determine the GID value for the glyph procedure using the // charset table in the CFF program return cidFont.getCharset().getGIDForCID(cid); } else { // The CIDs shall be used directly as GID values return cid; } }
private Format0Encoding readFormat0Encoding(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException { Format0Encoding encoding = new Format0Encoding(); encoding.format = format; encoding.nCodes = dataInput.readCard8(); encoding.add(0, 0, ".notdef"); for (int gid = 1; gid <= encoding.nCodes; gid++) { int code = dataInput.readCard8(); int sid = charset.getSIDForGID(gid); encoding.add(code, sid, readString(sid)); } if ((format & 0x80) != 0) { readSupplement(dataInput, encoding); } return encoding; }
@Override public boolean hasGlyph(String name) { int sid = charset.getSID(name); int gid = charset.getGIDForSID(sid); return gid != 0; }
@Override public int codeToGID(int code) { int cid = codeToCID(code); if (cidFont != null) { // The CIDs shall be used to determine the GID value for the glyph procedure using the // charset table in the CFF program return cidFont.getCharset().getGIDForCID(cid); } else { // The CIDs shall be used directly as GID values return cid; } }
private Format1Encoding readFormat1Encoding(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException { Format1Encoding encoding = new Format1Encoding(); encoding.format = format; encoding.nRanges = dataInput.readCard8(); encoding.add(0, 0, ".notdef"); int gid = 1; for (int i = 0; i < encoding.nRanges; i++) { int rangeFirst = dataInput.readCard8(); int rangeLeft = dataInput.readCard8(); for (int j = 0; j < 1 + rangeLeft; j++) { int sid = charset.getSIDForGID(gid); int code = rangeFirst + j; encoding.add(code, sid, readString(sid)); gid++; } } if ((format & 0x80) != 0) { readSupplement(dataInput, encoding); } return encoding; }
/** * Returns the GID for the given PostScript glyph name. * * @param name a PostScript glyph name. * @return GID */ public int nameToGID(String name) { // some fonts have glyphs beyond their encoding, so we look up by charset SID int sid = charset.getSID(name); return charset.getGIDForSID(sid); }
/** * Returns the Type 2 charstring for the given CID. * * @param cid CID * @throws IOException if the charstring could not be read */ @Override public CIDKeyedType2CharString getType2CharString(int cid) throws IOException { CIDKeyedType2CharString type2 = charStringCache.get(cid); if (type2 == null) { int gid = charset.getGIDForCID(cid); byte[] bytes = charStrings[gid]; if (bytes == null) { bytes = charStrings[0]; // .notdef } Type2CharStringParser parser = new Type2CharStringParser(fontName, cid); List<Object> type2seq = parser.parse(bytes, globalSubrIndex, getLocalSubrIndex(gid)); type2 = new CIDKeyedType2CharString(reader, fontName, cid, gid, type2seq, getDefaultWidthX(gid), getNominalWidthX(gid)); charStringCache.put(cid, type2); } return type2; }
private Format1Encoding readFormat1Encoding(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException { Format1Encoding encoding = new Format1Encoding(); encoding.format = format; encoding.nRanges = dataInput.readCard8(); encoding.add(0, 0, ".notdef"); int gid = 1; for (int i = 0; i < encoding.nRanges; i++) { int rangeFirst = dataInput.readCard8(); int rangeLeft = dataInput.readCard8(); for (int j = 0; j < 1 + rangeLeft; j++) { int sid = charset.getSIDForGID(gid); int code = rangeFirst + j; encoding.add(code, sid, readString(sid)); gid++; } } if ((format & 0x80) != 0) { readSupplement(dataInput, encoding); } return encoding; }
/** * Returns the GID for the given PostScript glyph name. * * @param name a PostScript glyph name. * @return GID */ public int nameToGID(String name) { // some fonts have glyphs beyond their encoding, so we look up by charset SID int sid = charset.getSID(name); return charset.getGIDForSID(sid); }
/** * Returns the Type 2 charstring for the given CID. * * @param cid CID * @throws IOException if the charstring could not be read */ @Override public CIDKeyedType2CharString getType2CharString(int cid) throws IOException { CIDKeyedType2CharString type2 = charStringCache.get(cid); if (type2 == null) { int gid = charset.getGIDForCID(cid); byte[] bytes = charStrings[gid]; if (bytes == null) { bytes = charStrings[0]; // .notdef } Type2CharStringParser parser = new Type2CharStringParser(fontName, cid); List<Object> type2seq = parser.parse(bytes, globalSubrIndex, getLocalSubrIndex(gid)); type2 = new CIDKeyedType2CharString(reader, fontName, cid, gid, type2seq, getDefaultWidthX(gid), getNominalWidthX(gid)); charStringCache.put(cid, type2); } return type2; }