Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/font/CharToGlyphMapper.java
38829 views
/*1* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.font;2627/*28* NB the versions that take a char as an int are used by the opentype29* layout engine. If that remains in native these methods may not be30* needed in the Java class.31*/32public abstract class CharToGlyphMapper {3334public static final int HI_SURROGATE_START = 0xD800;35public static final int HI_SURROGATE_END = 0xDBFF;36public static final int LO_SURROGATE_START = 0xDC00;37public static final int LO_SURROGATE_END = 0xDFFF;3839public static final int UNINITIALIZED_GLYPH = -1;40public static final int INVISIBLE_GLYPH_ID = 0xffff;41public static final int INVISIBLE_GLYPHS = 0xfffe; // and above4243protected int missingGlyph = CharToGlyphMapper.UNINITIALIZED_GLYPH;4445public int getMissingGlyphCode() {46return missingGlyph;47}4849/* Default implementations of these methods may be overridden by50* subclasses which have special requirements or optimisations51*/5253public boolean canDisplay(char ch) {54int glyph = charToGlyph(ch);55return glyph != missingGlyph;56}5758public boolean canDisplay(int cp) {59int glyph = charToGlyph(cp);60return glyph != missingGlyph;61}6263public int charToGlyph(char unicode) {64char[] chars = new char[1];65int[] glyphs = new int[1];66chars[0] = unicode;67charsToGlyphs(1, chars, glyphs);68return glyphs[0];69}7071public int charToGlyph(int unicode) {72int[] chars = new int[1];73int [] glyphs = new int[1];74chars[0] = unicode;75charsToGlyphs(1, chars, glyphs);76return glyphs[0];77}7879public abstract int getNumGlyphs();8081public abstract void charsToGlyphs(int count,82char[] unicodes, int[] glyphs);8384public abstract boolean charsToGlyphsNS(int count,85char[] unicodes, int[] glyphs);8687public abstract void charsToGlyphs(int count,88int[] unicodes, int[] glyphs);8990}919293