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();
+ }
}
}
}
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 {
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);
}
}
}
}
- 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();
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);
+ }
}