Skip to content

Commit 5c6ec4d

Browse files
FOP-2827: Add support for Khmer complex script
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1846994 13f79535-47bb-0310-9956-ffa450edef68
1 parent b2cdec0 commit 5c6ec4d

File tree

11 files changed

+658
-20
lines changed

11 files changed

+658
-20
lines changed

fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphPositioningTable.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ public boolean position(GlyphPositioningState ps) {
731731
if (ma != null) {
732732
for (int i = 0, n = ps.getPosition(); i < n; i++) {
733733
int gi = ps.getGlyph(-(i + 1));
734-
if (ps.isMark(gi)) {
734+
int unprocessedGlyph = ps.getUnprocessedGlyph(-(i + 1));
735+
if (ps.isMark(gi) && ps.isMark(unprocessedGlyph)) {
735736
continue;
736737
} else {
737738
Anchor a = getBaseAnchor(gi, ma.getMarkClass());
@@ -743,6 +744,9 @@ public boolean position(GlyphPositioningState ps) {
743744
v.adjust(0, 0, -ps.getWidth(giMark), 0);
744745
}
745746
// end experimental fix for END OF AYAH in Lateef/Scheherazade
747+
if (OTFScript.KHMER.equals(ps.script)) {
748+
v.adjust(-ps.getWidth(gi), -v.yPlacement, 0, 0);
749+
}
746750
if (ps.adjust(v)) {
747751
ps.setAdjusted(true);
748752
}
@@ -875,13 +879,13 @@ public boolean position(GlyphPositioningState ps) {
875879
int mxc = getMaxComponentCount();
876880
if (ma != null) {
877881
for (int i = 0, n = ps.getPosition(); i < n; i++) {
878-
int gi = ps.getGlyph(-(i + 1));
879-
if (ps.isMark(gi)) {
882+
int glyphIndex = ps.getUnprocessedGlyph(-(i + 1));
883+
if (ps.isMark(glyphIndex)) {
880884
continue;
881885
} else {
882-
Anchor a = getLigatureAnchor(gi, mxc, i, ma.getMarkClass());
883-
if (a != null) {
884-
if (ps.adjust(a.getAlignmentAdjustment(ma))) {
886+
Anchor anchor = getLigatureAnchor(glyphIndex, mxc, i, ma.getMarkClass());
887+
if (anchor != null) {
888+
if (ps.adjust(anchor.getAlignmentAdjustment(ma))) {
885889
ps.setAdjusted(true);
886890
}
887891
}
@@ -1033,9 +1037,9 @@ public boolean position(GlyphPositioningState ps) {
10331037
MarkAnchor ma = getMark1Anchor(ciMark1, giMark1);
10341038
if (ma != null) {
10351039
if (ps.hasPrev()) {
1036-
Anchor a = getMark2Anchor(ps.getGlyph(-1), ma.getMarkClass());
1037-
if (a != null) {
1038-
if (ps.adjust(a.getAlignmentAdjustment(ma))) {
1040+
Anchor anchor = getMark2Anchor(ps.getUnprocessedGlyph(-1), ma.getMarkClass());
1041+
if (anchor != null) {
1042+
if (ps.adjust(anchor.getAlignmentAdjustment(ma))) {
10391043
ps.setAdjusted(true);
10401044
}
10411045
}

fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphProcessingState.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,15 @@ public int getGlyph(int offset) throws IndexOutOfBoundsException {
413413
}
414414
}
415415

416+
public int getUnprocessedGlyph(int offset) throws IndexOutOfBoundsException {
417+
int i = index + offset;
418+
if ((i >= 0) && (i < indexLast)) {
419+
return igs.getUnprocessedGlyph(i);
420+
} else {
421+
throw new IndexOutOfBoundsException("Attempting to process glyph at index " + i);
422+
}
423+
}
424+
416425
/**
417426
* Obtain glyph at current position.
418427
* @return glyph at current position

fop-core/src/main/java/org/apache/fop/complexscripts/fonts/GlyphSubstitutionTable.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.fop.complexscripts.util.CharAssociation;
3232
import org.apache.fop.complexscripts.util.GlyphSequence;
3333
import org.apache.fop.complexscripts.util.GlyphTester;
34+
import org.apache.fop.fonts.MultiByteFont;
3435

3536
// CSOFF: LineLengthCheck
3637

@@ -105,6 +106,11 @@ public GlyphSequence substitute(GlyphSequence gs, String script, String language
105106
return ogs;
106107
}
107108

109+
public CharSequence preProcess(CharSequence charSequence, String script, MultiByteFont font, List associations) {
110+
ScriptProcessor scriptProcessor = ScriptProcessor.getInstance(script, processors);
111+
return scriptProcessor.preProcess(charSequence, font, associations);
112+
}
113+
108114
/**
109115
* Map a lookup type name to its constant (integer) value.
110116
* @param name lookup type name

fop-core/src/main/java/org/apache/fop/complexscripts/scripts/IndicScriptProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ public static ScriptProcessor makeProcessor(String script) {
130130
case CharScript.SCRIPT_TAMIL:
131131
case CharScript.SCRIPT_TAMIL_2:
132132
return new TamilScriptProcessor(script);
133+
case CharScript.SCRIPT_KHMER:
134+
return new KhmerScriptProcessor(script);
133135
// [TBD] implement other script processors
134136
default:
135137
return new IndicScriptProcessor(script);
@@ -239,6 +241,7 @@ private GlyphSequence unsyllabize(GlyphSequence gs, GlyphSequence[] sa) {
239241
"rkrf",
240242
"rphf",
241243
"vatu",
244+
"ccmp"
242245
};
243246
static {
244247
basicShapingFeatures = new HashSet<String>();
@@ -261,6 +264,7 @@ private boolean isBasicShapingUse(GlyphTable.UseSpec us) {
261264
"haln",
262265
"pres",
263266
"psts",
267+
"clig"
264268
};
265269
static {
266270
presentationFeatures = new HashSet<String>();

0 commit comments

Comments
 (0)