/** * 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 IOException If there is an error reading the data. */ @Override public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { loca = ttf.getIndexToLocation(); numGlyphs = ttf.getNumberOfGlyphs(); if (numGlyphs < MAX_CACHE_SIZE) { // don't cache the huge fonts to save memory glyphs = new GlyphData[numGlyphs]; } // we don't actually read the complete table here because it can contain tens of thousands of glyphs this.data = data; initialized = true; }
if (gid > ttf.getNumberOfGlyphs())
/** * Build widths with Identity CIDToGIDMap (for embedding full font). */ private void buildWidths(COSDictionary cidFont) throws IOException { int cidMax = ttf.getNumberOfGlyphs(); int[] gidwidths = new int[cidMax * 2]; for (int cid = 0; cid < cidMax; cid++) { gidwidths[cid * 2] = cid; gidwidths[cid * 2 + 1] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); } cidFont.setItem(COSName.W, getWidths(gidwidths)); }
if (cid < ttf.getNumberOfGlyphs())
int numGlyphs = ttf.getNumberOfGlyphs(); offsets = new long[ numGlyphs +1]; for( int i=0; i<numGlyphs+1; i++ )
/** * 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 IOException If there is an error reading the data. */ @Override public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { @SuppressWarnings({"unused", "squid:S1854", "squid:S1481"}) int version = data.readUnsignedShort(); int numberOfTables = data.readUnsignedShort(); cmaps = new CmapSubtable[numberOfTables]; for (int i = 0; i < numberOfTables; i++) { CmapSubtable cmap = new CmapSubtable(); cmap.initData(data); cmaps[i] = cmap; } for (int i = 0; i < numberOfTables; i++) { cmaps[i].initSubtable(this, ttf.getNumberOfGlyphs(), data); } initialized = true; }
int[] glyphNameIndex = new int[ttf.getNumberOfGlyphs()]; for (int i = 0; i < glyphNameIndex.length; i++)
int numGlyphs = ttf.getNumberOfGlyphs();
int numGlyphs = ttf.getNumberOfGlyphs();
/** * Build vertical metrics with Identity CIDToGIDMap (for embedding full font). */ private void buildVerticalMetrics(COSDictionary cidFont) throws IOException { if (!buildVerticalHeader(cidFont)) { return; } int cidMax = ttf.getNumberOfGlyphs(); int[] gidMetrics = new int[cidMax * 4]; for (int cid = 0; cid < cidMax; cid++) { GlyphData glyph = ttf.getGlyph().getGlyph(cid); if (glyph == null) { gidMetrics[cid * 4] = Integer.MIN_VALUE; } else { gidMetrics[cid * 4] = cid; gidMetrics[cid * 4 + 1] = ttf.getVerticalMetrics().getAdvanceHeight(cid); gidMetrics[cid * 4 + 2] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); gidMetrics[cid * 4 + 3] = glyph.getYMaximum() + ttf.getVerticalMetrics().getTopSideBearing(cid); } } cidFont.setItem(COSName.W2, getVerticalMetrics(gidMetrics)); }
/** * 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 IOException If there is an error reading the data. */ @Override public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { loca = ttf.getIndexToLocation(); numGlyphs = ttf.getNumberOfGlyphs(); if (numGlyphs < MAX_CACHE_SIZE) { // don't cache the huge fonts to save memory glyphs = new GlyphData[numGlyphs]; } // we don't actually read the complete table here because it can contain tens of thousands of glyphs this.data = data; 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 IOException If there is an error reading the data. */ @Override public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { loca = ttf.getIndexToLocation(); numGlyphs = ttf.getNumberOfGlyphs(); if (numGlyphs < MAX_CACHE_SIZE) { // don't cache the huge fonts to save memory glyphs = new GlyphData[numGlyphs]; } // we don't actually read the complete table here because it can contain tens of thousands of glyphs this.data = data; initialized = true; }
if (gid > ttf.getNumberOfGlyphs())
/** * Build widths with Identity CIDToGIDMap (for embedding full font). */ private void buildWidths(COSDictionary cidFont) throws IOException { int cidMax = ttf.getNumberOfGlyphs(); int[] gidwidths = new int[cidMax * 2]; for (int cid = 0; cid < cidMax; cid++) { gidwidths[cid * 2] = cid; gidwidths[cid * 2 + 1] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); } cidFont.setItem(COSName.W, getWidths(gidwidths)); }
/** * Build widths with Identity CIDToGIDMap (for embedding full font). */ private void buildWidths(COSDictionary cidFont) throws IOException { int cidMax = ttf.getNumberOfGlyphs(); int[] gidwidths = new int[cidMax * 2]; for (int cid = 0; cid < cidMax; cid++) { gidwidths[cid * 2] = cid; gidwidths[cid * 2 + 1] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); } cidFont.setItem(COSName.W, getWidths(gidwidths)); }
/** * 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 IOException If there is an error reading the data. */ public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { HeaderTable head = ttf.getHeader(); int numGlyphs = ttf.getNumberOfGlyphs(); offsets = new long[ numGlyphs +1]; for( int i=0; i<numGlyphs+1; i++ ) { if( head.getIndexToLocFormat() == SHORT_OFFSETS ) { offsets[i] = data.readUnsignedShort() * 2; } else if( head.getIndexToLocFormat() == LONG_OFFSETS ) { offsets[i] = data.readUnsignedInt(); } else { throw new IOException( "Error:TTF.loca unknown offset format."); } } 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 IOException If there is an error reading the data. */ public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { HeaderTable head = ttf.getHeader(); int numGlyphs = ttf.getNumberOfGlyphs(); offsets = new long[ numGlyphs +1]; for( int i=0; i<numGlyphs+1; i++ ) { if( head.getIndexToLocFormat() == SHORT_OFFSETS ) { offsets[i] = data.readUnsignedShort() * 2; } else if( head.getIndexToLocFormat() == LONG_OFFSETS ) { offsets[i] = data.readUnsignedInt(); } else { throw new IOException( "Error:TTF.loca unknown offset format."); } } 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 IOException If there is an error reading the data. */ public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { int version = data.readUnsignedShort(); int numberOfTables = data.readUnsignedShort(); cmaps = new CmapSubtable[numberOfTables]; for (int i = 0; i < numberOfTables; i++) { CmapSubtable cmap = new CmapSubtable(); cmap.initData(data); cmaps[i] = cmap; } for (int i = 0; i < numberOfTables; i++) { cmaps[i].initSubtable(this, ttf.getNumberOfGlyphs(), data); } 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 IOException If there is an error reading the data. */ @Override public void read(TrueTypeFont ttf, TTFDataStream data) throws IOException { @SuppressWarnings({"unused", "squid:S1854", "squid:S1481"}) int version = data.readUnsignedShort(); int numberOfTables = data.readUnsignedShort(); cmaps = new CmapSubtable[numberOfTables]; for (int i = 0; i < numberOfTables; i++) { CmapSubtable cmap = new CmapSubtable(); cmap.initData(data); cmaps[i] = cmap; } for (int i = 0; i < numberOfTables; i++) { cmaps[i].initSubtable(this, ttf.getNumberOfGlyphs(), data); } initialized = true; }
/** * Build vertical metrics with Identity CIDToGIDMap (for embedding full font). */ private void buildVerticalMetrics(COSDictionary cidFont) throws IOException { if (!buildVerticalHeader(cidFont)) { return; } int cidMax = ttf.getNumberOfGlyphs(); int[] gidMetrics = new int[cidMax * 4]; for (int cid = 0; cid < cidMax; cid++) { GlyphData glyph = ttf.getGlyph().getGlyph(cid); if (glyph == null) { gidMetrics[cid * 4] = Integer.MIN_VALUE; } else { gidMetrics[cid * 4] = cid; gidMetrics[cid * 4 + 1] = ttf.getVerticalMetrics().getAdvanceHeight(cid); gidMetrics[cid * 4 + 2] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); gidMetrics[cid * 4 + 3] = glyph.getYMaximum() + ttf.getVerticalMetrics().getTopSideBearing(cid); } } cidFont.setItem(COSName.W2, getVerticalMetrics(gidMetrics)); }