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:14:11 UTC

(xmlgraphics-fop) branch temp/jgoncalves-bad-font updated (50d1e613d -> c6b73d788)

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


 discard 50d1e613d FOP-3352 Avoid exception when checking contour data on empty glyphs
     new c6b73d788 FOP-3352 Avoid exception when checking contour data on empty glyphs

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (50d1e613d)
            \
             N -- N -- N   refs/heads/temp/jgoncalves-bad-font (c6b73d788)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:


---------------------------------------------------------------------
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 c6b73d788d264442c48905da4242d87a9beae6bf
Author: Joao Goncalves <an...@gmail.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