jdk/src/share/classes/sun/font/TrueTypeFont.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8813 d15a9204c2f0
child 10041 ee3a292c317f
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8813
diff changeset
     2
 * Copyright (c) 2003, 2010, 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: 3938
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: 3938
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: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
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
import java.awt.Font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.FontFormatException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.geom.Point2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.FileNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.RandomAccessFile;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.UnsupportedEncodingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.nio.ByteBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.nio.CharBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.nio.IntBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.nio.ShortBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.nio.channels.ClosedChannelException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.nio.channels.FileChannel;
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
    42
import java.util.HashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.HashSet;
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
    44
import java.util.Map;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.java2d.Disposer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import sun.java2d.DisposerRecord;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * TrueTypeFont is not called SFntFont because it is not expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * to handle all types that may be housed in a such a font file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * If additional types are supported later, it may make sense to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * create an SFnt superclass. Eg to handle sfnt-housed postscript fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * OpenType fonts are handled by this class, and possibly should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * represented by a subclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * An instance stores some information from the font file to faciliate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * faster access. File size, the table directory and the names of the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * are the most important of these. It amounts to approx 400 bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * for a typical font. Systems with mutiple locales sometimes have up to 400
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * font files, and an app which loads all font files would need around
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * 160Kbytes. So storing any more info than this would be expensive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
public class TrueTypeFont extends FileFont {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
   /* -- Tags for required TrueType tables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public static final int cmapTag = 0x636D6170; // 'cmap'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public static final int glyfTag = 0x676C7966; // 'glyf'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public static final int headTag = 0x68656164; // 'head'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public static final int hheaTag = 0x68686561; // 'hhea'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public static final int hmtxTag = 0x686D7478; // 'hmtx'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public static final int locaTag = 0x6C6F6361; // 'loca'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public static final int maxpTag = 0x6D617870; // 'maxp'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static final int nameTag = 0x6E616D65; // 'name'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public static final int postTag = 0x706F7374; // 'post'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public static final int os_2Tag = 0x4F532F32; // 'OS/2'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /* -- Tags for opentype related tables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public static final int GDEFTag = 0x47444546; // 'GDEF'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public static final int GPOSTag = 0x47504F53; // 'GPOS'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public static final int GSUBTag = 0x47535542; // 'GSUB'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public static final int mortTag = 0x6D6F7274; // 'mort'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /* -- Tags for non-standard tables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public static final int fdscTag = 0x66647363; // 'fdsc' - gxFont descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public static final int fvarTag = 0x66766172; // 'fvar' - gxFont variations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public static final int featTag = 0x66656174; // 'feat' - layout features
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public static final int EBLCTag = 0x45424C43; // 'EBLC' - embedded bitmaps
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public static final int gaspTag = 0x67617370; // 'gasp' - hint/smooth sizes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /* --  Other tags */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public static final int ttcfTag = 0x74746366; // 'ttcf' - TTC file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public static final int v1ttTag = 0x00010000; // 'v1tt' - Version 1 TT font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public static final int trueTag = 0x74727565; // 'true' - Version 2 TT font
1716
461122becab9 4356282: RFE: T2K should be used to rasterize CID/CFF fonts
igor
parents: 550
diff changeset
    94
    public static final int ottoTag = 0x4f54544f; // 'otto' - OpenType font
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /* -- ID's used in the 'name' table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public static final int MS_PLATFORM_ID = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /* MS locale id for US English is the "default" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public static final short ENGLISH_LOCALE_ID = 0x0409; // 1033 decimal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public static final int FAMILY_NAME_ID = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    // public static final int STYLE_WEIGHT_ID = 2; // currently unused.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public static final int FULL_NAME_ID = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public static final int POSTSCRIPT_NAME_ID = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   105
    private static final short US_LCID = 0x0409;  // US English - default
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   106
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   107
    private static Map<String, Short> lcidMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    class DirectoryEntry {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        int tag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        int offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        int length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /* There is a pool which limits the number of fd's that are in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * use. Normally fd's are closed as they are replaced in the pool.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * But if an instance of this class becomes unreferenced, then there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * needs to be a way to close the fd. A finalize() method could do this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * but using the Disposer class will ensure its called in a more timely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * manner. This is not something which should be relied upon to free
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * fd's - its a safeguard.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private static class TTDisposerRecord implements DisposerRecord {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        FileChannel channel = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        public synchronized void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                if (channel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                    channel.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                channel = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    TTDisposerRecord disposerRecord = new TTDisposerRecord();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /* > 0 only if this font is a part of a collection */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    int fontIndex = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /* Number of fonts in this collection. ==1 if not a collection */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    int directoryCount = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /* offset in file of table directory for this font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    int directoryOffset; // 12 if its not a collection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /* number of table entries in the directory/offsets table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    int numTables;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /* The contents of the the directory/offsets table */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    DirectoryEntry []tableDirectory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
//     protected byte []gposTable = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
//     protected byte []gdefTable = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
//     protected byte []gsubTable = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
//     protected byte []mortTable = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
//     protected boolean hintsTabledChecked = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
//     protected boolean containsHintsTable = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /* These fields are set from os/2 table info. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    private boolean supportsJA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    private boolean supportsCJK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
   167
    /* These are for faster access to the name of the font as
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
   168
     * typically exposed via API to applications.
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
   169
     */
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
   170
    private Locale nameLocale;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
   171
    private String localeFamilyName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
   172
    private String localeFullName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
   173
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * - does basic verification of the file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * - reads the header table for this font (within a collection)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * - reads the names (full, family).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * - determines the style of the font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * - initializes the CMAP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @throws FontFormatException - if the font can't be opened
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * or fails verification,  or there's no usable cmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   183
    public TrueTypeFont(String platname, Object nativeNames, int fIndex,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                 boolean javaRasterizer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        throws FontFormatException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        super(platname, nativeNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        useJavaRasterizer = javaRasterizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        fontRank = Font2D.TTF_RANK;
2609
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   189
        try {
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   190
            verify();
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   191
            init(fIndex);
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   192
        } catch (Throwable t) {
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   193
            close();
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   194
            if (t instanceof FontFormatException) {
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   195
                throw (FontFormatException)t;
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   196
            } else {
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   197
                throw new FontFormatException("Unexpected runtime exception.");
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   198
            }
1db65c97bddc 2163516: Font.createFont can be persuaded to leak temporary files
prr
parents: 550
diff changeset
   199
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        Disposer.addObjectRecord(this, disposerRecord);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /* Enable natives just for fonts picked up from the platform that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * may have external bitmaps on Solaris. Could do this just for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * the fonts that are specified in font configuration files which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * would lighten the burden (think about that).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * The EBLCTag is used to skip natives for fonts that contain embedded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * bitmaps as there's no need to use X11 for those fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Skip all the latin fonts as they don't need this treatment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Further refine this to fonts that are natively accessible (ie
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * as PCF bitmap fonts on the X11 font path).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * This method is called when creating the first strike for this font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   214
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    protected boolean checkUseNatives() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (checkedNatives) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            return useNatives;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   219
        if (!FontUtilities.isSolaris || useJavaRasterizer ||
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   220
            FontUtilities.useT2K || nativeNames == null ||
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            getDirectoryEntry(EBLCTag) != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            checkedNatives = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return false; /* useNatives is false */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        } else if (nativeNames instanceof String) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            String name = (String)nativeNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            /* Don't do do this for Latin fonts */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            if (name.indexOf("8859") > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                checkedNatives = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            } else if (NativeFont.hasExternalBitmaps(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                nativeFonts = new NativeFont[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    nativeFonts[0] = new NativeFont(name, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                    /* If reach here we have an non-latin font that has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                     * external bitmaps and we successfully created it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                    useNatives = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                } catch (FontFormatException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    nativeFonts = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        } else if (nativeNames instanceof String[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            String[] natNames = (String[])nativeNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            int numNames = natNames.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            boolean externalBitmaps = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            for (int nn = 0; nn < numNames; nn++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                if (natNames[nn].indexOf("8859") > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                    checkedNatives = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                } else if (NativeFont.hasExternalBitmaps(natNames[nn])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                    externalBitmaps = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            if (!externalBitmaps) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                checkedNatives = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            useNatives = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            nativeFonts = new NativeFont[numNames];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            for (int nn = 0; nn < numNames; nn++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    nativeFonts[nn] = new NativeFont(natNames[nn], true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                } catch (FontFormatException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    useNatives = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    nativeFonts = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        if (useNatives) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            glyphToCharMap = new char[getMapper().getNumGlyphs()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        checkedNatives = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        return useNatives;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /* This is intended to be called, and the returned value used,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * from within a block synchronized on this font object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * ie the channel returned may be nulled out at any time by "close()"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * unless the caller holds a lock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Deadlock warning: FontManager.addToPool(..) acquires a global lock,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * which means nested locks may be in effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    private synchronized FileChannel open() throws FontFormatException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        if (disposerRecord.channel == null) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   287
            if (FontUtilities.isLogging()) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   288
                FontUtilities.getLogger().info("open TTF: " + platName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                RandomAccessFile raf = (RandomAccessFile)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                        public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                                return new RandomAccessFile(platName, "r");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                            } catch (FileNotFoundException ffne) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                disposerRecord.channel = raf.getChannel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                fileSize = (int)disposerRecord.channel.size();
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   304
                FontManager fm = FontManagerFactory.getInstance();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   305
                if (fm instanceof SunFontManager) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   306
                    ((SunFontManager) fm).addToPool(this);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   307
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            } catch (NullPointerException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                throw new FontFormatException(e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            } catch (ClosedChannelException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                /* NIO I/O is interruptible, recurse to retry operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                 * The call to channel.size() above can throw this exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                 * Clear interrupts before recursing in case NIO didn't.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                 * Note that close() sets disposerRecord.channel to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                Thread.interrupted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                open();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                throw new FontFormatException(e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return disposerRecord.channel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    protected synchronized void close() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        disposerRecord.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    int readBlock(ByteBuffer buffer, int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        int bread = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                if (disposerRecord.channel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                    open();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                if (offset + length > fileSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                    if (offset >= fileSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                        /* Since the caller ensures that offset is < fileSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                         * this condition suggests that fileSize is now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                         * different than the value we originally provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                         * to native when the scaler was created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                         * Also fileSize is updated every time we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                         * open() the file here, but in native the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                         * isn't updated. If the file has changed whilst we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                         * are executing we want to bail, not spin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                         */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   351
                        if (FontUtilities.isLogging()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                            String msg = "Read offset is " + offset +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                                " file size is " + fileSize+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                                " file is " + platName;
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   355
                            FontUtilities.getLogger().severe(msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                        length = fileSize - offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                buffer.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                disposerRecord.channel.position(offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                while (bread < length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                    int cnt = disposerRecord.channel.read(buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                    if (cnt == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                        String msg = "Unexpected EOF " + this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                        int currSize = (int)disposerRecord.channel.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                        if (currSize != fileSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                            msg += " File size was " + fileSize +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                                " and now is " + currSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   373
                        if (FontUtilities.isLogging()) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   374
                            FontUtilities.getLogger().severe(msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                        // We could still flip() the buffer here because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                        // it's possible that we did read some data in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                        // an earlier loop, and we probably should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                        // return that to the caller. Although if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                        // the caller expected 8K of data and we return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                        // only a few bytes then maybe it's better instead to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                        // set bread = -1 to indicate failure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                        // The following is therefore using arbitrary values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                        // but is meant to allow cases where enough
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                        // data was read to probably continue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                        if (bread > length/2 || bread > 16384) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                            buffer.flip();
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   388
                            if (FontUtilities.isLogging()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                                msg = "Returning " + bread +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                                    " bytes instead of " + length;
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   391
                                FontUtilities.getLogger().severe(msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                            bread = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                        throw new IOException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                    bread += cnt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                buffer.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                if (bread > length) { // possible if buffer.size() > length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    bread = length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        } catch (FontFormatException e) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   406
            if (FontUtilities.isLogging()) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   407
                FontUtilities.getLogger().severe(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                                       "While reading " + platName, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            bread = -1; // signal EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            deregisterFontAndClearStrikeCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        } catch (ClosedChannelException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            /* NIO I/O is interruptible, recurse to retry operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
             * Clear interrupts before recursing in case NIO didn't.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            Thread.interrupted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            return readBlock(buffer, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            /* If we did not read any bytes at all and the exception is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
             * not a recoverable one (ie is not ClosedChannelException) then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
             * we should indicate that there is no point in re-trying.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
             * Other than an attempt to read past the end of the file it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
             * seems unlikely this would occur as problems opening the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
             * file are handled as a FontFormatException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
             */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   427
            if (FontUtilities.isLogging()) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   428
                FontUtilities.getLogger().severe(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                                       "While reading " + platName, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            if (bread == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                bread = -1; // signal EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                deregisterFontAndClearStrikeCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        return bread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    ByteBuffer readBlock(int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        ByteBuffer buffer = ByteBuffer.allocate(length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                if (disposerRecord.channel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                    open();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                if (offset + length > fileSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                    if (offset > fileSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                        return null; // assert?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                        buffer = ByteBuffer.allocate(fileSize-offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                disposerRecord.channel.position(offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                disposerRecord.channel.read(buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                buffer.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        } catch (FontFormatException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        } catch (ClosedChannelException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            /* NIO I/O is interruptible, recurse to retry operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
             * Clear interrupts before recursing in case NIO didn't.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            Thread.interrupted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            readBlock(buffer, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        return buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    /* This is used by native code which can't allocate a direct byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * buffer because of bug 4845371. It, and references to it in native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * code in scalerMethods.c can be removed once that bug is fixed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * 4845371 is now fixed but we'll keep this around as it doesn't cost
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * us anything if its never used/called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    byte[] readBytes(int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        ByteBuffer buffer = readBlock(offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        if (buffer.hasArray()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            return buffer.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            byte[] bufferBytes = new byte[buffer.limit()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            buffer.get(bufferBytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            return bufferBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    private void verify() throws FontFormatException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        open();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    /* sizes, in bytes, of TT/TTC header records */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    private static final int TTCHEADERSIZE = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    private static final int DIRECTORYHEADERSIZE = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    private static final int DIRECTORYENTRYSIZE = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    protected void init(int fIndex) throws FontFormatException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        int headerOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        ByteBuffer buffer = readBlock(0, TTCHEADERSIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            switch (buffer.getInt()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            case ttcfTag:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                buffer.getInt(); // skip TTC version ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                directoryCount = buffer.getInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                if (fIndex >= directoryCount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    throw new FontFormatException("Bad collection index");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                fontIndex = fIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                buffer = readBlock(TTCHEADERSIZE+4*fIndex, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                headerOffset = buffer.getInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            case v1ttTag:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            case trueTag:
1716
461122becab9 4356282: RFE: T2K should be used to rasterize CID/CFF fonts
igor
parents: 550
diff changeset
   518
            case ottoTag:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            default:
8813
d15a9204c2f0 6985453: Font.createFont may expose some system properties in exception text
bae
parents: 5506
diff changeset
   522
                throw new FontFormatException("Unsupported sfnt " +
d15a9204c2f0 6985453: Font.createFont may expose some system properties in exception text
bae
parents: 5506
diff changeset
   523
                                              getPublicFileName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            /* Now have the offset of this TT font (possibly within a TTC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
             * After the TT version/scaler type field, is the short
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
             * representing the number of tables in the table directory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
             * The table directory begins at 12 bytes after the header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
             * Each table entry is 16 bytes long (4 32-bit ints)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            buffer = readBlock(headerOffset+4, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            numTables = buffer.getShort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            directoryOffset = headerOffset+DIRECTORYHEADERSIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            ByteBuffer bbuffer = readBlock(directoryOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                                           numTables*DIRECTORYENTRYSIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            IntBuffer ibuffer = bbuffer.asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            DirectoryEntry table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            tableDirectory = new DirectoryEntry[numTables];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            for (int i=0; i<numTables;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                tableDirectory[i] = table = new DirectoryEntry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                table.tag   =  ibuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                /* checksum */ ibuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                table.offset = ibuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                table.length = ibuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                if (table.offset + table.length > fileSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                    throw new FontFormatException("bad table, tag="+table.tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            initNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        } catch (Exception e) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   552
            if (FontUtilities.isLogging()) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   553
                FontUtilities.getLogger().severe(e.toString());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            if (e instanceof FontFormatException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                throw (FontFormatException)e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                throw new FontFormatException(e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        if (familyName == null || fullName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            throw new FontFormatException("Font name not found");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        /* The os2_Table is needed to gather some info, but we don't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
         * want to keep it around (as a field) so obtain it once and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
         * pass it to the code that needs it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        ByteBuffer os2_Table = getTableBuffer(os_2Tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        setStyle(os2_Table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        setCJKSupport(os2_Table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    /* The array index corresponds to a bit offset in the TrueType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * font's OS/2 compatibility table's code page ranges fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * These are two 32 bit unsigned int fields at offsets 78 and 82.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * We are only interested in determining if the font supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * the windows encodings we expect as the default encoding in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * supported locales, so we only map the first of these fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    static final String encoding_mapping[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        "cp1252",    /*  0:Latin 1  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        "cp1250",    /*  1:Latin 2  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        "cp1251",    /*  2:Cyrillic */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        "cp1253",    /*  3:Greek    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        "cp1254",    /*  4:Turkish/Latin 5  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        "cp1255",    /*  5:Hebrew   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        "cp1256",    /*  6:Arabic   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        "cp1257",    /*  7:Windows Baltic   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        "",          /*  8:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        "",          /*  9:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        "",          /* 10:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        "",          /* 11:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        "",          /* 12:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        "",          /* 13:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        "",          /* 14:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        "",          /* 15:reserved for alternate ANSI */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        "ms874",     /* 16:Thai     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        "ms932",     /* 17:JIS/Japanese */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        "gbk",       /* 18:PRC GBK Cp950  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        "ms949",     /* 19:Korean Extended Wansung */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        "ms950",     /* 20:Chinese (Taiwan, Hongkong, Macau) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        "ms1361",    /* 21:Korean Johab */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        "",          /* 22 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        "",          /* 23 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        "",          /* 24 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        "",          /* 25 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        "",          /* 26 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        "",          /* 27 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        "",          /* 28 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        "",          /* 29 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        "",          /* 30 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        "",          /* 31 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    /* This maps two letter language codes to a Windows code page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * Note that eg Cp1252 (the first subarray) is not exactly the same as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * Latin-1 since Windows code pages are do not necessarily correspond.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * There are two codepages for zh and ko so if a font supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * only one of these ranges then we need to distinguish based on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * country. So far this only seems to matter for zh.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * REMIND: Unicode locales such as Hindi do not have a code page so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * this whole mechansim needs to be revised to map languages to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * the Unicode ranges either when this fails, or as an additional
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * validating test. Basing it on Unicode ranges should get us away
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * from needing to map to this small and incomplete set of Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * code pages which looks odd on non-Windows platforms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    private static final String languages[][] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        /* cp1252/Latin 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        { "en", "ca", "da", "de", "es", "fi", "fr", "is", "it",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
          "nl", "no", "pt", "sq", "sv", },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
         /* cp1250/Latin2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        { "cs", "cz", "et", "hr", "hu", "nr", "pl", "ro", "sk",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
          "sl", "sq", "sr", },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        /* cp1251/Cyrillic */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        { "bg", "mk", "ru", "sh", "uk" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        /* cp1253/Greek*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        { "el" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
         /* cp1254/Turkish,Latin 5 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        { "tr" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
         /* cp1255/Hebrew */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        { "he" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        /* cp1256/Arabic */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        { "ar" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
         /* cp1257/Windows Baltic */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        { "et", "lt", "lv" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        /* ms874/Thai */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        { "th" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
         /* ms932/Japanese */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        { "ja" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        /* gbk/Chinese (PRC GBK Cp950) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        { "zh", "zh_CN", },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        /* ms949/Korean Extended Wansung */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        { "ko" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        /* ms950/Chinese (Taiwan, Hongkong, Macau) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        { "zh_HK", "zh_TW", },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        /* ms1361/Korean Johab */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        { "ko" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    private static final String codePages[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        "cp1252",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        "cp1250",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        "cp1251",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        "cp1253",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        "cp1254",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        "cp1255",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        "cp1256",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        "cp1257",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        "ms874",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        "ms932",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        "gbk",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        "ms949",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        "ms950",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        "ms1361",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    private static String defaultCodePage = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    static String getCodePage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        if (defaultCodePage != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            return defaultCodePage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   699
        if (FontUtilities.isWindows) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            defaultCodePage =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                (String)java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                   new sun.security.action.GetPropertyAction("file.encoding"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            if (languages.length != codePages.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                throw new InternalError("wrong code pages array length");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            Locale locale = sun.awt.SunToolkit.getStartupLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            String language = locale.getLanguage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            if (language != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                if (language.equals("zh")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                    String country = locale.getCountry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                    if (country != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                        language = language + "_" + country;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                for (int i=0; i<languages.length;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                    for (int l=0;l<languages[i].length; l++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                        if (language.equals(languages[i][l])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                            defaultCodePage = codePages[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                            return defaultCodePage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        if (defaultCodePage == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            defaultCodePage = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        return defaultCodePage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    /* Theoretically, reserved bits must not be set, include symbol bits */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    public static final int reserved_bits1 = 0x80000000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    public static final int reserved_bits2 = 0x0000ffff;
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   736
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    boolean supportsEncoding(String encoding) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        if (encoding == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            encoding = getCodePage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        if ("".equals(encoding)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        encoding = encoding.toLowerCase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        /* java_props_md.c has a couple of special cases
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
         * if language packs are installed. In these encodings the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
         * fontconfig files pick up different fonts :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
         * SimSun-18030 and MingLiU_HKSCS. Since these fonts will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
         * indicate they support the base encoding, we need to rewrite
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
         * these encodings here before checking the map/array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        if (encoding.equals("gb18030")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            encoding = "gbk";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        } else if (encoding.equals("ms950_hkscs")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            encoding = "ms950";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        ByteBuffer buffer = getTableBuffer(os_2Tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        /* required info is at offsets 78 and 82 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        if (buffer == null || buffer.capacity() < 86) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        int range1 = buffer.getInt(78); /* ulCodePageRange1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        int range2 = buffer.getInt(82); /* ulCodePageRange2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        /* This test is too stringent for Arial on Solaris (and perhaps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
         * other fonts). Arial has at least one reserved bit set for an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
         * unknown reason.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
//         if (((range1 & reserved_bits1) | (range2 & reserved_bits2)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
//             return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
//         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        for (int em=0; em<encoding_mapping.length; em++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            if (encoding_mapping[em].equals(encoding)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                if (((1 << em) & range1) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    /* Use info in the os_2Table to test CJK support */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    private void setCJKSupport(ByteBuffer os2Table) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        /* required info is in ulong at offset 46 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        if (os2Table == null || os2Table.capacity() < 50) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        int range2 = os2Table.getInt(46); /* ulUnicodeRange2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        /* Any of these bits set in the 32-63 range indicate a font with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
         * support for a CJK range. We aren't looking at some other bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
         * in the 64-69 range such as half width forms as its unlikely a font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
         * would include those and none of these.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        supportsCJK = ((range2 & 0x29bf0000) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        /* This should be generalised, but for now just need to know if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
         * Hiragana or Katakana ranges are supported by the font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
         * In the 4 longs representing unicode ranges supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
         * bits 49 & 50 indicate hiragana and katakana
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
         * This is bits 17 & 18 in the 2nd ulong. If either is supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
         * we presume this is a JA font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        supportsJA = ((range2 & 0x60000) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    boolean supportsJA() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        return supportsJA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     ByteBuffer getTableBuffer(int tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        DirectoryEntry entry = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        for (int i=0;i<numTables;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            if (tableDirectory[i].tag == tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                entry = tableDirectory[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        if (entry == null || entry.length == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            entry.offset+entry.length > fileSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        int bread = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        ByteBuffer buffer = ByteBuffer.allocate(entry.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                if (disposerRecord.channel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                    open();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                disposerRecord.channel.position(entry.offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                bread = disposerRecord.channel.read(buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                buffer.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            } catch (ClosedChannelException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                /* NIO I/O is interruptible, recurse to retry operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                 * Clear interrupts before recursing in case NIO didn't.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                Thread.interrupted();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                return getTableBuffer(tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            } catch (FontFormatException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            if (bread < entry.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                return buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    /* NB: is it better to move declaration to Font2D? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    long getLayoutTableCache() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
          return getScaler().getLayoutTableCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        } catch(FontScalerException fe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
            return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   871
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    byte[] getTableBytes(int tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        ByteBuffer buffer = getTableBuffer(tag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        if (buffer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        } else if (buffer.hasArray()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                return buffer.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            } catch (Exception re) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        byte []data = new byte[getTableSize(tag)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        buffer.get(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        return data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    int getTableSize(int tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        for (int i=0;i<numTables;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            if (tableDirectory[i].tag == tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                return tableDirectory[i].length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    int getTableOffset(int tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        for (int i=0;i<numTables;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            if (tableDirectory[i].tag == tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                return tableDirectory[i].offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    DirectoryEntry getDirectoryEntry(int tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        for (int i=0;i<numTables;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            if (tableDirectory[i].tag == tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                return tableDirectory[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
550
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   914
    /* Used to determine if this size has embedded bitmaps, which
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   915
     * for CJK fonts should be used in preference to LCD glyphs.
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   916
     */
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   917
    boolean useEmbeddedBitmapsForSize(int ptSize) {
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   918
        if (!supportsCJK) {
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   919
            return false;
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   920
        }
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   921
        if (getDirectoryEntry(EBLCTag) == null) {
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   922
            return false;
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   923
        }
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   924
        ByteBuffer eblcTable = getTableBuffer(EBLCTag);
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   925
        int numSizes = eblcTable.getInt(4);
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   926
        /* The bitmapSizeTable's start at offset of 8.
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   927
         * Each bitmapSizeTable entry is 48 bytes.
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   928
         * The offset of ppemY in the entry is 45.
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   929
         */
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   930
        for (int i=0;i<numSizes;i++) {
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   931
            int ppemY = eblcTable.get(8+(i*48)+45) &0xff;
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   932
            if (ppemY == ptSize) {
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   933
                return true;
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   934
            }
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   935
        }
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   936
        return false;
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   937
    }
e85f91b9bb95 6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents: 2
diff changeset
   938
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    public String getFullName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        return fullName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    /* This probably won't get called but is there to support the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * contract() of setStyle() defined in the superclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   946
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    protected void setStyle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        setStyle(getTableBuffer(os_2Tag));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    /* TrueTypeFont can use the fsSelection fields of OS/2 table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * to determine the style. In the unlikely case that doesn't exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * can use macStyle in the 'head' table but simpler to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * fall back to super class algorithm of looking for well known string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * A very few fonts don't specify this information, but I only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * came across one: Lucida Sans Thai Typewriter Oblique in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     * /usr/openwin/lib/locale/th_TH/X11/fonts/TrueType/lucidai.ttf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * that explicitly specified the wrong value. It says its regular.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * I didn't find any fonts that were inconsistent (ie regular plus some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     * other value).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    private static final int fsSelectionItalicBit  = 0x00001;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    private static final int fsSelectionBoldBit    = 0x00020;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    private static final int fsSelectionRegularBit = 0x00040;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    private void setStyle(ByteBuffer os_2Table) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        /* fsSelection is unsigned short at buffer offset 62 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        if (os_2Table == null || os_2Table.capacity() < 64) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            super.setStyle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        int fsSelection = os_2Table.getChar(62) & 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        int italic  = fsSelection & fsSelectionItalicBit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        int bold    = fsSelection & fsSelectionBoldBit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        int regular = fsSelection & fsSelectionRegularBit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
//      System.out.println("platname="+platName+" font="+fullName+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
//                         " family="+familyName+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
//                         " R="+regular+" I="+italic+" B="+bold);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
        if (regular!=0 && ((italic|bold)!=0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            /* This is inconsistent. Try using the font name algorithm */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
            super.setStyle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        } else if ((regular|italic|bold) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
            /* No style specified. Try using the font name algorithm */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            super.setStyle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        switch (bold|italic) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
        case fsSelectionItalicBit:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
            style = Font.ITALIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
        case fsSelectionBoldBit:
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
   992
            if (FontUtilities.isSolaris && platName.endsWith("HG-GothicB.ttf")) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                /* Workaround for Solaris's use of a JA font that's marked as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                 * being designed bold, but is used as a PLAIN font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                style = Font.PLAIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                style = Font.BOLD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        case fsSelectionBoldBit|fsSelectionItalicBit:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
            style = Font.BOLD|Font.ITALIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    private float stSize, stPos, ulSize, ulPos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    private void setStrikethroughMetrics(ByteBuffer os_2Table, int upem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        if (os_2Table == null || os_2Table.capacity() < 30 || upem < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            stSize = .05f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            stPos = -.4f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
        ShortBuffer sb = os_2Table.asShortBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        stSize = sb.get(13) / (float)upem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        stPos = -sb.get(14) / (float)upem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    private void setUnderlineMetrics(ByteBuffer postTable, int upem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
        if (postTable == null || postTable.capacity() < 12 || upem < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            ulSize = .05f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            ulPos = .1f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        ShortBuffer sb = postTable.asShortBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        ulSize = sb.get(5) / (float)upem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        ulPos = -sb.get(4) / (float)upem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1030
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    public void getStyleMetrics(float pointSize, float[] metrics, int offset) {
2693
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1032
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1033
        if (ulSize == 0f && ulPos == 0f) {
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1034
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1035
            ByteBuffer head_Table = getTableBuffer(headTag);
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1036
            int upem = -1;
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1037
            if (head_Table != null && head_Table.capacity() >= 18) {
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1038
                ShortBuffer sb = head_Table.asShortBuffer();
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1039
                upem = sb.get(9) & 0xffff;
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1040
            }
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1041
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1042
            ByteBuffer os2_Table = getTableBuffer(os_2Tag);
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1043
            setStrikethroughMetrics(os2_Table, upem);
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1044
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1045
            ByteBuffer post_Table = getTableBuffer(postTag);
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1046
            setUnderlineMetrics(post_Table, upem);
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1047
        }
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1048
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        metrics[offset] = stPos * pointSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        metrics[offset+1] = stSize * pointSize;
2693
f87942d1edba 6753173: No need to read all the TrueType 'post' table to get underline info
prr
parents: 1721
diff changeset
  1051
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        metrics[offset+2] = ulPos * pointSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        metrics[offset+3] = ulSize * pointSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    private String makeString(byte[] bytes, int len, short encoding) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        /* Check for fonts using encodings 2->6 is just for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
         * some old DBCS fonts, apparently mostly on Solaris.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
         * Some of these fonts encode ascii names as double-byte characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
         * ie with a leading zero byte for what properly should be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
         * single byte-char.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        if (encoding >=2 && encoding <= 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
             byte[] oldbytes = bytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
             int oldlen = len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
             bytes = new byte[oldlen];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
             len = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
             for (int i=0; i<oldlen; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                 if (oldbytes[i] != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                     bytes[len++] = oldbytes[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        String charset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
        switch (encoding) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            case 1:  charset = "UTF-16";  break; // most common case first.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
            case 0:  charset = "UTF-16";  break; // symbol uses this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            case 2:  charset = "SJIS";    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            case 3:  charset = "GBK";     break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            case 4:  charset = "MS950";   break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            case 5:  charset = "EUC_KR";  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
            case 6:  charset = "Johab";   break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            default: charset = "UTF-16";  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            return new String(bytes, 0, len, charset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        } catch (UnsupportedEncodingException e) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1091
            if (FontUtilities.isLogging()) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1092
                FontUtilities.getLogger().warning(e + " EncodingID=" + encoding);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            return new String(bytes, 0, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
        } catch (Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    protected void initNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        byte[] name = new byte[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        ByteBuffer buffer = getTableBuffer(nameTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        if (buffer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            ShortBuffer sbuffer = buffer.asShortBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            sbuffer.get(); // format - not needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            short numRecords = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            /* The name table uses unsigned shorts. Many of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
             * are known small values that fit in a short.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
             * The values that are sizes or offsets into the table could be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
             * greater than 32767, so read and store those as ints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            int stringPtr = sbuffer.get() & 0xffff;
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1115
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1116
            nameLocale = sun.awt.SunToolkit.getStartupLocale();
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1117
            short nameLocaleID = getLCIDFromLocale(nameLocale);
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1118
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            for (int i=0; i<numRecords; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                short platformID = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                if (platformID != MS_PLATFORM_ID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                    sbuffer.position(sbuffer.position()+5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                    continue; // skip over this record.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                short encodingID = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                short langID     = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                short nameID     = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                int nameLen    = ((int) sbuffer.get()) & 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                int namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1130
                String tmpName = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                switch (nameID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
                case FAMILY_NAME_ID:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1135
                    if (familyName == null || langID == ENGLISH_LOCALE_ID ||
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1136
                        langID == nameLocaleID)
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1137
                    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                        buffer.position(namePtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                        buffer.get(name, 0, nameLen);
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1140
                        tmpName = makeString(name, nameLen, encodingID);
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1141
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1142
                        if (familyName == null || langID == ENGLISH_LOCALE_ID){
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1143
                            familyName = tmpName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1144
                        }
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1145
                        if (langID == nameLocaleID) {
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1146
                            localeFamilyName = tmpName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1147
                        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                    for (int ii=0;ii<nameLen;ii++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                        int val = (int)name[ii]&0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                        System.err.print(Integer.toHexString(val)+ " ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                    System.err.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                    System.err.println("familyName="+familyName +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                                       " nameLen="+nameLen+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                                       " langID="+langID+ " eid="+encodingID +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                                       " str len="+familyName.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                case FULL_NAME_ID:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1165
                    if (fullName == null || langID == ENGLISH_LOCALE_ID ||
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1166
                        langID == nameLocaleID)
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1167
                    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
                        buffer.position(namePtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
                        buffer.get(name, 0, nameLen);
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1170
                        tmpName = makeString(name, nameLen, encodingID);
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1171
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1172
                        if (fullName == null || langID == ENGLISH_LOCALE_ID) {
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1173
                            fullName = tmpName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1174
                        }
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1175
                        if (langID == nameLocaleID) {
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1176
                            localeFullName = tmpName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1177
                        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
            }
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1182
            if (localeFamilyName == null) {
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1183
                localeFamilyName = familyName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1184
            }
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1185
            if (localeFullName == null) {
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1186
                localeFullName = fullName;
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1187
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
    /* Return the requested name in the requested locale, for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     * MS platform ID. If the requested locale isn't found, return US
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     * English, if that isn't found, return null and let the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     * figure out how to handle that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
    protected String lookupName(short findLocaleID, int findNameID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        String foundName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        byte[] name = new byte[1024];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        ByteBuffer buffer = getTableBuffer(nameTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        if (buffer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
            ShortBuffer sbuffer = buffer.asShortBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
            sbuffer.get(); // format - not needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
            short numRecords = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
            /* The name table uses unsigned shorts. Many of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
             * are known small values that fit in a short.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
             * The values that are sizes or offsets into the table could be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
             * greater than 32767, so read and store those as ints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
            int stringPtr = ((int) sbuffer.get()) & 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            for (int i=0; i<numRecords; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
                short platformID = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                if (platformID != MS_PLATFORM_ID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                    sbuffer.position(sbuffer.position()+5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                    continue; // skip over this record.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                short encodingID = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                short langID     = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                short nameID     = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                int   nameLen    = ((int) sbuffer.get()) & 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                int   namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                if (nameID == findNameID &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
                    ((foundName == null && langID == ENGLISH_LOCALE_ID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                     || langID == findLocaleID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                    buffer.position(namePtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
                    buffer.get(name, 0, nameLen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                    foundName = makeString(name, nameLen, encodingID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                    if (langID == findLocaleID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                        return foundName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        return foundName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * @return number of logical fonts. Is "1" for all but TTC files
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    public int getFontCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        return directoryCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
    protected synchronized FontScaler getScaler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        if (scaler == null) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1248
            scaler = FontScaler.getScaler(this, fontIndex,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
                supportsCJK, fileSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        return scaler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
    /* Postscript name is rarely requested. Don't waste cycles locating it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
     * as part of font creation, nor storage to hold it. Get it only on demand.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
     */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1258
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
    public String getPostscriptName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        String name = lookupName(ENGLISH_LOCALE_ID, POSTSCRIPT_NAME_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
            return fullName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
            return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1268
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
    public String getFontName(Locale locale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
        if (locale == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
            return fullName;
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1272
        } else if (locale.equals(nameLocale) && localeFullName != null) {
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1273
            return localeFullName;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
        } else {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1275
            short localeID = getLCIDFromLocale(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
            String name = lookupName(localeID, FULL_NAME_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
            if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
                return fullName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
                return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1285
    // Return a Microsoft LCID from the given Locale.
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1286
    // Used when getting localized font data.
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1287
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1288
    private static void addLCIDMapEntry(Map<String, Short> map,
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1289
                                        String key, short value) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1290
        map.put(key, Short.valueOf(value));
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1291
    }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1292
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1293
    private static synchronized void createLCIDMap() {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1294
        if (lcidMap != null) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1295
            return;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1296
        }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1297
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1298
        Map<String, Short> map = new HashMap<String, Short>(200);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1299
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1300
        // the following statements are derived from the langIDMap
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1301
        // in src/windows/native/java/lang/java_props_md.c using the following
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1302
        // awk script:
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1303
        //    $1~/\/\*/   { next}
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1304
        //    $3~/\?\?/   { next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1305
        //    $3!~/_/     { next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1306
        //    $1~/0x0409/ { next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1307
        //    $1~/0x0c0a/ { next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1308
        //    $1~/0x042c/ { next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1309
        //    $1~/0x0443/ { next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1310
        //    $1~/0x0812/ { next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1311
        //    $1~/0x04/   { print "        addLCIDMapEntry(map, " substr($3, 0, 3) "\", (short) " substr($1, 0, 6) ");" ; next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1312
        //    $3~/,/      { print "        addLCIDMapEntry(map, " $3  " (short) " substr($1, 0, 6) ");" ; next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1313
        //                { print "        addLCIDMapEntry(map, " $3 ", (short) " substr($1, 0, 6) ");" ; next }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1314
        // The lines of this script:
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1315
        // - eliminate comments
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1316
        // - eliminate questionable locales
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1317
        // - eliminate language-only locales
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1318
        // - eliminate the default LCID value
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1319
        // - eliminate a few other unneeded LCID values
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1320
        // - print language-only locale entries for x04* LCID values
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1321
        //   (apparently Microsoft doesn't use language-only LCID values -
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1322
        //   see http://www.microsoft.com/OpenType/otspec/name.htm
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1323
        // - print complete entries for all other LCID values
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1324
        // Run
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1325
        //     awk -f awk-script langIDMap > statements
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1326
        addLCIDMapEntry(map, "ar", (short) 0x0401);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1327
        addLCIDMapEntry(map, "bg", (short) 0x0402);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1328
        addLCIDMapEntry(map, "ca", (short) 0x0403);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1329
        addLCIDMapEntry(map, "zh", (short) 0x0404);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1330
        addLCIDMapEntry(map, "cs", (short) 0x0405);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1331
        addLCIDMapEntry(map, "da", (short) 0x0406);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1332
        addLCIDMapEntry(map, "de", (short) 0x0407);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1333
        addLCIDMapEntry(map, "el", (short) 0x0408);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1334
        addLCIDMapEntry(map, "es", (short) 0x040a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1335
        addLCIDMapEntry(map, "fi", (short) 0x040b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1336
        addLCIDMapEntry(map, "fr", (short) 0x040c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1337
        addLCIDMapEntry(map, "iw", (short) 0x040d);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1338
        addLCIDMapEntry(map, "hu", (short) 0x040e);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1339
        addLCIDMapEntry(map, "is", (short) 0x040f);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1340
        addLCIDMapEntry(map, "it", (short) 0x0410);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1341
        addLCIDMapEntry(map, "ja", (short) 0x0411);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1342
        addLCIDMapEntry(map, "ko", (short) 0x0412);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1343
        addLCIDMapEntry(map, "nl", (short) 0x0413);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1344
        addLCIDMapEntry(map, "no", (short) 0x0414);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1345
        addLCIDMapEntry(map, "pl", (short) 0x0415);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1346
        addLCIDMapEntry(map, "pt", (short) 0x0416);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1347
        addLCIDMapEntry(map, "rm", (short) 0x0417);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1348
        addLCIDMapEntry(map, "ro", (short) 0x0418);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1349
        addLCIDMapEntry(map, "ru", (short) 0x0419);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1350
        addLCIDMapEntry(map, "hr", (short) 0x041a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1351
        addLCIDMapEntry(map, "sk", (short) 0x041b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1352
        addLCIDMapEntry(map, "sq", (short) 0x041c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1353
        addLCIDMapEntry(map, "sv", (short) 0x041d);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1354
        addLCIDMapEntry(map, "th", (short) 0x041e);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1355
        addLCIDMapEntry(map, "tr", (short) 0x041f);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1356
        addLCIDMapEntry(map, "ur", (short) 0x0420);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1357
        addLCIDMapEntry(map, "in", (short) 0x0421);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1358
        addLCIDMapEntry(map, "uk", (short) 0x0422);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1359
        addLCIDMapEntry(map, "be", (short) 0x0423);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1360
        addLCIDMapEntry(map, "sl", (short) 0x0424);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1361
        addLCIDMapEntry(map, "et", (short) 0x0425);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1362
        addLCIDMapEntry(map, "lv", (short) 0x0426);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1363
        addLCIDMapEntry(map, "lt", (short) 0x0427);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1364
        addLCIDMapEntry(map, "fa", (short) 0x0429);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1365
        addLCIDMapEntry(map, "vi", (short) 0x042a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1366
        addLCIDMapEntry(map, "hy", (short) 0x042b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1367
        addLCIDMapEntry(map, "eu", (short) 0x042d);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1368
        addLCIDMapEntry(map, "mk", (short) 0x042f);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1369
        addLCIDMapEntry(map, "tn", (short) 0x0432);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1370
        addLCIDMapEntry(map, "xh", (short) 0x0434);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1371
        addLCIDMapEntry(map, "zu", (short) 0x0435);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1372
        addLCIDMapEntry(map, "af", (short) 0x0436);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1373
        addLCIDMapEntry(map, "ka", (short) 0x0437);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1374
        addLCIDMapEntry(map, "fo", (short) 0x0438);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1375
        addLCIDMapEntry(map, "hi", (short) 0x0439);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1376
        addLCIDMapEntry(map, "mt", (short) 0x043a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1377
        addLCIDMapEntry(map, "se", (short) 0x043b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1378
        addLCIDMapEntry(map, "gd", (short) 0x043c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1379
        addLCIDMapEntry(map, "ms", (short) 0x043e);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1380
        addLCIDMapEntry(map, "kk", (short) 0x043f);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1381
        addLCIDMapEntry(map, "ky", (short) 0x0440);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1382
        addLCIDMapEntry(map, "sw", (short) 0x0441);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1383
        addLCIDMapEntry(map, "tt", (short) 0x0444);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1384
        addLCIDMapEntry(map, "bn", (short) 0x0445);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1385
        addLCIDMapEntry(map, "pa", (short) 0x0446);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1386
        addLCIDMapEntry(map, "gu", (short) 0x0447);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1387
        addLCIDMapEntry(map, "ta", (short) 0x0449);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1388
        addLCIDMapEntry(map, "te", (short) 0x044a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1389
        addLCIDMapEntry(map, "kn", (short) 0x044b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1390
        addLCIDMapEntry(map, "ml", (short) 0x044c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1391
        addLCIDMapEntry(map, "mr", (short) 0x044e);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1392
        addLCIDMapEntry(map, "sa", (short) 0x044f);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1393
        addLCIDMapEntry(map, "mn", (short) 0x0450);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1394
        addLCIDMapEntry(map, "cy", (short) 0x0452);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1395
        addLCIDMapEntry(map, "gl", (short) 0x0456);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1396
        addLCIDMapEntry(map, "dv", (short) 0x0465);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1397
        addLCIDMapEntry(map, "qu", (short) 0x046b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1398
        addLCIDMapEntry(map, "mi", (short) 0x0481);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1399
        addLCIDMapEntry(map, "ar_IQ", (short) 0x0801);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1400
        addLCIDMapEntry(map, "zh_CN", (short) 0x0804);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1401
        addLCIDMapEntry(map, "de_CH", (short) 0x0807);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1402
        addLCIDMapEntry(map, "en_GB", (short) 0x0809);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1403
        addLCIDMapEntry(map, "es_MX", (short) 0x080a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1404
        addLCIDMapEntry(map, "fr_BE", (short) 0x080c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1405
        addLCIDMapEntry(map, "it_CH", (short) 0x0810);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1406
        addLCIDMapEntry(map, "nl_BE", (short) 0x0813);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1407
        addLCIDMapEntry(map, "no_NO_NY", (short) 0x0814);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1408
        addLCIDMapEntry(map, "pt_PT", (short) 0x0816);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1409
        addLCIDMapEntry(map, "ro_MD", (short) 0x0818);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1410
        addLCIDMapEntry(map, "ru_MD", (short) 0x0819);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1411
        addLCIDMapEntry(map, "sr_CS", (short) 0x081a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1412
        addLCIDMapEntry(map, "sv_FI", (short) 0x081d);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1413
        addLCIDMapEntry(map, "az_AZ", (short) 0x082c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1414
        addLCIDMapEntry(map, "se_SE", (short) 0x083b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1415
        addLCIDMapEntry(map, "ga_IE", (short) 0x083c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1416
        addLCIDMapEntry(map, "ms_BN", (short) 0x083e);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1417
        addLCIDMapEntry(map, "uz_UZ", (short) 0x0843);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1418
        addLCIDMapEntry(map, "qu_EC", (short) 0x086b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1419
        addLCIDMapEntry(map, "ar_EG", (short) 0x0c01);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1420
        addLCIDMapEntry(map, "zh_HK", (short) 0x0c04);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1421
        addLCIDMapEntry(map, "de_AT", (short) 0x0c07);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1422
        addLCIDMapEntry(map, "en_AU", (short) 0x0c09);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1423
        addLCIDMapEntry(map, "fr_CA", (short) 0x0c0c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1424
        addLCIDMapEntry(map, "sr_CS", (short) 0x0c1a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1425
        addLCIDMapEntry(map, "se_FI", (short) 0x0c3b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1426
        addLCIDMapEntry(map, "qu_PE", (short) 0x0c6b);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1427
        addLCIDMapEntry(map, "ar_LY", (short) 0x1001);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1428
        addLCIDMapEntry(map, "zh_SG", (short) 0x1004);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1429
        addLCIDMapEntry(map, "de_LU", (short) 0x1007);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1430
        addLCIDMapEntry(map, "en_CA", (short) 0x1009);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1431
        addLCIDMapEntry(map, "es_GT", (short) 0x100a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1432
        addLCIDMapEntry(map, "fr_CH", (short) 0x100c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1433
        addLCIDMapEntry(map, "hr_BA", (short) 0x101a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1434
        addLCIDMapEntry(map, "ar_DZ", (short) 0x1401);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1435
        addLCIDMapEntry(map, "zh_MO", (short) 0x1404);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1436
        addLCIDMapEntry(map, "de_LI", (short) 0x1407);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1437
        addLCIDMapEntry(map, "en_NZ", (short) 0x1409);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1438
        addLCIDMapEntry(map, "es_CR", (short) 0x140a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1439
        addLCIDMapEntry(map, "fr_LU", (short) 0x140c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1440
        addLCIDMapEntry(map, "bs_BA", (short) 0x141a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1441
        addLCIDMapEntry(map, "ar_MA", (short) 0x1801);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1442
        addLCIDMapEntry(map, "en_IE", (short) 0x1809);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1443
        addLCIDMapEntry(map, "es_PA", (short) 0x180a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1444
        addLCIDMapEntry(map, "fr_MC", (short) 0x180c);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1445
        addLCIDMapEntry(map, "sr_BA", (short) 0x181a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1446
        addLCIDMapEntry(map, "ar_TN", (short) 0x1c01);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1447
        addLCIDMapEntry(map, "en_ZA", (short) 0x1c09);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1448
        addLCIDMapEntry(map, "es_DO", (short) 0x1c0a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1449
        addLCIDMapEntry(map, "sr_BA", (short) 0x1c1a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1450
        addLCIDMapEntry(map, "ar_OM", (short) 0x2001);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1451
        addLCIDMapEntry(map, "en_JM", (short) 0x2009);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1452
        addLCIDMapEntry(map, "es_VE", (short) 0x200a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1453
        addLCIDMapEntry(map, "ar_YE", (short) 0x2401);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1454
        addLCIDMapEntry(map, "es_CO", (short) 0x240a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1455
        addLCIDMapEntry(map, "ar_SY", (short) 0x2801);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1456
        addLCIDMapEntry(map, "en_BZ", (short) 0x2809);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1457
        addLCIDMapEntry(map, "es_PE", (short) 0x280a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1458
        addLCIDMapEntry(map, "ar_JO", (short) 0x2c01);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1459
        addLCIDMapEntry(map, "en_TT", (short) 0x2c09);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1460
        addLCIDMapEntry(map, "es_AR", (short) 0x2c0a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1461
        addLCIDMapEntry(map, "ar_LB", (short) 0x3001);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1462
        addLCIDMapEntry(map, "en_ZW", (short) 0x3009);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1463
        addLCIDMapEntry(map, "es_EC", (short) 0x300a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1464
        addLCIDMapEntry(map, "ar_KW", (short) 0x3401);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1465
        addLCIDMapEntry(map, "en_PH", (short) 0x3409);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1466
        addLCIDMapEntry(map, "es_CL", (short) 0x340a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1467
        addLCIDMapEntry(map, "ar_AE", (short) 0x3801);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1468
        addLCIDMapEntry(map, "es_UY", (short) 0x380a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1469
        addLCIDMapEntry(map, "ar_BH", (short) 0x3c01);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1470
        addLCIDMapEntry(map, "es_PY", (short) 0x3c0a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1471
        addLCIDMapEntry(map, "ar_QA", (short) 0x4001);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1472
        addLCIDMapEntry(map, "es_BO", (short) 0x400a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1473
        addLCIDMapEntry(map, "es_SV", (short) 0x440a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1474
        addLCIDMapEntry(map, "es_HN", (short) 0x480a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1475
        addLCIDMapEntry(map, "es_NI", (short) 0x4c0a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1476
        addLCIDMapEntry(map, "es_PR", (short) 0x500a);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1477
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1478
        lcidMap = map;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1479
    }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1480
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1481
    private static short getLCIDFromLocale(Locale locale) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1482
        // optimize for common case
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1483
        if (locale.equals(Locale.US)) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1484
            return US_LCID;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1485
        }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1486
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1487
        if (lcidMap == null) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1488
            createLCIDMap();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1489
        }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1490
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1491
        String key = locale.toString();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1492
        while (!"".equals(key)) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1493
            Short lcidObject = (Short) lcidMap.get(key);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1494
            if (lcidObject != null) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1495
                return lcidObject.shortValue();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1496
            }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1497
            int pos = key.lastIndexOf('_');
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1498
            if (pos < 1) {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1499
                return US_LCID;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1500
            }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1501
            key = key.substring(0, pos);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1502
        }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1503
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1504
        return US_LCID;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1505
    }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1506
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1507
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
    public String getFamilyName(Locale locale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        if (locale == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
            return familyName;
3006
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1511
        } else if (locale.equals(nameLocale) && localeFamilyName != null) {
8201b60ec5eb 6806822: Font.getFontName() is slow in Java5 and 6
prr
parents: 2699
diff changeset
  1512
            return localeFamilyName;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
        } else {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1514
            short localeID = getLCIDFromLocale(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
            String name = lookupName(localeID, FAMILY_NAME_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
            if (name == null) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1517
                return familyName;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
                return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
    public CharToGlyphMapper getMapper() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
        if (mapper == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
            mapper = new TrueTypeGlyphMapper(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
        return mapper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
    /* This duplicates initNames() but that has to run fast as its used
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
     * during typical start-up and the information here is likely never
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
     * needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
    protected void initAllNames(int requestedID, HashSet names) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
        byte[] name = new byte[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
        ByteBuffer buffer = getTableBuffer(nameTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
        if (buffer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
            ShortBuffer sbuffer = buffer.asShortBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
            sbuffer.get(); // format - not needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
            short numRecords = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
            /* The name table uses unsigned shorts. Many of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
             * are known small values that fit in a short.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
             * The values that are sizes or offsets into the table could be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
             * greater than 32767, so read and store those as ints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
            int stringPtr = ((int) sbuffer.get()) & 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
            for (int i=0; i<numRecords; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
                short platformID = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
                if (platformID != MS_PLATFORM_ID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
                    sbuffer.position(sbuffer.position()+5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
                    continue; // skip over this record.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
                short encodingID = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
                short langID     = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
                short nameID     = sbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
                int   nameLen    = ((int) sbuffer.get()) & 0xffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
                int   namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
                if (nameID == requestedID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
                    buffer.position(namePtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
                    buffer.get(name, 0, nameLen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
                    names.add(makeString(name, nameLen, encodingID));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
    String[] getAllFamilyNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
        HashSet aSet = new HashSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
            initAllNames(FAMILY_NAME_ID, aSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
            /* In case of malformed font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
        return (String[])aSet.toArray(new String[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
    String[] getAllFullNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
        HashSet aSet = new HashSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
            initAllNames(FULL_NAME_ID, aSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
            /* In case of malformed font */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
        return (String[])aSet.toArray(new String[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    /*  Used by the OpenType engine for mark positioning.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
     */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1594
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
    Point2D.Float getGlyphPoint(long pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
                                int glyphCode, int ptNumber) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
            return getScaler().getGlyphPoint(pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
                                             glyphCode, ptNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
        } catch(FontScalerException fe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
    private char[] gaspTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
    private char[] getGaspTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
        if (gaspTable != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
            return gaspTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
        ByteBuffer buffer = getTableBuffer(gaspTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
        if (buffer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
            return gaspTable = new char[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
        CharBuffer cbuffer = buffer.asCharBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
        char format = cbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
        /* format "1" has appeared for some Windows Vista fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
         * Its presently undocumented but the existing values
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
         * seem to be still valid so we can use it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
        if (format > 1) { // unrecognised format
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
            return gaspTable = new char[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
        char numRanges = cbuffer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
        if (4+numRanges*4 > getTableSize(gaspTag)) { // sanity check
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
            return gaspTable = new char[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
        gaspTable = new char[2*numRanges];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
        cbuffer.get(gaspTable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
        return gaspTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
    /* This is to obtain info from the TT 'gasp' (grid-fitting and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
     * scan-conversion procedure) table which specifies three combinations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
     * Hint, Smooth (greyscale), Hint and Smooth.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
     * In this simplified scheme we don't distinguish the latter two. We
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
     * hint even at small sizes, so as to preserve metrics consistency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
     * If the information isn't available default values are substituted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
     * The more precise defaults we'd do if we distinguished the cases are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
     * Bold (no other style) fonts :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
     * 0-8 : Smooth ( do grey)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
     * 9+  : Hint + smooth (gridfit + grey)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
     * Plain, Italic and Bold-Italic fonts :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
     * 0-8 : Smooth ( do grey)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
     * 9-17 : Hint (gridfit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
     * 18+  : Hint + smooth (gridfit + grey)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
     * The defaults should rarely come into play as most TT fonts provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
     * better defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
     * REMIND: consider unpacking the table into an array of booleans
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
     * for faster use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
     */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1656
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
    public boolean useAAForPtSize(int ptsize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
        char[] gasp = getGaspTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
        if (gasp.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
            for (int i=0;i<gasp.length;i+=2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
                if (ptsize <= gasp[i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
                    return ((gasp[i+1] & 0x2) != 0); // bit 2 means DO_GRAY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
        if (style == Font.BOLD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
            return ptsize <= 8 || ptsize >= 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1676
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
    public boolean hasSupplementaryChars() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
        return ((TrueTypeGlyphMapper)getMapper()).hasSupplementaryChars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3006
diff changeset
  1681
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
        return "** TrueType Font: Family="+familyName+ " Name="+fullName+
8813
d15a9204c2f0 6985453: Font.createFont may expose some system properties in exception text
bae
parents: 5506
diff changeset
  1684
            " style="+style+" fileName="+getPublicFileName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
}