Example usage for java.awt.font TextAttribute NUMERIC_SHAPING

List of usage examples for java.awt.font TextAttribute NUMERIC_SHAPING

Introduction

In this page you can find the example usage for java.awt.font TextAttribute NUMERIC_SHAPING.

Prototype

TextAttribute NUMERIC_SHAPING

To view the source code for java.awt.font TextAttribute NUMERIC_SHAPING.

Click Source Link

Document

Attribute key for converting ASCII decimal digits to other decimal ranges.

Usage

From source file:Main.java

private static TextLayout createTextLayout(JComponent c, String s, Font f, FontRenderContext frc) {
    Object shaper = (c == null ? null : c.getClientProperty(TextAttribute.NUMERIC_SHAPING));
    if (shaper == null) {
        return new TextLayout(s, f, frc);
    } else {/*from w w  w .ja v  a2 s  . com*/
        Map<TextAttribute, Object> a = new HashMap<TextAttribute, Object>();
        a.put(TextAttribute.FONT, f);
        a.put(TextAttribute.NUMERIC_SHAPING, shaper);
        return new TextLayout(s, a, frc);
    }
}

From source file:Test.java

public NumericShaperPanel() {
    String text = "java";
    HashMap map = new HashMap();
    Font font = new Font("Mongolian Baiti", Font.PLAIN, 32);
    map.put(TextAttribute.FONT, font);
    map.put(TextAttribute.NUMERIC_SHAPING, NumericShaper.getShaper(NumericShaper.Range.MONGOLIAN));
    FontRenderContext fontRenderContext = new FontRenderContext(null, false, false);
    layout = new TextLayout(text, map, fontRenderContext);
}