Search in sources :

Example 1 with NumericShaper

use of java.awt.font.NumericShaper in project jdk8u_jdk by JetBrains.

the class ShapingTest method test6943963.

private static void test6943963() {
    // Needed to reproduce this bug.
    NumericShaper ns_dummy = getContextualShaper(ARABIC | TAMIL | ETHIOPIC, EUROPEAN);
    char[] c = "ሀ 1".toCharArray();
    ns_dummy.shape(c, 0, c.length);
    String given = "اب 456";
    String expected_ARABIC = "اب ٤٥٦";
    String expected_EASTERN_ARABIC = "اب ۴۵۶";
    NumericShaper ns = getContextualShaper(ARABIC);
    checkResult("ARABIC", ns, given, expected_ARABIC);
    ns = getContextualShaper(EnumSet.of(Range.ARABIC));
    checkResult("Range.ARABIC", ns, given, expected_ARABIC);
    ns = getContextualShaper(EASTERN_ARABIC);
    checkResult("EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
    ns = getContextualShaper(EnumSet.of(Range.EASTERN_ARABIC));
    checkResult("Range.EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
    ns = getContextualShaper(ARABIC | EASTERN_ARABIC);
    checkResult("ARABIC | EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
    ns = getContextualShaper(EnumSet.of(Range.ARABIC, Range.EASTERN_ARABIC));
    checkResult("Range.ARABIC, Range.EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
}
Also used : NumericShaper(java.awt.font.NumericShaper)

Example 2 with NumericShaper

use of java.awt.font.NumericShaper in project jdk8u_jdk by JetBrains.

the class TextLayout method paragraphInit.

/**
     * Initialize the paragraph-specific data.
     */
private void paragraphInit(byte aBaseline, CoreMetrics lm, Map<? extends Attribute, ?> paragraphAttrs, char[] text) {
    baseline = aBaseline;
    // normalize to current baseline
    baselineOffsets = TextLine.getNormalizedOffsets(lm.baselineOffsets, baseline);
    justifyRatio = AttributeValues.getJustification(paragraphAttrs);
    NumericShaper shaper = AttributeValues.getNumericShaping(paragraphAttrs);
    if (shaper != null) {
        shaper.shape(text, 0, text.length);
    }
}
Also used : NumericShaper(java.awt.font.NumericShaper)

Example 3 with NumericShaper

use of java.awt.font.NumericShaper in project jdk8u_jdk by JetBrains.

the class ShapingTest method test6842557.

private static void test6842557() {
    NumericShaper ns_old = getContextualShaper(ARABIC | TAMIL | ETHIOPIC, EUROPEAN);
    NumericShaper ns_new = getContextualShaper(EnumSet.of(Range.ARABIC, Range.TAMIL, Range.ETHIOPIC), Range.EUROPEAN);
    String[][] data = { // Arabic "October 10"
    { "أكتوبر 10", "أكتوبر ١٠" }, // Tamil "Year 2009"
    { "ஆண்டு 2009", "ஆண்டு ௨௦௦௯" }, // Ethiopic "Syllable<HA> 2009"
    { "ሀ 2009", "ሀ ፪00፱" } };
    for (int i = 0; i < data.length; i++) {
        checkResult("ARABIC | TAMIL | ETHIOPIC", ns_old, data[i][0], data[i][1]);
        checkResult("Range.ARABIC, Range.TAMIL, Range.ETHIOPIC", ns_new, data[i][0], data[i][1]);
    }
}
Also used : NumericShaper(java.awt.font.NumericShaper)

Example 4 with NumericShaper

use of java.awt.font.NumericShaper in project jdk8u_jdk by JetBrains.

the class ShapingTest method test6903266.

private static void test6903266() {
    NumericShaper ns = getContextualShaper(EnumSet.of(Range.TAI_THAM_HORA));
    String given = "ᨠ 012";
    String expected = "ᨠ ᪀᪁᪂";
    checkResult("Range.TAI_THAM_HORA", ns, given, expected);
    ns = getContextualShaper(EnumSet.of(Range.TAI_THAM_HORA, Range.TAI_THAM_THAM));
    given = "ᨠ 012";
    // Tham digits are prioritized.
    expected = "ᨠ ᪐᪑᪒";
    checkResult("Range.TAI_THAM_HORA, Range.TAI_THAM_THAM", ns, given, expected);
    ns = getContextualShaper(EnumSet.of(Range.JAVANESE));
    given = "ꦄ 012";
    expected = "ꦄ ꧐꧑꧒";
    checkResult("Range.JAVANESE", ns, given, expected);
    ns = getContextualShaper(EnumSet.of(Range.TAI_THAM_THAM));
    given = "ᨠ 012";
    expected = "ᨠ ᪐᪑᪒";
    checkResult("Range.TAI_THAM_THAM", ns, given, expected);
    ns = getContextualShaper(EnumSet.of(Range.MEETEI_MAYEK));
    given = "ꯀ 012";
    expected = "ꯀ ꯰꯱꯲";
    checkResult("Range.MEETEI_MAYEK", ns, given, expected);
}
Also used : NumericShaper(java.awt.font.NumericShaper)

Example 5 with NumericShaper

use of java.awt.font.NumericShaper in project jdk8u_jdk by JetBrains.

the class BidiConformance method testMethods4Constructor1.

private void testMethods4Constructor1() {
    System.out.println("*** Test methods for constructor 1");
    String paragraph;
    Bidi bidi;
    NumericShaper ns = NumericShaper.getShaper(NumericShaper.ARABIC);
    for (int textNo = 0; textNo < data4Constructor1.length; textNo++) {
        paragraph = data4Constructor1[textNo][0];
        int start = paragraph.indexOf('<') + 1;
        int limit = paragraph.indexOf('>');
        int testNo;
        System.out.println("*** Test textNo=" + textNo + ": Bidi(AttributedCharacterIterator\"" + toReadableString(paragraph) + "\") " + "  start=" + start + ", limit=" + limit);
        // Test 0
        testNo = 0;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_LTR");
        AttributedString astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 1
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_LTR, BIDI_EMBEDDING(1)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(1), start, limit);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 2
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIERCTION_LTR, BIDI_EMBEDDING(2)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(2), start, limit);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 3
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTIOIN_LTR, BIDI_EMBEDDING(-3)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-3), start, limit);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 4
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_LTR, BIDI_EMBEDDING(-4)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-4), start, limit);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 5
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_RTL");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 6
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(1)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(1), start, limit);
        try {
            bidi = new Bidi(astr.getIterator());
            callTestEachMethod4Constructor1(textNo, testNo, bidi);
        } catch (IllegalArgumentException e) {
            errorHandling("  Unexpected exception: " + e);
        }
        // Test 7
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(2)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(2), start, limit);
        try {
            bidi = new Bidi(astr.getIterator());
            callTestEachMethod4Constructor1(textNo, testNo, bidi);
        } catch (IllegalArgumentException e) {
            errorHandling("  Unexpected exception: " + e);
        }
        // Test 8
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(-3)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-3), start, limit);
        try {
            bidi = new Bidi(astr.getIterator());
            callTestEachMethod4Constructor1(textNo, testNo, bidi);
        } catch (IllegalArgumentException e) {
            errorHandling("  Unexpected exception: " + e);
        }
        // Test 9
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(-4)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
        astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-4), start, limit);
        try {
            bidi = new Bidi(astr.getIterator());
            callTestEachMethod4Constructor1(textNo, testNo, bidi);
        } catch (IllegalArgumentException e) {
            errorHandling("  Unexpected exception: " + e);
        }
        // Test 10
        ++testNo;
        System.out.println(" Test#" + testNo + ": TextAttribute not specified");
        astr = new AttributedString(paragraph);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 11
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_LTR, NUMERIC_SHAPING(ARABIC)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_LTR);
        astr.addAttribute(TextAttribute.NUMERIC_SHAPING, ns);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
        // Test 12
        ++testNo;
        System.out.println(" Test#" + testNo + ": RUN_DIRECTION_RTL, NUMERIC_SHAPING(ARABIC)");
        astr = new AttributedString(paragraph);
        astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
        astr.addAttribute(TextAttribute.NUMERIC_SHAPING, ns);
        bidi = new Bidi(astr.getIterator());
        callTestEachMethod4Constructor1(textNo, testNo, bidi);
    }
}
Also used : Bidi(java.text.Bidi) NumericShaper(java.awt.font.NumericShaper) AttributedString(java.text.AttributedString) AttributedString(java.text.AttributedString)

Aggregations

NumericShaper (java.awt.font.NumericShaper)5 AttributedString (java.text.AttributedString)1 Bidi (java.text.Bidi)1