HangulFormatter.java 1.52 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.fontengine.inlineformatting.infontformatting;

import com.adobe.fontengine.inlineformatting.AttributedRun;
import com.adobe.fontengine.inlineformatting.infontformatting.GenericFormatter;

public final class HangulFormatter
extends GenericFormatter {
    private boolean isL(int ch) {
        return 4352 <= ch && ch < 4371;
    }

    private boolean isV(int ch) {
        return 4449 <= ch && ch < 4470;
    }

    private boolean isT(int ch) {
        return 4519 <= ch && ch < 4547;
    }

    private boolean isLV(int ch) {
        return 44032 <= ch && ch < 55204 && (ch - 44032) % 28 == 0;
    }

    public int firstPass(AttributedRun run, int start, int limit) {
        int current = start;
        int pendingChar = run.elementAt(current);
        ++current;
        while (current < limit) {
            int currentChar = run.elementAt(current);
            if (this.isL(pendingChar) && this.isV(currentChar)) {
                pendingChar = 44032 + ((pendingChar - 4352) * 21 + (currentChar - 4449)) * 28;
                run.replace(current - 1, current + 1, pendingChar);
                --limit;
                continue;
            }
            if (this.isLV(pendingChar) && this.isT(currentChar)) {
                run.replace(current - 1, current + 1, pendingChar += currentChar - 4519);
                --limit;
                continue;
            }
            pendingChar = currentChar;
            ++current;
        }
        return super.firstPass(run, start, limit);
    }
}