3909N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 1687N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1687N/A * This code is free software; you can redistribute it and/or modify it 1687N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 1687N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 1687N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1687N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1687N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1687N/A * version 2 for more details (a copy is included in the LICENSE file that 1687N/A * You should have received a copy of the GNU General Public License version 1687N/A * 2 along with this work; if not, write to the Free Software Foundation, 1687N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 1687N/A * Small utility class to manage FontConfig. 1687N/A /* This is populated by native */ 1687N/A /* Begin support for GTK Look and Feel - query libfontconfig and 1687N/A * return a composite Font to Swing that uses the desktop font(s). 1687N/A /* These next three classes are just data structures. 1687N/A //boolean preferBitmaps; // if embedded bitmaps preferred over AA 1687N/A /* fontconfig recognises slants roman, italic, as well as oblique, 1687N/A * and a slew of weights, where the ones that matter here are 1687N/A * To fully qualify what we want, we can for example ask for (eg) 1687N/A * Font.PLAIN : "serif:regular:roman" 1687N/A * Font.BOLD : "serif:bold:roman" 1687N/A * Font.ITALIC : "serif:regular:italic" 1687N/A * Font.BOLD|Font.ITALIC : "serif:bold:italic" 1687N/A "monospace:regular:italic",
1687N/A /* This array has the array elements created in Java code and is 1687N/A * passed down to native to be filled in. 1687N/A * Instantiates a new FontConfigManager getting the default instance 1687N/A * of FontManager from the FontManagerFactory. 1687N/A /* Called from code that needs to know what are the AA settings 1687N/A * that apps using FC would pick up for the default desktop font. 1687N/A * Note apps can change the default desktop font. etc, so this 1687N/A * isn't certain to be right but its going to correct for most cases. 1687N/A * Native return values map to the text aa values in sun.awt.SunHints. 1687N/A * which is used to look up the renderinghint value object. 1687N/A /* This is public solely so that for debugging purposes it can be called 1687N/A * with other names, which might (eg) include a size, eg "sans-24" 1687N/A * The return value is a text aa rendering hint value. 1687N/A * Normally we should call the no-args version. 1687N/A /* This does cause the native libfontconfig to be loaded and unloaded, 1687N/A * but it does not incur the overhead of initialisation of its 1687N/A * data structures, so shouldn't have a measurable impact. 1687N/A /* This can be made public if it's needed to force a re-read 1687N/A * rather than using the cached values. The re-read would be needed 1687N/A * only if some event signalled that the fontconfig has changed. 1687N/A * In that event this method would need to return directly the array 1687N/A * to be used by the caller in case it subsequently changed. 1687N/A /* If don't find anything (eg no libfontconfig), then just return */ 1687N/A /* If it's a TTC file we need to know that as we will need to 1687N/A * make sure we return the right font */ 1687N/A /* If this file is already registered, can just return its font. 1687N/A * However we do need to check in case it's a TTC as we need 1687N/A * a specific font, so rather than directly returning it, let 1687N/A /* If the font may hide a JRE font (eg fontconfig says it is 1687N/A * Lucida Sans), we want to use the JRE version, so make it 1687N/A /* It is also possible the font file is on the "deferred" list, 1687N/A * in which case we can just initialise it now. 1687N/A /* use findFont2D to get the right font from TTC's */ 1687N/A /* In the majority of cases we reach here, and need to determine 1687N/A * the type and rank to register the font. 1687N/A * We need to return a Composite font which has as the font in 1687N/A * its first slot one obtained from fontconfig. 5477N/A // This avoids an immediate NPE if fontconfig look up failed 5477N/A // but doesn't guarantee this is a recoverable situation. 1687N/A /* jdkFont is going to be used for slots 1..N and as a fallback. 1687N/A * Slot 0 will be the physical font from fontconfig. 1687N/A /* First, see if the family and exact style is already registered. 1687N/A * If it is, use it. If it's not, then try to register it. 1687N/A * If that registration fails (signalled by null) just return the 1687N/A * Algorithmically styled fonts won't match on exact style, so 1687N/A * will fall through this code, but the regisration code will 1687N/A * find that file already registered and return its font. 1687N/A /* Now register the fonts in the family (the other styles) after 1687N/A * checking that they aren't already registered and are actually in 1687N/A * a different file. They may be the same file in CJK cases. 1687N/A * For cases where they are different font files - eg as is common for 1687N/A * Latin fonts, then we rely on fontconfig to report these correctly. 1687N/A * Assume that all styles of this font are found by fontconfig, 1687N/A * so we can find all the family members which must be registered 1687N/A * together to prevent synthetic styling. 1687N/A /* Now we have a physical font. We will back this up with the JDK 1687N/A * logical font (sansserif, serif, or monospaced) that corresponds 1687N/A /* Return an array of FcCompFont structs describing the primary