0N/A/*
2362N/A * Copyright (c) 1996, 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/Apackage sun.awt;
0N/A
0N/Aimport java.nio.charset.Charset;
0N/Aimport java.nio.charset.CharsetEncoder;
4213N/Aimport java.nio.charset.StandardCharsets;
0N/Aimport sun.nio.cs.HistoricallyNamedCharset;
0N/A
0N/Apublic class FontDescriptor implements Cloneable {
0N/A
0N/A static {
0N/A NativeLibLoader.loadLibraries();
0N/A initIDs();
0N/A }
0N/A
0N/A String nativeName;
0N/A public CharsetEncoder encoder;
0N/A String charsetName;
0N/A private int[] exclusionRanges;
0N/A
0N/A public FontDescriptor(String nativeName, CharsetEncoder encoder,
0N/A int[] exclusionRanges){
0N/A
0N/A this.nativeName = nativeName;
0N/A this.encoder = encoder;
0N/A this.exclusionRanges = exclusionRanges;
0N/A this.useUnicode = false;
0N/A Charset cs = encoder.charset();
0N/A if (cs instanceof HistoricallyNamedCharset)
0N/A this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
0N/A else
0N/A this.charsetName = cs.name();
0N/A
0N/A }
0N/A
0N/A public String getNativeName() {
0N/A return nativeName;
0N/A }
0N/A
0N/A public CharsetEncoder getFontCharsetEncoder() {
0N/A return encoder;
0N/A }
0N/A
0N/A public String getFontCharsetName() {
0N/A return charsetName;
0N/A }
0N/A
0N/A public int[] getExclusionRanges() {
0N/A return exclusionRanges;
0N/A }
0N/A
0N/A /**
0N/A * Return true if the character is exclusion character.
0N/A */
0N/A public boolean isExcluded(char ch){
0N/A for (int i = 0; i < exclusionRanges.length; ){
0N/A
0N/A int lo = (exclusionRanges[i++]);
0N/A int up = (exclusionRanges[i++]);
0N/A
0N/A if (ch >= lo && ch <= up){
0N/A return true;
0N/A }
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A public String toString() {
0N/A return super.toString() + " [" + nativeName + "|" + encoder + "]";
0N/A }
0N/A
0N/A /**
0N/A * Initialize JNI field and method IDs
0N/A */
0N/A private static native void initIDs();
0N/A
0N/A
0N/A public CharsetEncoder unicodeEncoder;
0N/A boolean useUnicode; // set to true from native code on Unicode-based systems
0N/A
0N/A public boolean useUnicode() {
0N/A if (useUnicode && unicodeEncoder == null) {
0N/A try {
0N/A this.unicodeEncoder = isLE?
4213N/A StandardCharsets.UTF_16LE.newEncoder():
4213N/A StandardCharsets.UTF_16BE.newEncoder();
0N/A } catch (IllegalArgumentException x) {}
0N/A }
0N/A return useUnicode;
0N/A }
0N/A static boolean isLE;
0N/A static {
0N/A String enc = (String) java.security.AccessController.doPrivileged(
0N/A new sun.security.action.GetPropertyAction("sun.io.unicode.encoding",
0N/A "UnicodeBig"));
0N/A isLE = !"UnicodeBig".equals(enc);
0N/A }
0N/A}