src/solaris/native/sun/awt/fontpath.c

Print this page
rev 8725 : 8024854: Basic changes and files to build the class library on AIX
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -62,11 +62,11 @@
 #define FONTCONFIG_DLL_VERSIONED VERSIONED_JNI_LIB_NAME("fontconfig", "1")
 #define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
 
 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
 
-#if !defined(__linux__)
+#if defined(__solaris__)
 /*
  * This can be set in the makefile to "/usr/X11" if so desired.
  */
 #ifndef OPENWINHOMELIB
 #define OPENWINHOMELIB "/usr/openwin/lib/"

@@ -112,11 +112,11 @@
     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
     OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
     NULL, /* terminates the list */
 };
 
-#else /* __linux */
+#elif defined( __linux__)
 /* All the known interesting locations we have discovered on
  * various flavors of Linux
  */
 static char *fullLinuxFontPath[] = {
     "/usr/X11R6/lib/X11/fonts/TrueType",  /* RH 7.1+ */

@@ -132,10 +132,16 @@
     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType", /* Debian */
     "/usr/X11R6/lib/X11/fonts/Type1",
     "/usr/share/fonts/default/Type1",     /* RH 9.0 */
     NULL, /* terminates the list */
 };
+#elif defined(_AIX)
+static char *fullAixFontPath[] = {
+    "/usr/lpp/X11/lib/X11/fonts/Type1",    /* from X11.fnt.iso_T1  */
+    "/usr/lpp/X11/lib/X11/fonts/TrueType", /* from X11.fnt.ucs.ttf */
+    NULL, /* terminates the list */
+};
 #endif
 
 static char **getFontConfigLocations();
 
 typedef struct {

@@ -495,14 +501,15 @@
      */
     fcdirs = getFontConfigLocations();
 
 #if defined(__linux__)
     knowndirs = fullLinuxFontPath;
-#else /* IF SOLARIS */
+#elif defined(__solaris__)
     knowndirs = fullSolarisFontPath;
+#elif defined(_AIX)
+    knowndirs = fullAixFontPath;
 #endif
-
     /* REMIND: this code requires to be executed when the GraphicsEnvironment
      * is already initialised. That is always true, but if it were not so,
      * this code could throw an exception and the fontpath would fail to
      * be initialised.
      */

@@ -590,10 +597,29 @@
                 return NULL;
             }
         }
     }
 #endif
+
+#if defined(_AIX)
+    /* On AIX, fontconfig is not a standard package supported by IBM.
+     * instead it has to be installed from the "AIX Toolbox for Linux Applications"
+     * site http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html
+     * and will be installed under /opt/freeware/lib/libfontconfig.a.
+     * Notice that the archive contains the real 32- and 64-bit shared libraries.
+     * We first try to load 'libfontconfig.so' from the default library path in the
+     * case the user has installed a private version of the library and if that
+     * doesn't succeed, we try the version from /opt/freeware/lib/libfontconfig.a
+     */
+    libfontconfig = dlopen("libfontconfig.so", RTLD_LOCAL|RTLD_LAZY);
+    if (libfontconfig == NULL) {
+        libfontconfig = dlopen("/opt/freeware/lib/libfontconfig.a(libfontconfig.so.1)", RTLD_MEMBER|RTLD_LOCAL|RTLD_LAZY);
+        if (libfontconfig == NULL) {
+            return NULL;
+        }
+    }
+#else
     /* 64 bit sparc should pick up the right version from the lib path.
      * New features may be added to libfontconfig, this is expected to
      * be compatible with old features, but we may need to start
      * distinguishing the library version, to know whether to expect
      * certain symbols - and functionality - to be available.

@@ -604,10 +630,11 @@
         libfontconfig = dlopen(FONTCONFIG_DLL, RTLD_LOCAL|RTLD_LAZY);
         if (libfontconfig == NULL) {
             return NULL;
         }
     }
+#endif
 
     /* Version 1.0 of libfontconfig crashes if HOME isn't defined in
      * the environment. This should generally never happen, but we can't
      * control it, and can't control the version of fontconfig, so iff
      * its not defined we set it to an empty value which is sufficient

@@ -1201,11 +1228,11 @@
              * on Type 1 fonts for some Locale support, so we'll allow
              * them there.
              */
             if (fontformat != NULL
                 && (strcmp((char*)fontformat, "TrueType") != 0)
-#ifdef __linux__
+#if defined(__linux__) || defined(_AIX)
                 && (strcmp((char*)fontformat, "Type 1") != 0)
 #endif
              ) {
                 continue;
             }