0N/A/*
2362N/A * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.font;
0N/A
0N/Aimport java.awt.FontFormatException;
0N/Aimport java.awt.font.FontRenderContext;
0N/Aimport java.awt.geom.GeneralPath;
0N/Aimport java.awt.geom.Rectangle2D;
0N/Aimport java.util.HashMap;
0N/Aimport java.util.Locale;
0N/A
0N/A/*
0N/A * This needs work to distinguish between XMap's translation from unicode
0N/A * to the encoding used to access the X font, and whether a particular
0N/A * code point is in the font.
0N/A * ie a GlyphMapper ought to be able to say if a code point maps to a glyph
0N/A * IN THIS FONT, not just in this encoding.
0N/A * Because of the current lack of distinction the NativeGlyphMapper and
0N/A * XMap classes could be merged, however its cleaner to make them separate
0N/A * classes so we can build caches for a particular font.
0N/A */
0N/Apublic class NativeGlyphMapper extends CharToGlyphMapper {
0N/A
0N/A NativeFont font;
0N/A XMap xmapper;
0N/A int numGlyphs;
0N/A
0N/A NativeGlyphMapper(NativeFont f) {
0N/A font = f;
0N/A xmapper = XMap.getXMapper(font.encoding);
0N/A numGlyphs = f.getNumGlyphs();
0N/A missingGlyph = 0;
0N/A }
0N/A
0N/A public int getNumGlyphs() {
0N/A return numGlyphs;
0N/A }
0N/A
0N/A public int charToGlyph(char unicode) {
0N/A if (unicode >= xmapper.convertedGlyphs.length) {
0N/A return 0;
0N/A } else {
0N/A return xmapper.convertedGlyphs[unicode];
0N/A }
0N/A }
0N/A
0N/A public int charToGlyph(int unicode) {
0N/A if (unicode >= xmapper.convertedGlyphs.length) {
0N/A return 0;
0N/A } else {
0N/A return xmapper.convertedGlyphs[unicode];
0N/A }
0N/A }
0N/A
0N/A public void charsToGlyphs(int count, char[] unicodes, int[] glyphs) {
0N/A for (int i=0; i<count; i++) {
0N/A char code = unicodes[i];
0N/A if (code >= xmapper.convertedGlyphs.length) {
0N/A glyphs[i] = 0;
0N/A } else {
0N/A glyphs[i] = xmapper.convertedGlyphs[code];
0N/A }
0N/A }
0N/A }
0N/A
0N/A public boolean charsToGlyphsNS(int count, char[] unicodes, int[] glyphs) {
0N/A charsToGlyphs(count, unicodes, glyphs);
0N/A return false;
0N/A }
0N/A
0N/A public void charsToGlyphs(int count, int[] unicodes, int[] glyphs) {
0N/A for (int i=0; i<count; i++) {
0N/A char code = (char)unicodes[i];
0N/A if (code >= xmapper.convertedGlyphs.length) {
0N/A glyphs[i] = 0;
0N/A } else {
0N/A glyphs[i] = xmapper.convertedGlyphs[code];
0N/A }
0N/A }
0N/A }
0N/A
0N/A}