Hi all (and especially Jeremias or other font experts),

This bug seems to be due to the way we generate the 'loca' table in the embedded font subsets (CID fonts). In fact, it has offsets to the correct glyph descriptions, but the offsets are not in ascending order. Since it seems that the length of the glyph description is found by subtracting the offset to the glyph from the offset for the next glyph in the loca table, this does not work. For Acrobat, as long as there actually _is_ a glyph description, it seems to work anyway. However for space characters, there is no glyph. Acrobat thinks there is because of the offset, so it draws the glyph that _is_ stored at the offset.

This only shows up with SVG text because it has embedded spaces. The spaces in normal text are generally turned into explicit offsets and not drawn as such.

The attached diff fixes the bug; though there are perhaps more elegant ways to do it. Does anyone see anything wrong with this idea?
If not, I'll commit asap.


In fact, using this fix, xpdf now also works with embedded fonts, whereas before it produced garbage.

Regards,
Karen Lease

(Lately very overworked) Senior Software Developer
SPX Valley Forge
Paris/Munich

Index: org/apache/fop/fonts/TTFSubSetFile.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fonts/TTFSubSetFile.java,v
retrieving revision 1.5.2.2
diff -u -r1.5.2.2 TTFSubSetFile.java
--- org/apache/fop/fonts/TTFSubSetFile.java     8 Nov 2002 10:25:26 -0000       1.5.2.2
+++ org/apache/fop/fonts/TTFSubSetFile.java     19 Nov 2002 22:29:00 -0000
@@ -311,29 +311,35 @@
             pad4();
             start = currentPos;
 
+            int[] offsets = new int[glyphs.size()];
+
             for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) {
-                int glyphLength = 0;
                 Integer origIndex = (Integer)e.next();
                 Integer subsetIndex = (Integer)glyphs.get(origIndex);
+                offsets[subsetIndex.intValue()] = origIndex.intValue();
+            }
 
+            for (int i=0;i<offsets.length;i++) {
+                int glyphLength = 0;
                 int nextOffset = 0;
-                if (origIndex.intValue() >= (mtx_tab.length - 1))
+                int origGlyphIndex = offsets[i];
+                if (origGlyphIndex >= (mtx_tab.length - 1))
                     nextOffset = (int)lastLoca;
                 else
                     nextOffset =
-                        (int)mtx_tab[origIndex.intValue() + 1].offset;
+                        (int)mtx_tab[origGlyphIndex + 1].offset;
 
                 glyphLength = nextOffset
-                              - (int)mtx_tab[origIndex.intValue()].offset;
+                              - (int)mtx_tab[origGlyphIndex].offset;
 
                 // Copy glyph
-                System.arraycopy(in.getBytes((int)entry.offset + 
(int)mtx_tab[origIndex.intValue()].offset, glyphLength),
+                System.arraycopy(in.getBytes((int)entry.offset +
+                                             (int)mtx_tab[origGlyphIndex].offset, 
+glyphLength),
                                  0, output, currentPos, glyphLength);
 
 
                 // Update loca table
-                writeULong(locaOffset + subsetIndex.intValue() * 4,
-                           currentPos - start);
+                writeULong(locaOffset + i * 4, currentPos - start);
                 if ((currentPos - start + glyphLength) > endOffset)
                     endOffset = (currentPos - start + glyphLength);
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to