1 /*
   2  * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.font;
  27 
  28 import sun.java2d.SunGraphicsEnvironment;
  29 
  30 public class FontManagerNativeLibrary {
  31     static {
  32         java.security.AccessController.doPrivileged(
  33                                     new java.security.PrivilegedAction<Object>() {
  34             public Object run() {
  35                /* REMIND do we really have to load awt here? */
  36                System.loadLibrary("awt");
  37                if (System.getProperty("os.name").startsWith("Windows")) {
  38                    /* Ideally fontmanager library should not depend on
  39                       particular implementation of the font scaler.
  40                       However, freetype scaler is basically small wrapper on
  41                       top of freetype library (that is used in binary form).
  42 
  43                       This wrapper is compiled into fontmanager and this make
  44                       fontmanger library depending on freetype library.
  45 
  46                       On Windows DLL's in the JRE's BIN directory cannot be
  47                       found by windows DLL loading as that directory is not
  48                       on the Windows PATH.
  49 
  50                       To avoid link error we have to load freetype explicitly
  51                       before we load fontmanager.
  52 
  53                       NB: consider moving freetype wrapper part to separate
  54                           shared library in order to avoid dependency. */
  55                    System.loadLibrary("freetype");
  56                    /* Same for harfbuzz */
  57                    System.loadLibrary("harfbuzz");
  58                }
  59                System.loadLibrary("fontmanager");
  60 
  61                return null;
  62             }
  63         });
  64     }
  65 
  66     /*
  67      * Call this method to ensure libraries are loaded.
  68      *
  69      * Method acts as trigger to ensure this class is loaded
  70      * (and therefore initializer code is executed).
  71      * Actual loading is performed by static initializer.
  72      * (no need to execute doPrivilledged block more than once)
  73      */
  74     public static void load() {}
  75 }