Skip to content

Commit

Permalink
FOP-2827: Add support for Khmer complex script
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1846994 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
simonsteiner1984 committed Nov 20, 2018
1 parent b2cdec0 commit 5c6ec4d
Show file tree
Hide file tree
Showing 11 changed files with 658 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ public boolean position(GlyphPositioningState ps) {
if (ma != null) {
for (int i = 0, n = ps.getPosition(); i < n; i++) {
int gi = ps.getGlyph(-(i + 1));
if (ps.isMark(gi)) {
int unprocessedGlyph = ps.getUnprocessedGlyph(-(i + 1));
if (ps.isMark(gi) && ps.isMark(unprocessedGlyph)) {
continue;
} else {
Anchor a = getBaseAnchor(gi, ma.getMarkClass());
Expand All @@ -743,6 +744,9 @@ public boolean position(GlyphPositioningState ps) {
v.adjust(0, 0, -ps.getWidth(giMark), 0);
}
// end experimental fix for END OF AYAH in Lateef/Scheherazade
if (OTFScript.KHMER.equals(ps.script)) {
v.adjust(-ps.getWidth(gi), -v.yPlacement, 0, 0);
}
if (ps.adjust(v)) {
ps.setAdjusted(true);
}
Expand Down Expand Up @@ -875,13 +879,13 @@ public boolean position(GlyphPositioningState ps) {
int mxc = getMaxComponentCount();
if (ma != null) {
for (int i = 0, n = ps.getPosition(); i < n; i++) {
int gi = ps.getGlyph(-(i + 1));
if (ps.isMark(gi)) {
int glyphIndex = ps.getUnprocessedGlyph(-(i + 1));
if (ps.isMark(glyphIndex)) {
continue;
} else {
Anchor a = getLigatureAnchor(gi, mxc, i, ma.getMarkClass());
if (a != null) {
if (ps.adjust(a.getAlignmentAdjustment(ma))) {
Anchor anchor = getLigatureAnchor(glyphIndex, mxc, i, ma.getMarkClass());
if (anchor != null) {
if (ps.adjust(anchor.getAlignmentAdjustment(ma))) {
ps.setAdjusted(true);
}
}
Expand Down Expand Up @@ -1033,9 +1037,9 @@ public boolean position(GlyphPositioningState ps) {
MarkAnchor ma = getMark1Anchor(ciMark1, giMark1);
if (ma != null) {
if (ps.hasPrev()) {
Anchor a = getMark2Anchor(ps.getGlyph(-1), ma.getMarkClass());
if (a != null) {
if (ps.adjust(a.getAlignmentAdjustment(ma))) {
Anchor anchor = getMark2Anchor(ps.getUnprocessedGlyph(-1), ma.getMarkClass());
if (anchor != null) {
if (ps.adjust(anchor.getAlignmentAdjustment(ma))) {
ps.setAdjusted(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ public int getGlyph(int offset) throws IndexOutOfBoundsException {
}
}

public int getUnprocessedGlyph(int offset) throws IndexOutOfBoundsException {
int i = index + offset;
if ((i >= 0) && (i < indexLast)) {
return igs.getUnprocessedGlyph(i);
} else {
throw new IndexOutOfBoundsException("Attempting to process glyph at index " + i);
}
}

/**
* Obtain glyph at current position.
* @return glyph at current position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.fop.complexscripts.util.CharAssociation;
import org.apache.fop.complexscripts.util.GlyphSequence;
import org.apache.fop.complexscripts.util.GlyphTester;
import org.apache.fop.fonts.MultiByteFont;

// CSOFF: LineLengthCheck

Expand Down Expand Up @@ -105,6 +106,11 @@ public GlyphSequence substitute(GlyphSequence gs, String script, String language
return ogs;
}

public CharSequence preProcess(CharSequence charSequence, String script, MultiByteFont font, List associations) {
ScriptProcessor scriptProcessor = ScriptProcessor.getInstance(script, processors);
return scriptProcessor.preProcess(charSequence, font, associations);
}

/**
* Map a lookup type name to its constant (integer) value.
* @param name lookup type name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public static ScriptProcessor makeProcessor(String script) {
case CharScript.SCRIPT_TAMIL:
case CharScript.SCRIPT_TAMIL_2:
return new TamilScriptProcessor(script);
case CharScript.SCRIPT_KHMER:
return new KhmerScriptProcessor(script);
// [TBD] implement other script processors
default:
return new IndicScriptProcessor(script);
Expand Down Expand Up @@ -239,6 +241,7 @@ private GlyphSequence unsyllabize(GlyphSequence gs, GlyphSequence[] sa) {
"rkrf",
"rphf",
"vatu",
"ccmp"
};
static {
basicShapingFeatures = new HashSet<String>();
Expand All @@ -261,6 +264,7 @@ private boolean isBasicShapingUse(GlyphTable.UseSpec us) {
"haln",
"pres",
"psts",
"clig"
};
static {
presentationFeatures = new HashSet<String>();
Expand Down

0 comments on commit 5c6ec4d

Please sign in to comment.