diff options
author | Simon Steiner <ssteiner@apache.org> | 2022-06-06 12:56:20 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2022-06-06 12:56:20 +0000 |
commit | c243ae04820e864bea349f9f0e838b83799bf956 (patch) | |
tree | c9cf24a7dd8092534a7cd9b4ee4da7ea612da0f3 /fop-core/src | |
parent | be072979e59b322f7d8d5c828acfe9c6a3eb887e (diff) | |
download | xmlgraphics-fop-c243ae04820e864bea349f9f0e838b83799bf956.tar.gz xmlgraphics-fop-c243ae04820e864bea349f9f0e838b83799bf956.zip |
FOP-3074: Reorder glyphs based on gpa value
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1901699 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src')
4 files changed, 30 insertions, 9 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java index 16c130a3e..0de1a2058 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/DefaultScriptProcessor.java @@ -88,7 +88,8 @@ public class DefaultScriptProcessor extends ScriptProcessor { for (int i = 0; i < ng; i++) { int gid = ga [ i ]; int gw = unscaledWidths [ i ]; - if (isReorderedMark(gdef, ga, unscaledWidths, i)) { + int[] pa = (gpa != null) ? gpa[i] : null; + if (isReorderedMark(gdef, ga, unscaledWidths, i, pa)) { nm++; } } @@ -106,7 +107,7 @@ public class DefaultScriptProcessor extends ScriptProcessor { int gid = ga [ i ]; int[] pa = (gpa != null) ? gpa [ i ] : null; CharAssociation ca = aa [ i ]; - if (isReorderedMark(gdef, ga, unscaledWidths, i)) { + if (isReorderedMark(gdef, ga, unscaledWidths, i, pa)) { nga [ k ] = gid; naa [ k ] = ca; if (npa != null) { @@ -150,8 +151,9 @@ public class DefaultScriptProcessor extends ScriptProcessor { } } - protected boolean isReorderedMark(GlyphDefinitionTable gdef, int[] glyphs, int[] unscaledWidths, int index) { - return gdef.isGlyphClass(glyphs[index], GlyphDefinitionTable.GLYPH_CLASS_MARK); + protected boolean isReorderedMark(GlyphDefinitionTable gdef, int[] glyphs, int[] unscaledWidths, int index, int[] pa) { + pa = (pa != null) ? pa : new int[1]; + return gdef.isGlyphClass(glyphs[index], GlyphDefinitionTable.GLYPH_CLASS_MARK) && pa[0] != 0; } } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/HebrewScriptProcessor.java b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/HebrewScriptProcessor.java index d772fe337..a2915ca24 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/HebrewScriptProcessor.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/HebrewScriptProcessor.java @@ -25,7 +25,9 @@ public class HebrewScriptProcessor extends DefaultScriptProcessor { super(script); } - protected boolean isReorderedMark(GlyphDefinitionTable gdef, int[] glyphs, int[] unscaledWidths, int index) { + @Override + protected boolean isReorderedMark( + GlyphDefinitionTable gdef, int[] glyphs, int[] unscaledWidths, int index, int[] pa) { return gdef.isGlyphClass(glyphs[index], GlyphDefinitionTable.GLYPH_CLASS_MARK) && (unscaledWidths[index] != 0); } } diff --git a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ThaiScriptProcessor.java b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ThaiScriptProcessor.java index c681861e9..4c293d41d 100644 --- a/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ThaiScriptProcessor.java +++ b/fop-core/src/main/java/org/apache/fop/complexscripts/scripts/ThaiScriptProcessor.java @@ -25,7 +25,9 @@ public class ThaiScriptProcessor extends DefaultScriptProcessor { super(script); } - protected boolean isReorderedMark(GlyphDefinitionTable gdef, int[] glyphs, int[] unscaledWidths, int index) { + @Override + protected boolean isReorderedMark( + GlyphDefinitionTable gdef, int[] glyphs, int[] unscaledWidths, int index, int[] pa) { return gdef.isGlyphClass(glyphs[index], GlyphDefinitionTable.GLYPH_CLASS_MARK); } } diff --git a/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/DefaultScriptTestCase.java b/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/DefaultScriptTestCase.java index 96d3ba04f..b8357068b 100644 --- a/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/DefaultScriptTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/DefaultScriptTestCase.java @@ -35,8 +35,24 @@ import org.apache.fop.fonts.MultiByteFont; public class DefaultScriptTestCase { @Test - public void testProcessor() { + public void testProcessorReorder() { String in = "\u00F6\u0323"; + int[][] gpa = new int[2][1]; + gpa[0][0] = 1; + gpa[1][0] = 1; + String actual = getFont().reorderCombiningMarks(in, gpa, OTFScript.DEFAULT, null, null).toString(); + Assert.assertEquals(actual.charAt(0), 803); + } + + @Test + public void testProcessorNoReorder() { + String in = "\u00F6\u0323"; + int[][] gpa = new int[2][1]; + String actual = getFont().reorderCombiningMarks(in, gpa, OTFScript.DEFAULT, null, null).toString(); + Assert.assertEquals(actual.charAt(0), 57344); + } + + private MultiByteFont getFont() { MultiByteFont font = new MultiByteFont(null, null); font.setWidthArray(new int[0]); font.setCMap(new CMapSegment[]{new CMapSegment('\u0323', '\u0323', 1)}); @@ -46,7 +62,6 @@ public class DefaultScriptTestCase { GlyphClassTable.createClassTable(entries), null); font.setGDEF( new GlyphDefinitionTable(Collections.singletonList(table), new HashMap<String, ScriptProcessor>())); - String actual = font.reorderCombiningMarks(in, null, OTFScript.DEFAULT, null, null).toString(); - Assert.assertEquals(actual.charAt(0), 803); + return font; } } |