jdk/src/share/classes/sun/font/FontResolver.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 438 2ae294e4518c
child 3928 be186a33df9b
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 438
diff changeset
     2
 * Portions Copyright 1999-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1999,  All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
package sun.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.font.TextAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.text.CodePointIterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * This class maps an individual character to a Font family which can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * display it.  The character-to-Font mapping does not depend on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * character's context, so a particular character will be mapped to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * same font family each time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Typically, clients will call getIndexFor(char) for each character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * in a style run.  When getIndexFor() returns a different value from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * ones seen previously, the characters up to that point will be assigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * a font obtained from getFont().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public final class FontResolver {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    // An array of all fonts available to the runtime.  The fonts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    // will be searched in order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private Font[] allFonts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private Font[] supplementaryFonts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private int[]  supplementaryIndices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    // Default size of Fonts (if created from an empty Map, for instance).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static final int DEFAULT_SIZE = 12; // from Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, DEFAULT_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // The results of previous lookups are cached in a two-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // table.  The value for a character c is found in:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    //     blocks[c>>SHIFT][c&MASK]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // although the second array is only allocated when needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // A 0 value means the character's font has not been looked up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // A positive value means the character's font is in the allFonts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // array at index (value-1).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private static final int SHIFT = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private static final int BLOCKSIZE = 1<<(16-SHIFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static final int MASK = BLOCKSIZE-1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private int[][] blocks = new int[1<<SHIFT][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private FontResolver() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private Font[] getAllFonts() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        if (allFonts == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            allFonts =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            for (int i=0; i < allFonts.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                allFonts[i] = allFonts[i].deriveFont((float)DEFAULT_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        return allFonts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Search fonts in order, and return "1" to indicate its in the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * font, (or not found at all),  or the index of the first font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * which can display the given character, plus 2, if it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * in the default font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private int getIndexFor(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        if (defaultFont.canDisplay(c)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        for (int i=0; i < getAllFonts().length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            if (allFonts[i].canDisplay(c)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                return i+2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private Font [] getAllSCFonts() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (supplementaryFonts == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            ArrayList<Font> fonts = new ArrayList<Font>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            ArrayList<Integer> indices = new ArrayList<Integer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            for (int i=0; i<getAllFonts().length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                Font font = allFonts[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                Font2D font2D = FontManager.getFont2D(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                if (font2D.hasSupplementaryChars()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    fonts.add(font);
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   120
                    indices.add(Integer.valueOf(i));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            int len = fonts.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            supplementaryIndices = new int[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            for (int i=0; i<len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                supplementaryIndices[i] = indices.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            supplementaryFonts = fonts.toArray(new Font[len]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return supplementaryFonts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /* This method is called only for character codes >= 0x10000 - which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * are assumed to be legal supplementary characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * It looks first at the default font (to avoid calling getAllFonts if at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * all possible) and if that doesn't map the code point, it scans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * just the fonts that may contain supplementary characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * The index that is returned is into the "allFonts" array so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * callers see the same value for both supplementary and base chars.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    private int getIndexFor(int cp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (defaultFont.canDisplay(cp)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        for (int i = 0; i < getAllSCFonts().length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            if (supplementaryFonts[i].canDisplay(cp)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                return supplementaryIndices[i]+2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Return an index for the given character.  The index identifies a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * font family to getFont(), and has no other inherent meaning.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @param c the character to map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @return a value for consumption by getFont()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @see #getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public int getFontIndex(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        int blockIndex = c>>SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        int[] block = blocks[blockIndex];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        if (block == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            block = new int[BLOCKSIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            blocks[blockIndex] = block;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        int index = c & MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (block[index] == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            block[index] = getIndexFor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return block[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public int getFontIndex(int cp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (cp < 0x10000) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            return getFontIndex((char)cp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return getIndexFor(cp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Determines the font index for the code point at the current position in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * iterator, then advances the iterator to the first code point that has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * a different index or until the iterator is DONE, and returns the font index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param iter a code point iterator, this will be advanced past any code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *             points that have the same font index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @return the font index for the initial code point found, or 1 if the iterator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * was empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public int nextFontRunIndex(CodePointIterator iter) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        int cp = iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        int fontIndex = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (cp != CodePointIterator.DONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            fontIndex = getFontIndex(cp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            while ((cp = iter.next()) != CodePointIterator.DONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                if (getFontIndex(cp) != fontIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                    iter.prev();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return fontIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Return a Font from a given font index with properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * from attributes.  The font index, which should have been produced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * by getFontIndex(), determines a font family.  The size and style
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * of the Font reflect the properties in attributes.  Any Font or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * font family specifications in attributes are ignored, on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * assumption that clients have already handled them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @param index an index from getFontIndex() which determines the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *        font family
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @param attributes a Map from which the size and style of the Font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *        are determined.  The default size is 12 and the default style
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *        is Font.PLAIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @see #getFontIndex
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    public Font getFont(int index, Map attributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        Font font = defaultFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        if (index >= 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            font = allFonts[index-2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return font.deriveFont(attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    private static FontResolver INSTANCE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * Return a shared instance of FontResolver.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public static FontResolver getInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (INSTANCE == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            INSTANCE = new FontResolver();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return INSTANCE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
}