/** * Read the Format 0 of the FDSelect data structure. * @param dataInput * @param format * @param nGlyphs * @param ros * @return the Format 0 of the FDSelect data * @throws IOException */ private static Format0FDSelect readFormat0FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros) throws IOException { Format0FDSelect fdselect = new Format0FDSelect(ros); fdselect.format = format; fdselect.fds = new int[nGlyphs]; for (int i = 0; i < fdselect.fds.length; i++) { fdselect.fds[i] = dataInput.readCard8(); } return fdselect; }
private CFFEncoding readEncoding(CFFDataInput dataInput, CFFCharset charset) throws IOException { int format = dataInput.readCard8(); int baseFormat = format & 0x7f; switch (baseFormat) { case 0: return readFormat0Encoding(dataInput, charset, format); case 1: return readFormat1Encoding(dataInput, charset, format); default: throw new IllegalArgumentException(); } }
/** * Read the FDSelect Data according to the format. * @param dataInput * @param nGlyphs * @param ros * @return the FDSelect data * @throws IOException */ private static FDSelect readFDSelect(CFFDataInput dataInput, int nGlyphs, CFFCIDFont ros) throws IOException { int format = dataInput.readCard8(); switch (format) { case 0: return readFormat0FDSelect(dataInput, format, nGlyphs, ros); case 3: return readFormat3FDSelect(dataInput, format, nGlyphs, ros); default: throw new IllegalArgumentException(); } }
private void readSupplement(CFFDataInput dataInput, CFFBuiltInEncoding encoding) throws IOException { encoding.nSups = dataInput.readCard8(); encoding.supplement = new CFFBuiltInEncoding.Supplement[encoding.nSups]; for (int i = 0; i < encoding.supplement.length; i++) { CFFBuiltInEncoding.Supplement supplement = new CFFBuiltInEncoding.Supplement(); supplement.code = dataInput.readCard8(); supplement.sid = dataInput.readSID(); supplement.name = readString(supplement.sid); encoding.supplement[i] = supplement; encoding.add(supplement.code, supplement.sid, readString(supplement.sid)); } }
private CFFCharset readCharset(CFFDataInput dataInput, int nGlyphs, boolean isCIDFont) throws IOException { int format = dataInput.readCard8(); switch (format) { case 0: return readFormat0Charset(dataInput, format, nGlyphs, isCIDFont); case 1: return readFormat1Charset(dataInput, format, nGlyphs, isCIDFont); case 2: return readFormat2Charset(dataInput, format, nGlyphs, isCIDFont); default: throw new IllegalArgumentException(); } }
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; }
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; }
int rangeLeft = dataInput.readCard8(); if (!isCIDFont)
/** * Read the Format 3 of the FDSelect data structure. * * @param dataInput * @param format * @param nGlyphs * @param ros * @return the Format 3 of the FDSelect data * @throws IOException */ private static Format3FDSelect readFormat3FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros) throws IOException { Format3FDSelect fdselect = new Format3FDSelect(ros); fdselect.format = format; fdselect.nbRanges = dataInput.readCard16(); fdselect.range3 = new Range3[fdselect.nbRanges]; for (int i = 0; i < fdselect.nbRanges; i++) { Range3 r3 = new Range3(); r3.first = dataInput.readCard16(); r3.fd = dataInput.readCard8(); fdselect.range3[i] = r3; } fdselect.sentinel = dataInput.readCard16(); return fdselect; }
private CFFEncoding readEncoding(CFFDataInput dataInput, CFFCharset charset) throws IOException { int format = dataInput.readCard8(); int baseFormat = format & 0x7f; switch (baseFormat) { case 0: return readFormat0Encoding(dataInput, charset, format); case 1: return readFormat1Encoding(dataInput, charset, format); default: throw new IllegalArgumentException(); } }
private CFFEncoding readEncoding(CFFDataInput dataInput, CFFCharset charset) throws IOException { int format = dataInput.readCard8(); int baseFormat = format & 0x7f; switch (baseFormat) { case 0: return readFormat0Encoding(dataInput, charset, format); case 1: return readFormat1Encoding(dataInput, charset, format); default: throw new IllegalArgumentException(); } }
private Format1Encoding readFormat1Encoding(int format, int numEntries) throws IOException { Format1Encoding newEncoding = new Format1Encoding(); newEncoding.setFormat(format); newEncoding.setNumEntries(numEntries); Map<Integer, Integer> ranges = new LinkedHashMap<Integer, Integer>(); for (int i = 0; i < numEntries; i++) { int first = cffData.readCard8(); int left = cffData.readCard8(); ranges.put(first, left); } newEncoding.setRanges(ranges); return newEncoding; }
private int getSIDFromGIDFormat(int gid, int format) throws IOException { int glyphCount = 0; while (true) { int oldGlyphCount = glyphCount; int start = cffData.readSID(); glyphCount += ((format == 1) ? cffData.readCard8() : cffData.readCard16()) + 1; if (gid <= glyphCount) { return start + (gid - oldGlyphCount) - 1; } } }
private void readSupplement(CFFDataInput dataInput, CFFBuiltInEncoding encoding) throws IOException { encoding.nSups = dataInput.readCard8(); encoding.supplement = new CFFBuiltInEncoding.Supplement[encoding.nSups]; for (int i = 0; i < encoding.supplement.length; i++) { CFFBuiltInEncoding.Supplement supplement = new CFFBuiltInEncoding.Supplement(); supplement.code = dataInput.readCard8(); supplement.sid = dataInput.readSID(); supplement.name = readString(supplement.sid); encoding.supplement[i] = supplement; encoding.add(supplement.code, supplement.sid, readString(supplement.sid)); } }
private void readSupplement(CFFDataInput dataInput, CFFBuiltInEncoding encoding) throws IOException { encoding.nSups = dataInput.readCard8(); encoding.supplement = new CFFBuiltInEncoding.Supplement[encoding.nSups]; for (int i = 0; i < encoding.supplement.length; i++) { CFFBuiltInEncoding.Supplement supplement = new CFFBuiltInEncoding.Supplement(); supplement.code = dataInput.readCard8(); supplement.sid = dataInput.readSID(); supplement.name = readString(supplement.sid); encoding.supplement[i] = supplement; encoding.add(supplement.code, supplement.sid, readString(supplement.sid)); } }
private Format0Encoding readFormat0Encoding(int format, int numEntries) throws IOException { Format0Encoding newEncoding = new Format0Encoding(); newEncoding.setFormat(format); newEncoding.setNumEntries(numEntries); int[] codes = new int[numEntries]; for (int i = 0; i < numEntries; i++) { codes[i] = cffData.readCard8(); } newEncoding.setCodes(codes); return newEncoding; }
private Format0FDSelect readFormat0FDSelect() throws IOException { Format0FDSelect newFDs = new Format0FDSelect(); newFDs.setFormat(0); int glyphCount = charStringIndex.getNumObjects(); int[] fds = new int[glyphCount]; for (int i = 0; i < glyphCount; i++) { fds[i] = cffData.readCard8(); } newFDs.setFDIndexes(fds); return newFDs; }