aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core/src
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2022-08-05 07:04:37 +0000
committerSimon Steiner <ssteiner@apache.org>2022-08-05 07:04:37 +0000
commita68ad9321fa53bb4704ecf70f257e6aa40853d85 (patch)
treec2363477a86abaae4f964c8f89bbbeb002f9e585 /fop-core/src
parent5818e16bd18384d5f8fe5e3fb82795b1fb96948e (diff)
downloadxmlgraphics-fop-a68ad9321fa53bb4704ecf70f257e6aa40853d85.tar.gz
xmlgraphics-fop-a68ad9321fa53bb4704ecf70f257e6aa40853d85.zip
FOP-3077: Use all rulesets for glyph substitution
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1903233 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src')
-rw-r--r--fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java27
-rw-r--r--fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java25
2 files changed, 35 insertions, 17 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
index e4065712d..43a3bcb4a 100644
--- a/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
+++ b/fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java
@@ -1146,19 +1146,20 @@ public class GlyphSubstitutionTable extends GlyphTable {
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();
+ }
}
}
}
diff --git a/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java b/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java
index 5519240c6..ad43b920f 100644
--- a/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/complexscripts/fonts/GSUBTestCase.java
@@ -30,13 +30,15 @@ import static org.junit.Assert.assertNotNull;
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 ScriptContextTester, GlyphContextTester {
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 ScriptContextTester, GlyphContextTester {
}
}
- 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 ScriptContextTester, GlyphContextTester {
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);
+ }
}