jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java
author prr
Wed, 09 Nov 2016 11:28:13 -0800
changeset 42208 7c1017f0ade5
parent 25859 3317bb8137f4
permissions -rw-r--r--
8155874: Fix java.desktop deprecation warnings about Class.newInstance Reviewed-by: serb, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * NB the versions that take a char as an int are used by the opentype
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * layout engine. If that remains in native these methods may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * needed in the Java class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
public abstract class CharToGlyphMapper {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    public static final int HI_SURROGATE_START = 0xD800;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    public static final int HI_SURROGATE_END = 0xDBFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    public static final int LO_SURROGATE_START = 0xDC00;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    public static final int LO_SURROGATE_END = 0xDFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public static final int UNINITIALIZED_GLYPH = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    public static final int INVISIBLE_GLYPH_ID = 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    public static final int INVISIBLE_GLYPHS   = 0xfffe; // and above
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    protected int missingGlyph = CharToGlyphMapper.UNINITIALIZED_GLYPH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    public int getMissingGlyphCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        return missingGlyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /* Default implementations of these methods may be overridden by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * subclasses which have special requirements or optimisations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public boolean canDisplay(char ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        int glyph = charToGlyph(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        return glyph != missingGlyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public boolean canDisplay(int cp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        int glyph = charToGlyph(cp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        return glyph != missingGlyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public int charToGlyph(char unicode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        char[] chars = new char[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        int[] glyphs = new int[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        chars[0] = unicode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        charsToGlyphs(1, chars, glyphs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        return glyphs[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public int charToGlyph(int unicode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        int[] chars = new int[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        int [] glyphs = new int[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        chars[0] = unicode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        charsToGlyphs(1, chars, glyphs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        return glyphs[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public abstract int getNumGlyphs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public abstract void charsToGlyphs(int count,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                       char[] unicodes, int[] glyphs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public abstract boolean charsToGlyphsNS(int count,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                            char[] unicodes, int[] glyphs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public abstract void charsToGlyphs(int count,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                       int[] unicodes, int[] glyphs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}