@Override public GeneralPath getPath(String name) throws IOException { int gid = nameToGID(name); return getCFF().getFont().getType2CharString(gid).getPath(); }
font.setName(name); font.addValueToTopDict("version", getString(topDict, "version")); font.addValueToTopDict("Notice", getString(topDict, "Notice")); font.addValueToTopDict("Copyright", getString(topDict, "Copyright")); font.addValueToTopDict("FullName", getString(topDict, "FullName")); font.addValueToTopDict("FamilyName", getString(topDict, "FamilyName")); font.addValueToTopDict("Weight", getString(topDict, "Weight")); font.addValueToTopDict("isFixedPitch", topDict.getBoolean("isFixedPitch", false)); font.addValueToTopDict("ItalicAngle", topDict.getNumber("ItalicAngle", 0)); font.addValueToTopDict("UnderlinePosition", topDict.getNumber("UnderlinePosition", -100)); font.addValueToTopDict("UnderlineThickness", topDict.getNumber("UnderlineThickness", 50)); font.addValueToTopDict("PaintType", topDict.getNumber("PaintType", 0)); font.addValueToTopDict("CharstringType", topDict.getNumber("CharstringType", 2)); font.addValueToTopDict("FontMatrix", topDict.getArray("FontMatrix", Arrays.<Number>asList( 0.001, (double) 0, (double) 0, 0.001, (double) 0, (double) 0))); font.addValueToTopDict("UniqueID", topDict.getNumber("UniqueID", null)); font.addValueToTopDict("FontBBox", topDict.getArray("FontBBox", Arrays.<Number> asList(0, 0, 0, 0))); font.addValueToTopDict("StrokeWidth", topDict.getNumber("StrokeWidth", 0)); font.addValueToTopDict("XUID", topDict.getArray("XUID", null)); font.setCharset(charset); font.addValueToTopDict("FontMatrix", privMatrix); font.addValueToTopDict("FontMatrix", topDict.getArray("FontMatrix", Arrays.<Number>asList(0.001, (double) 0, (double) 0, 0.001,
protected void readName() throws IOException { Object familyName = fileFont.getTopDict().get("FamilyName"); if (familyName != null && !familyName.equals("")) { familyNames.add(familyName.toString()); fullName = familyName.toString(); } else { fullName = fileFont.getName(); familyNames.add(fullName); } }
font.setGlobalSubrIndex(globalSubrIndex); font.setData(source); fonts.add(font);
private <X> X nonNullDictEntry(String key, Class<X> type) { Object value = font.getTopDict().get(key); if (value != null) return (X) value; if (type == String.class) return (X) ""; if (type == Integer.class) return (X) new Integer(1); return (X) ""; }
public String getName() { String name = font.getName(); if (name.isEmpty()) name = nonNullDictEntry("FullName", String.class); return name; }
font.setGlobalSubrIndex(globalSubrIndex); font.setData(source); fonts.add(font);
private ArrayList<Integer> getBoundingBox() { Object obj = font.getTopDict().get("FontBBox"); ArrayList<Integer> boundingBox = null; if (obj != null && obj instanceof ArrayList) boundingBox = (ArrayList<Integer>) obj; if (boundingBox == null || boundingBox.size() < 4) boundingBox = createDefaultBoundingBox(); return boundingBox; }
@Override protected void initializeFont(FontFileReader in) throws IOException { fontFile = in; fontFile.seekSet(0); CFFParser parser = new CFFParser(); fileFont = parser.parse(in.getAllBytes()).get(0); embedFontName = fileFont.getName(); }
@Override public GeneralPath getPath(int code) throws IOException { if (ttf instanceof OpenTypeFont && ((OpenTypeFont)ttf).isPostScript()) { // we're not supposed to have CFF fonts inside PDCIDFontType2, but if we do, // then we treat their CIDs as GIDs, see PDFBOX-3344 int cid = codeToGID(code); Type2CharString charstring = ((OpenTypeFont)ttf).getCFF().getFont().getType2CharString(cid); return charstring.getPath(); } else { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getPath(); } return new GeneralPath(); } }
font.setName(name); font.addValueToTopDict("version", getString(topDict, "version")); font.addValueToTopDict("Notice", getString(topDict, "Notice")); font.addValueToTopDict("Copyright", getString(topDict, "Copyright")); font.addValueToTopDict("FullName", getString(topDict, "FullName")); font.addValueToTopDict("FamilyName", getString(topDict, "FamilyName")); font.addValueToTopDict("Weight", getString(topDict, "Weight")); font.addValueToTopDict("isFixedPitch", topDict.getBoolean("isFixedPitch", false)); font.addValueToTopDict("ItalicAngle", topDict.getNumber("ItalicAngle", 0)); font.addValueToTopDict("UnderlinePosition", topDict.getNumber("UnderlinePosition", -100)); font.addValueToTopDict("UnderlineThickness", topDict.getNumber("UnderlineThickness", 50)); font.addValueToTopDict("PaintType", topDict.getNumber("PaintType", 0)); font.addValueToTopDict("CharstringType", topDict.getNumber("CharstringType", 2)); font.addValueToTopDict("FontMatrix", topDict.getArray("FontMatrix", Arrays.<Number>asList( 0.001, (double) 0, (double) 0, 0.001, (double) 0, (double) 0))); font.addValueToTopDict("UniqueID", topDict.getNumber("UniqueID", null)); font.addValueToTopDict("FontBBox", topDict.getArray("FontBBox", Arrays.<Number> asList(0, 0, 0, 0))); font.addValueToTopDict("StrokeWidth", topDict.getNumber("StrokeWidth", 0)); font.addValueToTopDict("XUID", topDict.getArray("XUID", null)); font.setCharset(charset); font.addValueToTopDict("FontMatrix", privMatrix); font.addValueToTopDict("FontMatrix", topDict.getArray("FontMatrix", Arrays.<Number>asList(0.001, (double) 0, (double) 0, 0.001,
font.setGlobalSubrIndex(globalSubrIndex); font.setData(source); fonts.add(font);
@Override protected void updateBBoxAndOffset() throws IOException { Object bbox = fileFont.getTopDict().get("FontBBox"); if (bbox != null) { List bboxList = (List) bbox; int[] bboxInt = new int[4]; for (int i = 0; i < bboxInt.length; i++) { bboxInt[i] = (Integer) bboxList.get(i); } for (OFMtxEntry o : mtxTab) { o.setBoundingBox(bboxInt); } } }
public List<CffGlyph> getGlyphs() throws IOException { List<CffGlyph> glyphs = new ArrayList<CffGlyph>(); for (GlyphMapReader.GlyphMapping mapOn : getGlyphMaps()) { CffGlyph glyph = createGlyph(); Type2CharString charStr = font.getType2CharString(mapOn.glyphId); glyph.readType2Sequence(charStr.getType2Sequence()); glyph.map = mapOn; glyph.charStr = charStr; glyphs.add(glyph); } return glyphs; }
font.setName(name); font.addValueToTopDict("version", getString(topDict, "version")); font.addValueToTopDict("Notice", getString(topDict, "Notice")); font.addValueToTopDict("Copyright", getString(topDict, "Copyright")); font.addValueToTopDict("FullName", getString(topDict, "FullName")); font.addValueToTopDict("FamilyName", getString(topDict, "FamilyName")); font.addValueToTopDict("Weight", getString(topDict, "Weight")); font.addValueToTopDict("isFixedPitch", topDict.getBoolean("isFixedPitch", false)); font.addValueToTopDict("ItalicAngle", topDict.getNumber("ItalicAngle", 0)); font.addValueToTopDict("UnderlinePosition", topDict.getNumber("UnderlinePosition", -100)); font.addValueToTopDict("UnderlineThickness", topDict.getNumber("UnderlineThickness", 50)); font.addValueToTopDict("PaintType", topDict.getNumber("PaintType", 0)); font.addValueToTopDict("CharstringType", topDict.getNumber("CharstringType", 2)); font.addValueToTopDict("FontMatrix", topDict.getArray("FontMatrix", Arrays.<Number>asList( 0.001, (double) 0, (double) 0, 0.001, (double) 0, (double) 0))); font.addValueToTopDict("UniqueID", topDict.getNumber("UniqueID", null)); font.addValueToTopDict("FontBBox", topDict.getArray("FontBBox", Arrays.<Number> asList(0, 0, 0, 0))); font.addValueToTopDict("StrokeWidth", topDict.getNumber("StrokeWidth", 0)); font.addValueToTopDict("XUID", topDict.getArray("XUID", null)); font.setCharset(charset); font.addValueToTopDict("FontMatrix", privMatrix); font.addValueToTopDict("FontMatrix", topDict.getArray("FontMatrix", Arrays.<Number>asList(0.001, (double) 0, (double) 0, 0.001,
@Override public GeneralPath getPath(String name) throws IOException { int gid = nameToGID(name); return getCFF().getFont().getType2CharString(gid).getPath(); }
@Override public GeneralPath getPath(String name) throws IOException { int gid = nameToGID(name); return getCFF().getFont().getType2CharString(gid).getPath(); }
@Override public GeneralPath getPath(int code) throws IOException { if (ttf instanceof OpenTypeFont && ((OpenTypeFont)ttf).isPostScript()) { // we're not supposed to have CFF fonts inside PDCIDFontType2, but if we do, // then we treat their CIDs as GIDs, see PDFBOX-3344 int cid = codeToGID(code); Type2CharString charstring = ((OpenTypeFont)ttf).getCFF().getFont().getType2CharString(cid); return charstring.getPath(); } else { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getPath(); } return new GeneralPath(); } }
@Override public GeneralPath getPath(int code) throws IOException { if (ttf instanceof OpenTypeFont && ((OpenTypeFont)ttf).isPostScript()) { // we're not supposed to have CFF fonts inside PDCIDFontType2, but if we do, // then we treat their CIDs as GIDs, see PDFBOX-3344 int cid = codeToGID(code); Type2CharString charstring = ((OpenTypeFont)ttf).getCFF().getFont().getType2CharString(cid); return charstring.getPath(); } else { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getPath(); } return new GeneralPath(); } }