"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

GlyphTable.java  (pdfbox-2.0.23-src):GlyphTable.java  (pdfbox-2.0.24-src)
skipping to change at line 85 skipping to change at line 85
// we don't actually read the complete table here because it can contain tens of thousands of glyphs // we don't actually read the complete table here because it can contain tens of thousands of glyphs
this.data = data; this.data = data;
initialized = true; initialized = true;
} }
/** /**
* Returns all glyphs. This method can be very slow. * Returns all glyphs. This method can be very slow.
* *
* @throws IOException If there is an error reading the data. * @throws IOException If there is an error reading the data.
* @deprecated use {@link #getGlyph(int)} instead. This will be removed in 3
.0. If you need this
* method, please create an issue in JIRA.
*/ */
@Deprecated
public GlyphData[] getGlyphs() throws IOException public GlyphData[] getGlyphs() throws IOException
{ {
// PDFBOX-4219: synchronize on data because it is accessed by several th reads // PDFBOX-4219: synchronize on data because it is accessed by several th reads
// when PDFBox is accessing a standard 14 font for the first time // when PDFBox is accessing a standard 14 font for the first time
synchronized (data) synchronized (data)
{ {
// the glyph offsets // the glyph offsets
long[] offsets = loca.getOffsets(); long[] offsets = loca.getOffsets();
// the end of the glyph table // the end of the glyph table
skipping to change at line 164 skipping to change at line 167
if (gid < 0 || gid >= numGlyphs) if (gid < 0 || gid >= numGlyphs)
{ {
return null; return null;
} }
if (glyphs != null && glyphs[gid] != null) if (glyphs != null && glyphs[gid] != null)
{ {
return glyphs[gid]; return glyphs[gid];
} }
GlyphData glyph;
// PDFBOX-4219: synchronize on data because it is accessed by several th reads // PDFBOX-4219: synchronize on data because it is accessed by several th reads
// when PDFBox is accessing a standard 14 font for the first time // when PDFBox is accessing a standard 14 font for the first time
synchronized (data) synchronized (data)
{ {
// read a single glyph // read a single glyph
long[] offsets = loca.getOffsets(); long[] offsets = loca.getOffsets();
if (offsets[gid] == offsets[gid + 1]) if (offsets[gid] == offsets[gid + 1])
{ {
// no outline // no outline
return null; // PDFBOX-5135: can't return null, must return an empty glyph be
cause
// sometimes this is used in a composite glyph.
glyph = new GlyphData();
glyph.initEmptyData();
} }
else
{
// save
long currentPosition = data.getCurrentPosition();
// save data.seek(getOffset() + offsets[gid]);
long currentPosition = data.getCurrentPosition();
data.seek(getOffset() + offsets[gid]);
GlyphData glyph = getGlyphData(gid); glyph = getGlyphData(gid);
// restore // restore
data.seek(currentPosition); data.seek(currentPosition);
}
if (glyphs != null && glyphs[gid] == null && cached < MAX_CACHED_GLY PHS) if (glyphs != null && glyphs[gid] == null && cached < MAX_CACHED_GLY PHS)
{ {
glyphs[gid] = glyph; glyphs[gid] = glyph;
++cached; ++cached;
} }
return glyph; return glyph;
} }
} }
 End of changes. 8 change blocks. 
8 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)