You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ga...@apache.org on 2012/12/29 19:56:57 UTC

svn commit: r1426805 - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/complexscripts/fonts/ test/java/org/apache/fop/complexscripts/fonts/ test/resources/complexscripts/arab/data/

Author: gadams
Date: Sat Dec 29 18:56:56 2012
New Revision: 1426805

URL: http://svn.apache.org/viewvc?rev=1426805&view=rev
Log:
FOP-2178: Fix incomplete kerning when complex script features are enabled.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java
    xmlgraphics/fop/trunk/status.xml
    xmlgraphics/fop/trunk/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java
    xmlgraphics/fop/trunk/test/resources/complexscripts/arab/data/arab-001-f0.ser
    xmlgraphics/fop/trunk/test/resources/complexscripts/arab/data/arab-001-f1.ser

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java?rev=1426805&r1=1426804&r2=1426805&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java Sat Dec 29 18:56:56 2012
@@ -408,19 +408,42 @@ public class GlyphPositioningTable exten
                     if ( ( iga != null ) && ( iga.length == 2 ) ) {
                         PairValues pv = getPairValues ( ci, iga[0], iga[1] );
                         if ( pv != null ) {
+                            int offset = 0;
+                            int offsetLast = counts[0] + counts[1];
+                            // skip any ignored glyphs prior to first non-ignored glyph
+                            for ( ; offset < offsetLast; ++offset ) {
+                                if ( ! ps.isIgnoredGlyph ( offset ) ) {
+                                    break;
+                                } else {
+                                    ps.consume(1);
+                                }
+                            }
+                            // adjust first non-ignored glyph if first value isn't null
                             Value v1 = pv.getValue1();
                             if ( v1 != null ) {
-                                if ( ps.adjust(v1, 0) ) {
+                                if ( ps.adjust(v1, offset) ) {
                                     ps.setAdjusted ( true );
                                 }
+                                ps.consume(1);          // consume first non-ignored glyph
+                                ++offset;
+                            }
+                            // skip any ignored glyphs prior to second non-ignored glyph
+                            for ( ; offset < offsetLast; ++offset ) {
+                                if ( ! ps.isIgnoredGlyph ( offset ) ) {
+                                    break;
+                                } else {
+                                    ps.consume(1);
+                                }
                             }
+                            // adjust second non-ignored glyph if second value isn't null
                             Value v2 = pv.getValue2();
                             if ( v2 != null ) {
-                                if ( ps.adjust(v2, 1) ) {
+                                if ( ps.adjust(v2, offset) ) {
                                     ps.setAdjusted ( true );
                                 }
+                                ps.consume(1);          // consume second non-ignored glyph
+                                ++offset;
                             }
-                            ps.consume ( counts[0] + counts[1] );
                             applied = true;
                         }
                     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java?rev=1426805&r1=1426804&r2=1426805&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java Sat Dec 29 18:56:56 2012
@@ -448,18 +448,13 @@ public class GlyphProcessingState {
     private int[] getGlyphsForward ( int start, int count, GlyphTester ignoreTester, int[] glyphs, int[] counts ) throws IndexOutOfBoundsException {
         int counted = 0;
         int ignored = 0;
-        for ( int i = start, n = indexLast, k = 0; i < n; i++ ) {
+        for ( int i = start, n = indexLast; ( i < n ) && ( counted < count ); i++ ) {
             int gi = getGlyph ( i - index );
             if ( gi == 65535 ) {
                 ignored++;
             } else {
                 if ( ( ignoreTester == null ) || ! ignoreTester.test ( gi, getLookupFlags() ) ) {
-                    if ( k < count ) {
-                        glyphs [ k++ ] = gi;
-                        counted++;
-                    } else {
-                        break;
-                    }
+                    glyphs [ counted++ ] = gi;
                 } else {
                     ignored++;
                 }
@@ -475,18 +470,13 @@ public class GlyphProcessingState {
     private int[] getGlyphsReverse ( int start, int count, GlyphTester ignoreTester, int[] glyphs, int[] counts ) throws IndexOutOfBoundsException {
         int counted = 0;
         int ignored = 0;
-        for ( int i = start, k = 0; i >= 0; i-- ) {
+        for ( int i = start; ( i >= 0 ) && ( counted < count ); i-- ) {
             int gi = getGlyph ( i - index );
             if ( gi == 65535 ) {
                 ignored++;
             } else {
                 if ( ( ignoreTester == null ) || ! ignoreTester.test ( gi, getLookupFlags() ) ) {
-                    if ( k < count ) {
-                        glyphs [ k++ ] = gi;
-                        counted++;
-                    } else {
-                        break;
-                    }
+                    glyphs [ counted++ ] = gi;
                 } else {
                     ignored++;
                 }
@@ -560,6 +550,41 @@ public class GlyphProcessingState {
     }
 
     /**
+     * Determine if glyph at specified offset from current position is ignored. If <code>offset</code> is
+     * negative, then test in reverse order.
+     * @param offset from current position
+     * @param ignoreTester glyph tester to use to determine which glyphs are ignored (or null, in which case none are ignored)
+     * @return true if glyph is ignored
+     * @throws IndexOutOfBoundsException if offset results in an
+     * invalid index into input glyph sequence
+     */
+    public boolean isIgnoredGlyph ( int offset, GlyphTester ignoreTester ) throws IndexOutOfBoundsException {
+        return ( ignoreTester != null ) && ignoreTester.test ( getGlyph ( offset ), getLookupFlags() );
+    }
+
+    /**
+     * Determine if glyph at specified offset from current position is ignored. If <code>offset</code> is
+     * negative, then test in reverse order.
+     * @param offset from current position
+     * @return true if glyph is ignored
+     * @throws IndexOutOfBoundsException if offset results in an
+     * invalid index into input glyph sequence
+     */
+    public boolean isIgnoredGlyph ( int offset ) throws IndexOutOfBoundsException {
+        return isIgnoredGlyph ( offset, ignoreDefault );
+    }
+
+    /**
+     * Determine if glyph at current position is ignored.
+     * @return true if glyph is ignored
+     * @throws IndexOutOfBoundsException if offset results in an
+     * invalid index into input glyph sequence
+     */
+    public boolean isIgnoredGlyph() throws IndexOutOfBoundsException {
+        return isIgnoredGlyph ( getPosition() );
+    }
+
+    /**
      * Determine number of glyphs available starting at specified offset from current position. If
      * <code>reverseOrder</code> is true, then search backwards in input glyph sequence.
      * @param offset from current position

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1426805&r1=1426804&r2=1426805&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sat Dec 29 18:56:56 2012
@@ -59,6 +59,9 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="GA" type="fix" fixes-bug="FOP-2178">
+        Fix incomplete kerning when complex script features are enabled.
+      </action>
       <action context="Renderers" dev="CB" type="fix" fixes-bug="FOP-2173" due-to="Simon Steiner">
         Invalid Postscript created if more than 255 characters in a custom font are used within 
         SVG when generating Postscript

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java?rev=1426805&r1=1426804&r2=1426805&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/complexscripts/fonts/GPOSTestCase.java Sat Dec 29 18:56:56 2012
@@ -298,7 +298,7 @@ public class GPOSTestCase implements Scr
                 {
                     new String[] { "zain", "fatha", "kafinitial" },
                     new int[][] {
-                        { 0, 0, 0, 0 }, { 0, 250, 0, 0 }, { 0, 0, 0, 0 }
+                        { 0, 250, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
                     }
                 },
           },

Modified: xmlgraphics/fop/trunk/test/resources/complexscripts/arab/data/arab-001-f0.ser
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/resources/complexscripts/arab/data/arab-001-f0.ser?rev=1426805&r1=1426804&r2=1426805&view=diff
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/fop/trunk/test/resources/complexscripts/arab/data/arab-001-f1.ser
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/resources/complexscripts/arab/data/arab-001-f1.ser?rev=1426805&r1=1426804&r2=1426805&view=diff
==============================================================================
Binary files - no diff available.



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org