Author: ssteiner
Date: Fri Aug  5 07:04:37 2022
New Revision: 1903233

URL: http://svn.apache.org/viewvc?rev=1903233&view=rev
Log:
FOP-3077: Use all rulesets for glyph substitution

Modified:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java?rev=1903233&r1=1903232&r2=1903233&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
 Fri Aug  5 07:04:37 2022
@@ -1146,19 +1146,20 @@ public class GlyphSubstitutionTable exte
             assert (rv != null) && (rv.length > 0);
             assert rsa != null;
             if (rsa.length > 0) {
-                RuleSet rs = rsa [ 0 ];
-                if (rs != null) {
-                    Rule[] ra = rs.getRules();
-                    for (Rule r : ra) {
-                        if ((r != null) && (r instanceof 
ChainedClassSequenceRule)) {
-                            ChainedClassSequenceRule cr = 
(ChainedClassSequenceRule) r;
-                            int[] ica = cr.getClasses(icdt.getClassIndex(gi, 
ss.getClassMatchSet(gi)));
-                            if (matches(ss, icdt, ica, 0, rv)) {
-                                int[] bca = cr.getBacktrackClasses();
-                                if (matches(ss, bcdt, bca, -1, null)) {
-                                    int[] lca = cr.getLookaheadClasses();
-                                    if (matches(ss, lcdt, lca, rv[0], null)) {
-                                        return r.getLookups();
+                for (RuleSet rs : rsa) {
+                    if (rs != null) {
+                        Rule[] ra = rs.getRules();
+                        for (Rule r : ra) {
+                            if ((r != null) && (r instanceof 
ChainedClassSequenceRule)) {
+                                ChainedClassSequenceRule cr = 
(ChainedClassSequenceRule) r;
+                                int[] ica = 
cr.getClasses(icdt.getClassIndex(gi, ss.getClassMatchSet(gi)));
+                                if (matches(ss, icdt, ica, 0, rv)) {
+                                    int[] bca = cr.getBacktrackClasses();
+                                    if (matches(ss, bcdt, bca, -1, null)) {
+                                        int[] lca = cr.getLookaheadClasses();
+                                        if (matches(ss, lcdt, lca, rv[0], 
null)) {
+                                            return r.getLookups();
+                                        }
                                     }
                                 }
                             }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java?rev=1903233&r1=1903232&r2=1903233&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java
 Fri Aug  5 07:04:37 2022
@@ -30,13 +30,15 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
 import org.apache.fop.complexscripts.fonts.GlyphTable.LookupTable;
 import org.apache.fop.complexscripts.fonts.ttx.TTXFile;
 import org.apache.fop.complexscripts.util.GlyphContextTester;
 import org.apache.fop.complexscripts.util.GlyphSequence;
 import org.apache.fop.complexscripts.util.ScriptContextTester;
-
-// CSOFF: LineLength
+import org.apache.fop.fonts.MultiByteFont;
+import org.apache.fop.fonts.truetype.OFFontLoader;
 
 public class GSUBTestCase implements ScriptContextTester, GlyphContextTester {
 
@@ -120,7 +122,8 @@ public class GSUBTestCase implements Scr
                         String[] ogia = ti[1];                  // output 
glyph id array
                         GlyphSequence igs = tf.getGlyphSequence(igia);
                         GlyphSequence ogs = tf.getGlyphSequence(ogia);
-                        GlyphSequence tgs = 
GlyphSubstitutionSubtable.substitute(igs, script, language, feature, sta, sct);
+                        GlyphSequence tgs =
+                                GlyphSubstitutionSubtable.substitute(igs, 
script, language, feature, sta, sct);
                         assertSameGlyphs(ogs, tgs);
                     }
                 }
@@ -151,7 +154,8 @@ public class GSUBTestCase implements Scr
         }
     }
 
-    private GlyphSubstitutionSubtable[] 
findGSUBSubtables(GlyphSubstitutionTable gsub, String script, String language, 
String feature, String lid) {
+    private GlyphSubstitutionSubtable[] findGSUBSubtables(
+            GlyphSubstitutionTable gsub, String script, String language, 
String feature, String lid) {
         LookupTable lt = gsub.getLookupTable(lid);
         if (lt != null) {
             return (GlyphSubstitutionSubtable[]) lt.getSubtables();
@@ -191,4 +195,17 @@ public class GSUBTestCase implements Scr
         GlyphClassTable classTable = 
GlyphClassTable.createClassTable(Collections.singletonList(coverageTable));
         assertNotNull(classTable);
     }
+
+    @Test
+    public void testSubRuleSets() throws Exception {
+        File fontfile = new 
File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
+        InternalResourceResolver resourceResolver =
+                
ResourceResolverFactory.createDefaultInternalResourceResolver(new 
File(".").toURI());
+        OFFontLoader fontLoader = new OFFontLoader(fontfile.toURI(), 
resourceResolver);
+        MultiByteFont font = (MultiByteFont) fontLoader.getFont();
+        String in = "\u006A\u0301";
+        String out = "\u0237\u0301";
+        String sub = font.performSubstitution(in, "latn", "dflt", null, 
false).toString();
+        assertEquals(sub, out);
+    }
 }



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

Reply via email to