You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by jg...@apache.org on 2026/10/05 17:13:14 UTC
(xmlgraphics-fop) branch temp/jgoncalves-bad-font created (now 50d1e613d)
This is an automated email from the ASF dual-hosted git repository.
joao12021996 pushed a change to branch temp/jgoncalves-bad-font
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-fop.git
at 50d1e613d FOP-3352 Avoid exception when checking contour data on empty glyphs
This branch includes the following new commits:
new 50d1e613d FOP-3352 Avoid exception when checking contour data on empty glyphs
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org
(xmlgraphics-fop) 01/01: FOP-3352 Avoid exception when checking contour data on empty glyphs
Posted by jg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
joao12021996 pushed a commit to branch temp/jgoncalves-bad-font
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-fop.git
commit 50d1e613d701868208edfe8c9460599bed1adce7
Author: Joao Andre Goncalves <jg...@smartcommunications.com>
AuthorDate: Mon Oct 5 12:12:47 2026 -0500
FOP-3352 Avoid exception when checking contour data on empty glyphs
---
.../org/apache/fop/fonts/truetype/GlyfTable.java | 15 +++++++++++++++
.../apache/fop/fonts/truetype/GlyfTableTestCase.java | 20 ++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/GlyfTable.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/GlyfTable.java
index c5380b82e..9e44ee18d 100644
--- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/GlyfTable.java
+++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/GlyfTable.java
@@ -35,6 +35,8 @@ public class GlyfTable {
private final long tableOffset;
+ private final long tableLength;
+
private final Set<Long> remappedComposites;
protected final Map<Integer, Integer> subset;
@@ -51,6 +53,7 @@ public class GlyfTable {
Map<Integer, Integer> glyphs) throws IOException {
mtxTab = metrics;
tableOffset = dirTableEntry.getOffset();
+ tableLength = dirTableEntry.getLength();
remappedComposites = new HashSet<Long>();
this.subset = glyphs;
this.in = in;
@@ -203,10 +206,22 @@ public class GlyfTable {
}
public boolean isComposite(int indexInOriginal) throws IOException {
+ if (isLastGlyphEmpty(indexInOriginal)) {
+ return false;
+ }
+
int numberOfContours = in.readTTFShort(tableOffset + mtxTab[indexInOriginal].getOffset());
return numberOfContours < 0;
}
+ private boolean isLastGlyphEmpty(int indexInOriginal) {
+ if (indexInOriginal != mtxTab.length - 1) {
+ return false;
+ }
+
+ return tableLength == mtxTab[indexInOriginal].getOffset();
+ }
+
/**
* Reads a composite glyph at a given index and retrieves all the glyph indices of contingent
* composed glyphs.
diff --git a/fop-core/src/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java
index 0ca861ea3..efa2dafcb 100644
--- a/fop-core/src/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/fonts/truetype/GlyfTableTestCase.java
@@ -29,6 +29,7 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@@ -131,6 +132,25 @@ public class GlyfTableTestCase {
assertArrayEquals(expected, composedIndices);
}
+ @Test
+ public void testIsCompositeOnEmptyGlyph() throws IOException {
+ int glyphLength = 12;
+
+ OFMtxEntry glyph = new OFMtxEntry();
+ glyph.setOffset(glyphLength);
+
+ OFMtxEntry[] mtx = new OFMtxEntry[] {glyph};
+ OFDirTabEntry dirTab = new OFDirTabEntry(0, glyphLength);
+
+ byte[] glyf = new byte[glyphLength];
+ glyf[0] = 0x00;
+
+ FontFileReader reader = new FontFileReader(new ByteArrayInputStream(glyf));
+ GlyfTable glyfTable = new GlyfTable(reader, mtx, dirTab, new HashMap<Integer, Integer>());
+
+ assertFalse("An empty glyph must not be reported as composite", glyfTable.isComposite(0));
+ }
+
private int[] setupTest(int... glyphIndices) throws IOException {
Map<Integer, Integer> glyphs = new HashMap<Integer, Integer>();
int index = 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org