jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java
author tdv
Fri, 12 Sep 2008 15:01:45 -0700
changeset 1724 a22a286aa16f
parent 889 6549643c008c
child 3928 be186a33df9b
permissions -rw-r--r--
6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal Reviewed-by: prr, tdv Contributed-by: rkennke@kennke.org
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: 557
diff changeset
     2
 * Copyright 1997-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
package sun.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.BufferedReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.FileReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.FileNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.StreamTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.net.InetAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.net.NetworkInterface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.net.SocketException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.net.UnknownHostException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.util.logging.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.awt.motif.MFontConfiguration;
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
    47
import sun.font.FcFontConfiguration;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import sun.font.Font2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import sun.font.FontManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import sun.font.NativeFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import sun.java2d.SunGraphicsEnvironment;
557
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 2
diff changeset
    52
import sun.java2d.SurfaceManagerFactory;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 2
diff changeset
    53
import sun.java2d.UnixSurfaceManagerFactory;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * This is an implementation of a GraphicsEnvironment object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * default local GraphicsEnvironment used by the Java Runtime Environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * for X11 environments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @see GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
public class X11GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    extends SunGraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private static final Logger log = Logger.getLogger("sun.awt.X11GraphicsEnvironment");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final Logger screenLog = Logger.getLogger("sun.awt.screen.X11GraphicsEnvironment");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private static Boolean xinerState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * This is the set of font directories needed to be on the X font path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * to enable AWT heavyweights to find all of the font configuration fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * It is populated by :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * - awtfontpath entries in the fontconfig.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * - parent directories of "core" fonts used in the fontconfig.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * - looking up font dirs in the xFontDirsMap where the key is a fontID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *   (cut down version of the XLFD read from the font configuration file).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * This set is nulled out after use to free heap space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static HashSet<String> fontConfigDirs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
   /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    * fontNameMap is a map from a fontID (which is a substring of an XLFD like
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    * "-monotype-arial-bold-r-normal-iso8859-7")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    * to font file path like
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    * /usr/openwin/lib/locale/iso_8859_7/X11/fonts/TrueType/ArialBoldItalic.ttf
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    * It's used in a couple of methods like
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    * getFileNameFomPlatformName(..) to help locate the font file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    * We use this substring of a full XLFD because the font configuration files
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    * define the XLFDs in a way that's easier to make into a request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    * E.g., the -0-0-0-0-p-0- reported by X is -*-%d-*-*-p-*- in the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    * configuration files. We need to remove that part for comparisons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    private static Map fontNameMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /* xFontDirsMap is also a map from a font ID to a font filepath.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * The difference from fontNameMap is just that it does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * resolved symbolic links. Normally this is not interesting except
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * that we need to know the directory in which a font was found to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * add it to the X font server path, since although the files may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * be linked, the fonts.dir is different and specific to the encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * handled by that directory. This map is nulled out after use to free
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * heap space. If the optimal path is taken, such that all fonts in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * font configuration files are referenced by filename, then the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * dir can be directly derived as its parent directory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * If a font is used by two XLFDs, each corresponding to a different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * X11 font directory, then precautions must be taken to include both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * directories.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     private static Map xFontDirsMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * xlfdMap is a map from a platform path like
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * /usr/openwin/lib/locale/ja/X11/fonts/TT/HG-GothicB.ttf to an XLFD like
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Because there may be multiple native names, because the font is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * to support multiple X encodings for example, the value of an entry in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * this map is always a vector where we store all the native names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * For fonts which we don't understand the key isn't a pathname, its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * the full XLFD string like :-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     private static Map xlfdMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Used to eliminate redundant work. When a font directory is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * registered it added to this list. Subsequent registrations for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * same directory can then be skipped by checking this Map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Access to this map is not synchronised here since creation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * of the singleton GE instance is already synchronised and that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * the only code path that accesses this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     private static HashMap registeredDirs = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /* Array of directories to be added to the X11 font path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Used by static method called from Toolkits which use X11 fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Specifically this means MToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    private static String[] fontdirs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                          new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                System.loadLibrary("awt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                 * Note: The MToolkit object depends on the static initializer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                 * of X11GraphicsEnvironment to initialize the connection to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                 * the X11 server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                if (!isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                    // first check the OGL system property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                    boolean glxRequested = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    String prop = System.getProperty("sun.java2d.opengl");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    if (prop != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                        if (prop.equals("true") || prop.equals("t")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                            glxRequested = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                        } else if (prop.equals("True") || prop.equals("T")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                            glxRequested = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                            glxVerbose = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    // initialize the X11 display connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    initDisplay(glxRequested);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    // only attempt to initialize GLX if it was requested
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    if (glxRequested) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                        glxAvailable = initGLX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                        if (glxVerbose && !glxAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                            System.out.println(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                "Could not enable OpenGL " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                "pipeline (GLX 1.3 not available)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
         });
557
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 2
diff changeset
   183
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 2
diff changeset
   184
        // Install the correct surface manager factory.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 2
diff changeset
   185
        SurfaceManagerFactory.setInstance(new UnixSurfaceManagerFactory());
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 2
diff changeset
   186
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    private static boolean glxAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    private static boolean glxVerbose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    private static native boolean initGLX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public static boolean isGLXAvailable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        return glxAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public static boolean isGLXVerbose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return glxVerbose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Checks if Shared Memory extension can be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * Returns:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *   -1 if server doesn't support MITShm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *    1 if server supports it and it can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *    0 otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    private static native int checkShmExt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    private static  native String getDisplayString();
1724
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 889
diff changeset
   212
    private Boolean isDisplayLocal;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * This should only be called from the static initializer, so no need for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * the synchronized keyword.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    private static native void initDisplay(boolean glxRequested);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public X11GraphicsEnvironment() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    protected native int getNumScreens();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    protected GraphicsDevice makeScreenDevice(int screennum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        return new X11GraphicsDevice(screennum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    protected native int getDefaultScreenNum();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * Returns the default screen graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    public GraphicsDevice getDefaultScreenDevice() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        return getScreenDevices()[getDefaultScreenNum()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
1724
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 889
diff changeset
   237
    @Override
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 889
diff changeset
   238
    public boolean isDisplayLocal() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        if (isDisplayLocal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            SunToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                if (isDisplayLocal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                    isDisplayLocal = Boolean.valueOf(_isDisplayLocal());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                SunToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return isDisplayLocal.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    private static boolean _isDisplayLocal() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if (isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        String isRemote = (String)java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            new sun.security.action.GetPropertyAction("sun.java2d.remote"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        if (isRemote != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            return isRemote.equals("false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        int shm = checkShmExt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        if (shm != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            return (shm == 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        // If XServer doesn't support ShMem extension,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        // try the other way
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        String display = getDisplayString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        int ind = display.indexOf(':');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        final String hostName = display.substring(0, ind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        if (ind <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            // ':0' case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        Boolean result = (Boolean)java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            new java.security.PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                InetAddress remAddr[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                Enumeration locals = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                Enumeration interfaces = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                    interfaces = NetworkInterface.getNetworkInterfaces();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                    remAddr = InetAddress.getAllByName(hostName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                    if (remAddr == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                        return Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                } catch (UnknownHostException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                    System.err.println("Unknown host: " + hostName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    return Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                } catch (SocketException e1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    System.err.println(e1.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    return Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                for (; interfaces.hasMoreElements();) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                    locals = ((NetworkInterface)interfaces.nextElement()).getInetAddresses();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                    for (; locals.hasMoreElements();) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                        for (int i = 0; i < remAddr.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                            if (locals.nextElement().equals(remAddr[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                return Boolean.TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                return Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            }});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        return result.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    /* These maps are used on Linux where we reference the Lucida oblique
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * fonts in fontconfig files even though they aren't in the standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * font directory. This explicitly remaps the XLFDs for these to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * correct base font. This is needed to prevent composite fonts from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * defaulting to the Lucida Sans which is a bad substitute for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * monospaced Lucida Sans Typewriter. Also these maps prevent the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * JRE from doing wasted work at start up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    HashMap<String, String> oblmap = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    private String getObliqueLucidaFontID(String fontID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        if (fontID.startsWith("-lucidasans-medium-i-normal") ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            fontID.startsWith("-lucidasans-bold-i-normal") ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            fontID.startsWith("-lucidatypewriter-medium-i-normal") ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            fontID.startsWith("-lucidatypewriter-bold-i-normal")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            return fontID.substring(0, fontID.indexOf("-i-"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
   private void initObliqueLucidaFontMap() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
       oblmap = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
       oblmap.put("-lucidasans-medium",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                  jreLibDirName+"/fonts/LucidaSansRegular.ttf");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
       oblmap.put("-lucidasans-bold",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                  jreLibDirName+"/fonts/LucidaSansDemiBold.ttf");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
       oblmap.put("-lucidatypewriter-medium",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                  jreLibDirName+"/fonts/LucidaTypewriterRegular.ttf");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
       oblmap.put("-lucidatypewriter-bold",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                  jreLibDirName+"/fonts/LucidaTypewriterBold.ttf");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * Takes family name property in the following format:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * "-linotype-helvetica-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * and returns the name of the corresponding physical font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * This code is used to resolve font configuration fonts, and expects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * only to get called for these fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public String getFileNameFromPlatformName(String platName) {
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   355
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   356
        /* If the FontConfig file doesn't use xlfds, or its
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   357
         * FcFontConfiguration, this may be already a file name.
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   358
         */
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   359
        if (platName.startsWith("/")) {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   360
            return platName;
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   361
        }
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   362
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        String fileName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        String fontID = specificFontIDForName(platName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        /* If the font filename has been explicitly assigned in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
         * font configuration file, use it. This avoids accessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
         * the wrong fonts on Linux, where different fonts (some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
         * of which may not be usable by 2D) may share the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
         * specific font ID. It may also speed up the lookup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        fileName = super.getFileNameFromPlatformName(platName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        if (fileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            if (isHeadless() && fileName.startsWith("-")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                /* if it's headless, no xlfd should be used */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            if (fileName.startsWith("/")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                /* If a path is assigned in the font configuration file,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                 * it is required that the config file also specify using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                 * new awtfontpath key the X11 font directories
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                 * which must be added to the X11 font path to support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                 * AWT access to that font. For that reason we no longer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                 * have code here to add the parent directory to the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                 * of font config dirs, since the parent directory may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                 * be sufficient if fonts are symbolically linked to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                 * different directory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                 * Add this XLFD (platform name) to the list of known
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                 * ones for this file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                Vector xVal = (Vector) xlfdMap.get(fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                if (xVal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                    /* Try to be robust on Linux distros which move fonts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                     * around by verifying that the fileName represents a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                     * file that exists.  If it doesn't, set it to null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                     * to trigger a search.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                    if (getFontConfiguration().needToSearchForFile(fileName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                        fileName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    if (fileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                        xVal = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                        xVal.add(platName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                        xlfdMap.put(fileName, xVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                    if (!xVal.contains(platName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                        xVal.add(platName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            if (fileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                fontNameMap.put(fontID, fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                return fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        if (fontID != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            fileName = (String)fontNameMap.get(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            /* On Linux check for the Lucida Oblique fonts */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            if (fileName == null && isLinux && !isOpenJDK()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                if (oblmap == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                    initObliqueLucidaFontMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                String oblkey = getObliqueLucidaFontID(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                if (oblkey != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                    fileName = oblmap.get(oblkey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            if (fontPath == null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                (fileName == null || !fileName.startsWith("/"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                    logger.warning("** Registering all font paths because " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                                   "can't find file for " + platName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                fontPath = getPlatformFontPath(noType1Font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                registerFontDirs(fontPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    logger.warning("** Finished registering all font paths");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                fileName = (String)fontNameMap.get(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            if (fileName == null && !isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                /* Query X11 directly to see if this font is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                 * as a native font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                fileName = getX11FontName(platName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            if (fileName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                fontID = switchFontIDForName(platName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                fileName = (String)fontNameMap.get(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            if (fileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                fontNameMap.put(fontID, fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        return fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    private static String getX11FontName(String platName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        String xlfd = platName.replaceAll("%d", "*");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        if (NativeFont.fontExists(xlfd)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            return xlfd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * Returns the face name for the given XLFD.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public String getFileNameFromXLFD(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        String fileName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        String fontID = specificFontIDForName(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        if (fontID != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            fileName = (String)fontNameMap.get(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            if (fileName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                fontID = switchFontIDForName(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                fileName = (String)fontNameMap.get(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            if (fileName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                fileName = getDefaultFontFile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        return fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    // constants identifying XLFD and font ID fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    private static final int FOUNDRY_FIELD = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    private static final int FAMILY_NAME_FIELD = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    private static final int WEIGHT_NAME_FIELD = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    private static final int SLANT_FIELD = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    private static final int SETWIDTH_NAME_FIELD = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    private static final int ADD_STYLE_NAME_FIELD = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    private static final int PIXEL_SIZE_FIELD = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    private static final int POINT_SIZE_FIELD = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    private static final int RESOLUTION_X_FIELD = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    private static final int RESOLUTION_Y_FIELD = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    private static final int SPACING_FIELD = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    private static final int AVERAGE_WIDTH_FIELD = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    private static final int CHARSET_REGISTRY_FIELD = 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    private static final int CHARSET_ENCODING_FIELD = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    private String switchFontIDForName(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        int[] hPos = new int[14];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        int hyphenCnt = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        int pos = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        while (pos != -1 && hyphenCnt < 14) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            pos = name.indexOf('-', pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            if (pos != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                hPos[hyphenCnt++] = pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                    pos++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        if (hyphenCnt != 14) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                logger.severe("Font Configuration Font ID is malformed:" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            return name; // what else can we do?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        String slant = name.substring(hPos[SLANT_FIELD-1]+1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                                           hPos[SLANT_FIELD]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        String family = name.substring(hPos[FAMILY_NAME_FIELD-1]+1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                                           hPos[FAMILY_NAME_FIELD]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        String registry = name.substring(hPos[CHARSET_REGISTRY_FIELD-1]+1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                                           hPos[CHARSET_REGISTRY_FIELD]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        String encoding = name.substring(hPos[CHARSET_ENCODING_FIELD-1]+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        if (slant.equals("i")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            slant = "o";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        } else if (slant.equals("o")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            slant = "i";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        // workaround for #4471000
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        if (family.equals("itc zapfdingbats")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            && registry.equals("sun")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            && encoding.equals("fontspecific")){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            registry = "adobe";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        StringBuffer sb =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            new StringBuffer(name.substring(hPos[FAMILY_NAME_FIELD-1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                                            hPos[SLANT_FIELD-1]+1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        sb.append(slant);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        sb.append(name.substring(hPos[SLANT_FIELD],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                                 hPos[SETWIDTH_NAME_FIELD]+1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        sb.append(registry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        sb.append(name.substring(hPos[CHARSET_ENCODING_FIELD-1]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        String retval = sb.toString().toLowerCase (Locale.ENGLISH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    private String specificFontIDForName(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        int[] hPos = new int[14];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        int hyphenCnt = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        int pos = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        while (pos != -1 && hyphenCnt < 14) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            pos = name.indexOf('-', pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            if (pos != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                hPos[hyphenCnt++] = pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                    pos++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        if (hyphenCnt != 14) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                logger.severe("Font Configuration Font ID is malformed:" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            return name; // what else can we do?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        StringBuffer sb =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            new StringBuffer(name.substring(hPos[FAMILY_NAME_FIELD-1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                                            hPos[SETWIDTH_NAME_FIELD]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        sb.append(name.substring(hPos[CHARSET_REGISTRY_FIELD-1]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        String retval = sb.toString().toLowerCase (Locale.ENGLISH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    protected String[] getNativeNames(String fontFileName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                                      String platformName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        Vector nativeNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            if (platformName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                /* back-stop so that at least the name used in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                 * font configuration file is known as a native name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                String []natNames = new String[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                natNames[0] = platformName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                return natNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            int len = nativeNames.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            return (String[])nativeNames.toArray(new String[len]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    // An X font spec (xlfd) includes an encoding. The same TrueType font file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    // may be referenced from different X font directories in font.dir files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    // to support use in multiple encodings by X apps.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    // So for the purposes of font configuration logical fonts where AWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    // heavyweights need to access the font via X APIs we need to ensure that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    // the directory for precisely the encodings needed by this are added to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    // the x font path. This requires that we note the platform names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    // specified in font configuration files and use that to identify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    // X font directory that contains a font.dir file for that platform name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    // and add it to the X font path (if display is local)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    // Here we make use of an already built map of xlfds to font locations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    // to add the font location to the set of those required to build the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    // x font path needed by AWT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    // These are added to the x font path later.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    // All this is necessary because on Solaris the font.dir directories
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    // may contain not real font files, but symbolic links to the actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    // location but that location is not suitable for the x font path, since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    // it probably doesn't have a font.dir at all and certainly not one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    // with the required encodings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    // If the fontconfiguration file is properly set up so that all fonts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    // are mapped to files then we will never trigger initialising
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    // xFontDirsMap (it will be null). In this case the awtfontpath entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    // must specify all the X11 directories needed by AWT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    protected void addFontToPlatformFontPath(String platformName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        if (xFontDirsMap != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            String fontID = specificFontIDForName(platformName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            String dirName = (String)xFontDirsMap.get(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            if (dirName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                fontConfigDirs.add(dirName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    protected void getPlatformFontPathFromFontConfig() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        if (fontConfigDirs == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            fontConfigDirs = getFontConfiguration().getAWTFontPathSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            if (debugFonts && fontConfigDirs != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                String[] names = fontConfigDirs.toArray(new String[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                for (int i=0;i<names.length;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                    logger.info("awtfontpath : " + names[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    protected void registerPlatformFontsUsedByFontConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        if (fontConfigDirs == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        if (isLinux) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            fontConfigDirs.add(jreLibDirName+File.separator+"oblique-fonts");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        fontdirs = (String[])fontConfigDirs.toArray(new String[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    /* Called by MToolkit to set the X11 font path */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    public static void setNativeFontPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        if (fontdirs == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        // need to register these individually rather than by one call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        // to ensure that one bad directory doesn't cause all to be rejected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        for (int i=0; i<fontdirs.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                logger.info("Add " + fontdirs[i] + " to X11 fontpath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            FontManager.setNativeFontPath(fontdirs[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    /* Register just the paths, (it doesn't register the fonts).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * If a font configuration file has specified a baseFontPath
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * fontPath is just those directories, unless on usage we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * find it doesn't contain what we need for the logical fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * Otherwise, we register all the paths on Solaris, because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * the fontPath we have here is the complete one from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * parsing /var/sadm/install/contents, not just
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * what's on the X font path (may be this should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * changed).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * But for now what it means is that if we didn't do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * this then if the font weren't listed anywhere on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * less complete font path we'd trigger loadFonts which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * actually registers the fonts. This may actually be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * the right thing tho' since that would also set up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * the X font path without which we wouldn't be able to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * display some "native" fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * So something to revisit is that probably fontPath
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * here ought to be only the X font path + jre font dir.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * loadFonts should have a separate native call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * get the rest of the platform font path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * Registering the directories can now be avoided in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * font configuration initialisation when filename entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * exist in the font configuration file for all fonts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * (Perhaps a little confusingly a filename entry is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * actually keyed using the XLFD used in the font entries,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * and it maps *to* a real filename).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * In the event any are missing, registration of all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * directories will be invoked to find the real files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * But registering the directory performed other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * functions such as filling in the map of all native names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * for the font. So when this method isn't invoked, they still
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * must be found. This is mitigated by getNativeNames now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * being able to return at least the platform name, but mostly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * by ensuring that when a filename key is found, that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * xlfd key is stored as one of the set of platform names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * for the font. Its a set because typical font configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * files reference the same CJK font files using multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * X11 encodings. For the code that adds this to the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * see X11GE.getFileNameFromPlatformName(..)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * If you don't get all of these then some code points may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * not use the Xserver, and will not get the PCF bitmaps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * that are available for some point sizes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * So, in the event that there is such a problem,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * unconditionally making this call may be necessary, at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * some cost to JRE start-up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    protected void registerFontDirs(String pathName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        StringTokenizer parser = new StringTokenizer(pathName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                                                     File.pathSeparator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            while (parser.hasMoreTokens()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                String dirPath = parser.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                if (dirPath != null && !registeredDirs.containsKey(dirPath)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                    registeredDirs.put(dirPath, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                    registerFontDir(dirPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        } catch (NoSuchElementException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    /* NOTE: this method needs to be executed in a privileged context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * The superclass constructor which is the primary caller of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * this method executes entirely in such a context. Additionally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * the loadFonts() method does too. So all should be well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    protected void registerFontDir(String path) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        /* fonts.dir file format looks like :-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
         * 47
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
         * Arial.ttf -monotype-arial-regular-r-normal--0-0-0-0-p-0-iso8859-1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
         * Arial-Bold.ttf -monotype-arial-bold-r-normal--0-0-0-0-p-0-iso8859-1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
         * ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            logger.info("ParseFontDir " + path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        File fontsDotDir = new File(path + File.separator + "fonts.dir");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        FileReader fr = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            if (fontsDotDir.canRead()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                fr = new FileReader(fontsDotDir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                BufferedReader br = new BufferedReader(fr, 8192);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                StreamTokenizer st = new StreamTokenizer(br);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                st.eolIsSignificant(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                int ttype = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                if (ttype == StreamTokenizer.TT_NUMBER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                    int numEntries = (int)st.nval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                    ttype = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                    if (ttype == StreamTokenizer.TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                        st.resetSyntax();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                        st.wordChars(32, 127);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                        st.wordChars(128 + 32, 255);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                        st.whitespaceChars(0, 31);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                        for (int i=0; i < numEntries; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                            ttype = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                            if (ttype == StreamTokenizer.TT_EOF) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                            if (ttype != StreamTokenizer.TT_WORD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                            int breakPos = st.sval.indexOf(' ');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                            if (breakPos <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                                /* On TurboLinux 8.0 a fonts.dir file had
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                                 * a line with integer value "24" which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                                 * appeared to be the number of remaining
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                                 * entries in the file. This didn't add to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                                 * the value on the first line of the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                                 * Seemed like XFree86 didn't like this line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                                 * much either. It failed to parse the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                                 * Ignore lines like this completely, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                                 * don't let them count as an entry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                                numEntries++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                                ttype = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                                if (ttype != StreamTokenizer.TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                            if (st.sval.charAt(0) == '!') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                                /* TurboLinux 8.0 comment line: ignore.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                                 * can't use st.commentChar('!') to just
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                                 * skip because this line mustn't count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                                 * against numEntries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                                numEntries++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                                ttype = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                                if (ttype != StreamTokenizer.TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                            String fileName = st.sval.substring(0, breakPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
                            /* TurboLinux 8.0 uses some additional syntax to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
                             * indicate algorithmic styling values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                             * Ignore ':' separated files at the beginning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                             * of the fileName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                            int lastColon = fileName.lastIndexOf(':');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                            if (lastColon > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                                if (lastColon+1 >= fileName.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                                fileName = fileName.substring(lastColon+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                            String fontPart = st.sval.substring(breakPos+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                            String fontID = specificFontIDForName(fontPart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                            String sVal = (String) fontNameMap.get(fontID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                            if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                                logger.info("file=" + fileName +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                                            " xlfd=" + fontPart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                                logger.info("fontID=" + fontID +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                                            " sVal=" + sVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                            String fullPath = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                                File file = new File(path,fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                                /* we may have a resolved symbolic link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                                 * this becomes important for an xlfd we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                                 * still need to know the location it was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                                 * found to update the X server font path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                                 * for use by AWT heavyweights - and when 2D
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                                 * wants to use the native rasteriser.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                                if (xFontDirsMap == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                                    xFontDirsMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                                xFontDirsMap.put(fontID, path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                                fullPath = file.getCanonicalPath();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                                fullPath = path + File.separator + fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                            Vector xVal = (Vector) xlfdMap.get(fullPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                            if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                                logger.info("fullPath=" + fullPath +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                                            " xVal=" + xVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                            if ((xVal == null || !xVal.contains(fontPart)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                                (sVal == null) || !sVal.startsWith("/")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                                if (debugFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                                    logger.info("Map fontID:"+fontID +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                                                "to file:" + fullPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                                fontNameMap.put(fontID, fullPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                                if (xVal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                                    xVal = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                                    xlfdMap.put (fullPath, xVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
                                xVal.add(fontPart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                            ttype = st.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                            if (ttype != StreamTokenizer.TT_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                fr.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        } catch (IOException ioe1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            if (fr != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                    fr.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                }  catch (IOException ioe2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    public void loadFonts() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        super.loadFonts();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        /* These maps are greatly expanded during a loadFonts but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
         * can be reset to their initial state afterwards.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
         * Since preferLocaleFonts() and preferProportionalFonts() will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
         * trigger a partial repopulating from the FontConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
         * it has to be the inital (empty) state for the latter two, not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
         * simply nulling out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
         * xFontDirsMap is a special case in that the implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
         * will typically not ever need to initialise it so it can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        xFontDirsMap = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        xlfdMap = new HashMap(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        fontNameMap = new HashMap(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    // Implements SunGraphicsEnvironment.createFontConfiguration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    protected FontConfiguration createFontConfiguration() {
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   918
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   919
        /* The logic here decides whether to use a preconfigured
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   920
         * fontconfig.properties file, or synthesise one using platform APIs.
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   921
         * On Solaris (as opposed to OpenSolaris) we try to use the
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   922
         * pre-configured ones, but if the files it specifies are missing
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   923
         * we fail-safe to synthesising one. This might happen if Solaris
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   924
         * changes its fonts.
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   925
         * For OpenSolaris I don't expect us to ever create fontconfig files,
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   926
         * so it will always synthesise. Note that if we misidentify
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   927
         * OpenSolaris as Solaris, then the test for the presence of
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   928
         * Solaris-only font files will correct this.
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   929
         * For Linux we require an exact match of distro and version to
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   930
         * use the preconfigured file, and also that it points to
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   931
         * existent fonts.
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   932
         * If synthesising fails, we fall back to any preconfigured file
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   933
         * and do the best we can. For the commercial JDK this will be
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   934
         * fine as it includes the Lucida fonts. OpenJDK should not hit
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   935
         * this as the synthesis should always work on its platforms.
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   936
         */
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   937
        FontConfiguration mFontConfig = new MFontConfiguration(this);
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   938
        if (isOpenSolaris ||
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   939
            (isLinux &&
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   940
             (!mFontConfig.foundOsSpecificFile() ||
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   941
              !mFontConfig.fontFilesArePresent()) ||
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   942
             (isSolaris && !mFontConfig.fontFilesArePresent()))) {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   943
            FcFontConfiguration fcFontConfig =
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   944
                new FcFontConfiguration(this);
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   945
            if (fcFontConfig.init()) {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   946
                return fcFontConfig;
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   947
            }
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   948
        }
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   949
        mFontConfig.init();
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   950
        return mFontConfig;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    public FontConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        createFontConfiguration(boolean preferLocaleFonts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                                boolean preferPropFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   956
        FontConfiguration config = getFontConfiguration();
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   957
        if (config instanceof FcFontConfiguration) {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   958
            // Doesn't need to implement the alternate support.
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   959
            return config;
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   960
        }
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   961
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        return new MFontConfiguration(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                                      preferLocaleFonts, preferPropFonts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     * Returns face name for default font, or null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     * no face names are used for CompositeFontDescriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     * for this platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    public String getDefaultFontFaceName() {
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   972
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    private static native boolean pRunningXinerama();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    private static native Point getXineramaCenterPoint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * Override for Xinerama case: call new Solaris API for getting the correct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * centering point from the windowing system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    public Point getCenterPoint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        if (runningXinerama()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            Point p = getXineramaCenterPoint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
            if (p != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
        return super.getCenterPoint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * Override for Xinerama case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    public Rectangle getMaximumWindowBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
        if (runningXinerama()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
            return getXineramaWindowBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            return super.getMaximumWindowBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    public boolean runningXinerama() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        if (xinerState == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
            // pRunningXinerama() simply returns a global boolean variable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            // so there is no need to synchronize here
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
            xinerState = Boolean.valueOf(pRunningXinerama());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            if (screenLog.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                screenLog.log(Level.FINER, "Running Xinerama: " + xinerState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
        return xinerState.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * Return the bounds for a centered Window on a system running in Xinerama
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * Calculations are based on the assumption of a perfectly rectangular
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * display area (display edges line up with one another, and displays
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * have consistent width and/or height).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * The bounds to return depend on the arrangement of displays and on where
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * Windows are to be centered.  There are two common situations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * 1) The center point lies at the center of the combined area of all the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     *    displays.  In this case, the combined area of all displays is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     *    returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * 2) The center point lies at the center of a single display.  In this case
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     *    the user most likely wants centered Windows to be constrained to that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     *    single display.  The boundaries of the one display are returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     * It is possible for the center point to be at both the center of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * entire display space AND at the center of a single monitor (a square of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     * 9 monitors, for instance).  In this case, the entire display area is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * Because the center point is arbitrarily settable by the user, it could
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * fit neither of the cases above.  The fallback case is to simply return
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * the combined area for all screens.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    protected Rectangle getXineramaWindowBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        Point center = getCenterPoint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        Rectangle unionRect, tempRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        GraphicsDevice[] gds = getScreenDevices();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        Rectangle centerMonitorRect = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        // if center point is at the center of all monitors
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        // return union of all bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        //  MM*MM     MMM       M
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
        //            M*M       *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        //            MMM       M
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        // if center point is at center of a single monitor (but not of all
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        // monitors)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        // return bounds of single monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        // MMM         MM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        // MM*         *M
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        // else, center is in some strange spot (such as on the border between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        // monitors), and we should just return the union of all monitors
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        // MM          MMM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        // MM          MMM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        unionRect = getUsableBounds(gds[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
        for (i = 0; i < gds.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            tempRect = getUsableBounds(gds[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            if (centerMonitorRect == null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                // add a pixel or two for fudge-factor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                (tempRect.width / 2) + tempRect.x > center.x - 1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                (tempRect.height / 2) + tempRect.y > center.y - 1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                (tempRect.width / 2) + tempRect.x < center.x + 1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                (tempRect.height / 2) + tempRect.y < center.y + 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                centerMonitorRect = tempRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            unionRect = unionRect.union(tempRect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        // first: check for center of all monitors (video wall)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        // add a pixel or two for fudge-factor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        if ((unionRect.width / 2) + unionRect.x > center.x - 1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            (unionRect.height / 2) + unionRect.y > center.y - 1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
            (unionRect.width / 2) + unionRect.x < center.x + 1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
            (unionRect.height / 2) + unionRect.y < center.y + 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            if (screenLog.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                screenLog.log(Level.FINER, "Video Wall: center point is at center of all displays.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            return unionRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        // next, check if at center of one monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        if (centerMonitorRect != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
            if (screenLog.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                screenLog.log(Level.FINER, "Center point at center of a particular " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
                                           "monitor, but not of the entire virtual display.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            return centerMonitorRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        // otherwise, the center is at some weird spot: return unionRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        if (screenLog.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            screenLog.log(Level.FINER, "Center point is somewhere strange - return union of all bounds.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        return unionRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
     * From the DisplayChangedListener interface; devices do not need
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
     * to react to this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    public void paletteChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
}