diff options
author | Simon Steiner <ssteiner@apache.org> | 2022-06-16 15:38:26 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2022-06-16 15:38:26 +0000 |
commit | bad28da68ae8ff3a9b530d20648395b626c0c7b9 (patch) | |
tree | 220bea2c5459c89ba67dd65a6c50f9a9151601c6 /fop-core/src | |
parent | 6a0eaa083e7831582b655c5c8e8a4fbb1a2d2aa3 (diff) | |
download | xmlgraphics-fop-bad28da68ae8ff3a9b530d20648395b626c0c7b9.tar.gz xmlgraphics-fop-bad28da68ae8ff3a9b530d20648395b626c0c7b9.zip |
FOP-3078: Fix position of macron glyph
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1901980 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src')
2 files changed, 35 insertions, 35 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 0de1a2058..0dcde599b 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 @@ -103,45 +103,29 @@ public class DefaultScriptProcessor extends ScriptProcessor { CharAssociation ba = null; int bg = -1; int[] bpa = null; + int[] order = new int[ng]; for (int i = 0; i < ng; i++) { - int gid = ga [ i ]; - int[] pa = (gpa != null) ? gpa [ i ] : null; - CharAssociation ca = aa [ i ]; + order[i] = i; + } + for (int i = 1; i < ng; i++) { + int[] pa = (gpa != null) ? gpa[i] : null; if (isReorderedMark(gdef, ga, unscaledWidths, i, pa)) { - nga [ k ] = gid; - naa [ k ] = ca; - if (npa != null) { - npa [ k ] = pa; - } - k++; - } else { - if (bg != -1) { - nga [ k ] = bg; - naa [ k ] = ba; - if (npa != null) { - npa [ k ] = bpa; + for (int j = i; j > 0; j--) { + switchGlyphs(order, j); + int[] paj = (gpa != null) ? gpa[order[j]] : null; + if (!isMarkNotReordered(gdef, ga, order[j], paj)) { + break; } - k++; - bg = -1; - ba = null; - bpa = null; - } - if (bg == -1) { - bg = gid; - ba = ca; - bpa = pa; } } } - if (bg != -1) { - nga [ k ] = bg; - naa [ k ] = ba; - if (npa != null) { - npa [ k ] = bpa; + for (int i = 0; i < ng; i++) { + nga[i] = ga[order[i]]; + naa[i] = aa[order[i]]; + if (gpa != null) { + npa[i] = gpa[order[i]]; } - k++; } - assert k == ng; if (npa != null) { System.arraycopy(npa, 0, gpa, 0, ng); } @@ -151,9 +135,22 @@ public class DefaultScriptProcessor extends ScriptProcessor { } } + private static void switchGlyphs(int[] order, int i) { + if (i < 1) { + throw new IllegalArgumentException(i + " must be > 0"); + } + int oi = order[i]; + order[i] = order[i - 1]; + order[i - 1] = oi; + } + 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; } + private boolean isMarkNotReordered(GlyphDefinitionTable gdef, int[] glyphs, 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/test/java/org/apache/fop/complexscripts/scripts/DefaultScriptTestCase.java b/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/DefaultScriptTestCase.java index ba4ddf554..a7fec3b4e 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 @@ -54,11 +54,14 @@ public class DefaultScriptTestCase { @Test public void testProcessorReorder2() { - String in = "\u00F6\u0323"; - int[][] gpa = new int[2][2]; - gpa[1][1] = 1; + String in = "S\u0323\u0323;"; + int[][] gpa = new int[4][1]; + gpa[2][0] = 1; String actual = getFont().reorderCombiningMarks(in, gpa, OTFScript.DEFAULT, null, null).toString(); - Assert.assertEquals(actual.charAt(0), 57344); + Assert.assertEquals(actual.charAt(0), 803); + Assert.assertEquals(actual.charAt(1), 57344); + Assert.assertEquals(actual.charAt(2), 803); + Assert.assertEquals(actual.charAt(3), 57344); } private MultiByteFont getFont() { |