/** * This will read the required data from the stream. * * @param ttf The font that is being read. * @param data The stream to read the data from. * @throws java.io.IOException If there is an error reading the data. */ public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { byte[] bytes = data.read((int)getLength()); CFFParser parser = new CFFParser(); cffFont = parser.parse(bytes, new ByteSource(font)).get(0); initialized = true; }
DictData topDict = readDictData(topDictInput); ((CFFCIDFont) font).setRegistry(readString(rosEntry.getNumber(0).intValue())); ((CFFCIDFont) font).setOrdering(readString(rosEntry.getNumber(1).intValue())); ((CFFCIDFont) font).setSupplement(rosEntry.getNumber(2).intValue()); 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)); int charStringsOffset = charStringsEntry.getNumber(0).intValue(); input.setPosition(charStringsOffset); byte[][] charStringsIndex = readIndexData(input); charset = readCharset(input, charStringsIndex.length, isCIDFont); parseCIDFontDicts(input, topDict, (CFFCIDFont) font, numEntries); concatenateMatrix(matrix, privMatrix); parseType1Dicts(input, topDict, (CFFType1Font) font, charset);
String firstTag = readTagName(input); input = createTaggedCFFDataInput(input, bytes); break; case TAG_TTCF: Header header = readHeader(input); String[] nameIndex = readStringIndexData(input); if (nameIndex == null) byte[][] topDictIndex = readIndexData(input); if (topDictIndex == null) stringIndex = readStringIndexData(input); byte[][] globalSubrIndex = readIndexData(input); CFFFont font = parseFont(input, nameIndex[i], topDictIndex[i]); font.setGlobalSubrIndex(globalSubrIndex); font.setData(source);
byte[][] fdIndex = readIndexData(input); DictData fontDict = readDictData(fontDictInput); fontDictMap.put("FontName", getString(fontDict, "FontName")); fontDictMap.put("FontType", fontDict.getNumber("FontType", 0)); fontDictMap.put("FontBBox", fontDict.getArray("FontBBox", null)); input.setPosition(privateOffset); int privateSize = privateEntry.getNumber(0).intValue(); DictData privateDict = readDictData(input, privateSize); Map<String, Object> privDict = readPrivateDict(privateDict); privateDictionaries.add(privDict); privDict.put("Subrs", readIndexData(input)); int fdSelectPos = fdSelectEntry.getNumber(0).intValue(); input.setPosition(fdSelectPos); FDSelect fdSelect = readFDSelect(input, nrOfcharStrings, font);
/** * Parse CFF font using byte array, also passing in a byte source for future use. * * @param bytes source bytes * @param source source to re-read bytes from in the future * @return the parsed CFF fonts * @throws IOException If there is an error reading from the stream */ public List<CFFFont> parse(byte[] bytes, ByteSource source) throws IOException { this.source = source; return parse(bytes); }
byte[][] fdIndex = readIndexData(input); DictData fontDict = readDictData(fontDictInput); fontDictMap.put("FontName", getString(fontDict, "FontName")); fontDictMap.put("FontType", fontDict.getNumber("FontType", 0)); fontDictMap.put("FontBBox", fontDict.getArray("FontBBox", null)); input.setPosition(privateOffset); int privateSize = privateEntry.getNumber(0).intValue(); DictData privateDict = readDictData(input, privateSize); Map<String, Object> privDict = readPrivateDict(privateDict); privateDictionaries.add(privDict); privDict.put("Subrs", readIndexData(input)); int fdSelectPos = fdSelectEntry.getNumber(0).intValue(); input.setPosition(fdSelectPos); FDSelect fdSelect = readFDSelect(input, nrOfcharStrings, font);
/** * Parse CFF font using byte array, also passing in a byte source for future use. * * @param bytes source bytes * @param source source to re-read bytes from in the future * @return the parsed CFF fonts * @throws IOException If there is an error reading from the stream */ public List<CFFFont> parse(byte[] bytes, ByteSource source) throws IOException { this.source = source; return parse(bytes); }
DictData topDict = readDictData(topDictInput); ((CFFCIDFont) font).setRegistry(readString(rosEntry.getNumber(0).intValue())); ((CFFCIDFont) font).setOrdering(readString(rosEntry.getNumber(1).intValue())); ((CFFCIDFont) font).setSupplement(rosEntry.getNumber(2).intValue()); 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)); int charStringsOffset = charStringsEntry.getNumber(0).intValue(); input.setPosition(charStringsOffset); byte[][] charStringsIndex = readIndexData(input); charset = readCharset(input, charStringsIndex.length, isCIDFont); parseCIDFontDicts(input, topDict, (CFFCIDFont) font, charStringsIndex.length); concatenateMatrix(matrix, privMatrix); parseType1Dicts(input, topDict, (CFFType1Font) font, charset);
String firstTag = readTagName(input); input = createTaggedCFFDataInput(input, bytes); break; case TAG_TTCF: Header header = readHeader(input); String[] nameIndex = readStringIndexData(input); if (nameIndex == null) byte[][] topDictIndex = readIndexData(input); stringIndex = readStringIndexData(input); byte[][] globalSubrIndex = readIndexData(input); CFFFont font = parseFont(input, nameIndex[i], topDictIndex[i]); font.setGlobalSubrIndex(globalSubrIndex); font.setData(source);
byte[][] fdIndex = readIndexData(input); DictData fontDict = readDictData(fontDictInput); fontDictMap.put("FontName", getString(fontDict, "FontName")); fontDictMap.put("FontType", fontDict.getNumber("FontType", 0)); fontDictMap.put("FontBBox", fontDict.getArray("FontBBox", null)); input.setPosition(privateOffset); int privateSize = privateEntry.getNumber(0).intValue(); DictData privateDict = readDictData(input, privateSize); Map<String, Object> privDict = readPrivateDict(privateDict); privateDictionaries.add(privDict); privDict.put("Subrs", readIndexData(input)); int fdSelectPos = fdSelectEntry.getNumber(0).intValue(); input.setPosition(fdSelectPos); FDSelect fdSelect = readFDSelect(input, nrOfcharStrings, font);
/** * Parse CFF font using byte array, also passing in a byte source for future use. * * @param bytes source bytes * @param source source to re-read bytes from in the future * @return the parsed CFF fonts * @throws IOException If there is an error reading from the stream */ public List<CFFFont> parse(byte[] bytes, ByteSource source) throws IOException { this.source = source; return parse(bytes); }
DictData topDict = readDictData(topDictInput); ((CFFCIDFont) font).setRegistry(readString(rosEntry.getNumber(0).intValue())); ((CFFCIDFont) font).setOrdering(readString(rosEntry.getNumber(1).intValue())); ((CFFCIDFont) font).setSupplement(rosEntry.getNumber(2).intValue()); 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)); int charStringsOffset = charStringsEntry.getNumber(0).intValue(); input.setPosition(charStringsOffset); byte[][] charStringsIndex = readIndexData(input); charset = readCharset(input, charStringsIndex.length, isCIDFont); parseCIDFontDicts(input, topDict, (CFFCIDFont) font, charStringsIndex.length); concatenateMatrix(matrix, privMatrix); parseType1Dicts(input, topDict, (CFFType1Font) font, charset);
String firstTag = readTagName(input); input = createTaggedCFFDataInput(input, bytes); Header header = readHeader(input); String[] nameIndex = readStringIndexData(input); if (nameIndex == null) byte[][] topDictIndex = readIndexData(input); stringIndex = readStringIndexData(input); byte[][] globalSubrIndex = readIndexData(input); CFFFont font = parseFont(input, nameIndex[i], topDictIndex[i]); font.setGlobalSubrIndex(globalSubrIndex); font.setData(source);
/** * This will read the required data from the stream. * * @param ttf The font that is being read. * @param data The stream to read the data from. * @throws java.io.IOException If there is an error reading the data. */ public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { byte[] bytes = data.read((int)getLength()); CFFParser parser = new CFFParser(); cffFont = parser.parse(bytes, new ByteSource(font)).get(0); initialized = true; }
/** * This will read the required data from the stream. * * @param ttf The font that is being read. * @param data The stream to read the data from. * @throws java.io.IOException If there is an error reading the data. */ public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { byte[] bytes = data.read((int)getLength()); CFFParser parser = new CFFParser(); cffFont = parser.parse(bytes, new ByteSource(font)).get(0); initialized = true; }
private List<InputStream> convertOTFToType1(InputStream in) throws IOException { CFFFont f = new CFFParser().parse(IOUtils.toByteArray(in)).get(0); if (!(f instanceof CFFType1Font)) { throw new IOException(getEmbedFileURI() + ": only OTF CFF Type1 font can be converted to Type1"); } List<InputStream> fonts = new ArrayList<InputStream>(); Map<Integer, Integer> glyphs = cidSet.getGlyphs(); int i = 0; for (Map<Integer, Integer> x : splitGlyphs(glyphs)) { String iStr = "." + i; fonts.add(convertOTFToType1(x, f, iStr)); i++; } return fonts; }