Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/font/FontManager.java
38829 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package sun.font;2526import java.awt.Font;27import java.awt.FontFormatException;28import java.io.File;29import java.util.Locale;30import java.util.TreeMap;3132import javax.swing.plaf.FontUIResource;333435/**36* Interface between Java Fonts (java.awt.Font) and the underlying37* font files/native font resources and the Java and native font scalers.38*/39public interface FontManager {4041// These constants are used in findFont().42public static final int NO_FALLBACK = 0;43public static final int PHYSICAL_FALLBACK = 1;44public static final int LOGICAL_FALLBACK = 2;4546/**47* Register a new font. Please, note that {@code null} is not a valid48* argument, and it's caller's responsibility to ensure that, but to keep49* compatibility, if {@code null} is passed as an argument, {@code false}50* is returned, and no {@link NullPointerException}51* is thrown.52*53* As additional note, an implementation should ensure that this font54* cannot override existing installed fonts.55*56* @param font57* @return {@code true} is the font is successfully registered,58* {@code false} otherwise.59*/60public boolean registerFont(Font font);6162public void deRegisterBadFont(Font2D font2D);6364/**65* The client supplies a name and a style.66* The name could be a family name, or a full name.67* A font may exist with the specified style, or it may68* exist only in some other style. For non-native fonts the scaler69* may be able to emulate the required style.70*/71public Font2D findFont2D(String name, int style, int fallback);7273/**74* Creates a Font2D for the specified font file, that is expected75* to be in the specified font format (according to the constants76* in java.awt.Font). The parameter {@code isCopy} is set to true77* when the specified font file is actually a copy of the font data78* and needs to be deleted afterwards. This method is called79* for the Font.createFont() methods.80*81* @param fontFile the file holding the font data82* @param fontFormat the expected font format83* @param isCopy {@code true} if the file is a copy and needs to be84* deleted, {@code false} otherwise85*86* @return the created Font2D instance87*/88public Font2D createFont2D(File fontFile, int fontFormat,89boolean isCopy, CreatedFontTracker tracker)90throws FontFormatException;9192/**93* If usingPerAppContextComposites is true, we are in "applet"94* (eg browser) environment and at least one context has selected95* an alternate composite font behaviour.96*/97public boolean usingPerAppContextComposites();9899/**100* Creates a derived composite font from the specified font (handle).101*102* @param family the font family of the derived font103* @param style the font style of the derived font104* @param handle the original font (handle)105*106* @return the handle for the derived font107*/108public Font2DHandle getNewComposite(String family, int style,109Font2DHandle handle);110111/**112* Indicates a preference for locale-specific fonts in the mapping of113* logical fonts to physical fonts. Calling this method indicates that font114* rendering should primarily use fonts specific to the primary writing115* system (the one indicated by the default encoding and the initial116* default locale). For example, if the primary writing system is117* Japanese, then characters should be rendered using a Japanese font118* if possible, and other fonts should only be used for characters for119* which the Japanese font doesn't have glyphs.120* <p>121* The actual change in font rendering behavior resulting from a call122* to this method is implementation dependent; it may have no effect at123* all, or the requested behavior may already match the default behavior.124* The behavior may differ between font rendering in lightweight125* and peered components. Since calling this method requests a126* different font, clients should expect different metrics, and may need127* to recalculate window sizes and layout. Therefore this method should128* be called before user interface initialisation.129*130* @see #preferProportionalFonts()131* @since 1.5132*/133public void preferLocaleFonts();134135/**136* preferLocaleFonts() and preferProportionalFonts() are called to inform137* that the application could be using an alternate set of composite138* fonts, and so the implementation should try to create a CompositeFonts139* with this directive in mind.140*141* @see #preferLocaleFonts()142*/143public void preferProportionalFonts();144145}146147148