Path: blob/master/src/java.desktop/share/classes/sun/font/FontManager.java
41155 views
/*1* Copyright (c) 2003, 2019, 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*/2425package sun.font;2627import java.awt.Font;28import java.awt.FontFormatException;29import java.io.File;3031/**32* Interface between Java Fonts (java.awt.Font) and the underlying33* font files/native font resources and the Java and native font scalers.34*/35public interface FontManager {3637// These constants are used in findFont().38public static final int NO_FALLBACK = 0;39public static final int PHYSICAL_FALLBACK = 1;40public static final int LOGICAL_FALLBACK = 2;4142/**43* Register a new font. Please, note that {@code null} is not a valid44* argument, and it's caller's responsibility to ensure that, but to keep45* compatibility, if {@code null} is passed as an argument, {@code false}46* is returned, and no {@link NullPointerException}47* is thrown.48*49* As additional note, an implementation should ensure that this font50* cannot override existing installed fonts.51*52* @param font53* @return {@code true} is the font is successfully registered,54* {@code false} otherwise.55*/56public boolean registerFont(Font font);5758public void deRegisterBadFont(Font2D font2D);5960/**61* The client supplies a name and a style.62* The name could be a family name, or a full name.63* A font may exist with the specified style, or it may64* exist only in some other style. For non-native fonts the scaler65* may be able to emulate the required style.66*/67public Font2D findFont2D(String name, int style, int fallback);6869/**70* Creates a Font2D for the specified font file, that is expected71* to be in the specified font format (according to the constants72* in java.awt.Font). The parameter {@code isCopy} is set to true73* when the specified font file is actually a copy of the font data74* and needs to be deleted afterwards. This method is called75* for the Font.createFont() methods.76*77* @param fontFile the file holding the font data78* @param fontFormat the expected font format79* @param all whether to retrieve all fonts in the resource or80* just the first one.81* @param isCopy {@code true} if the file is a copy and needs to be82* deleted, {@code false} otherwise83*84* @return the created Font2D instance85*/86public Font2D[] createFont2D(File fontFile, int fontFormat, boolean all,87boolean isCopy, CreatedFontTracker tracker)88throws FontFormatException;8990/**91* Creates a derived composite font from the specified font (handle).92*93* @param family the font family of the derived font94* @param style the font style of the derived font95* @param handle the original font (handle)96*97* @return the handle for the derived font98*/99public Font2DHandle getNewComposite(String family, int style,100Font2DHandle handle);101102/**103* Indicates a preference for locale-specific fonts in the mapping of104* logical fonts to physical fonts. Calling this method indicates that font105* rendering should primarily use fonts specific to the primary writing106* system (the one indicated by the default encoding and the initial107* default locale). For example, if the primary writing system is108* Japanese, then characters should be rendered using a Japanese font109* if possible, and other fonts should only be used for characters for110* which the Japanese font doesn't have glyphs.111* <p>112* The actual change in font rendering behavior resulting from a call113* to this method is implementation dependent; it may have no effect at114* all, or the requested behavior may already match the default behavior.115* The behavior may differ between font rendering in lightweight116* and peered components. Since calling this method requests a117* different font, clients should expect different metrics, and may need118* to recalculate window sizes and layout. Therefore this method should119* be called before user interface initialisation.120*121* @see #preferProportionalFonts()122* @since 1.5123*/124public void preferLocaleFonts();125126/**127* preferLocaleFonts() and preferProportionalFonts() are called to inform128* that the application could be using an alternate set of composite129* fonts, and so the implementation should try to create a CompositeFonts130* with this directive in mind.131*132* @see #preferLocaleFonts()133*/134public void preferProportionalFonts();135136}137138139