Showing the changes to java/pkg/sun/font/FontManager.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,145 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 2008, 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 | +package sun.font; | |
| 26 | + | |
| 27 | +import java.awt.Font; | |
| 28 | +import java.awt.FontFormatException; | |
| 29 | +import java.io.File; | |
| 30 | +import java.util.Locale; | |
| 31 | +import java.util.TreeMap; | |
| 32 | + | |
| 33 | +import javax.swing.plaf.FontUIResource; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * Interface between Java Fonts (java.awt.Font) and the underlying | |
| 37 | + * font files/native font resources and the Java and native font scalers. | |
| 38 | + */ | |
| 39 | +public interface FontManager { | |
| 40 | + | |
| 41 | + // These constants are used in findFont(). | |
| 42 | + public static final int NO_FALLBACK = 0; | |
| 43 | + public static final int PHYSICAL_FALLBACK = 1; | |
| 44 | + public static final int LOGICAL_FALLBACK = 2; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Register a new font. Please, note that {@code null} is not a valid | |
| 48 | + * argument, and it's caller's responsibility to ensure that, but to keep | |
| 49 | + * 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 font | |
| 54 | + * cannot override existing installed fonts. | |
| 55 | + * | |
| 56 | + * @param font | |
| 57 | + * @return {@code true} is the font is successfully registered, | |
| 58 | + * {@code false} otherwise. | |
| 59 | + */ | |
| 60 | + public boolean registerFont(Font font); | |
| 61 | + | |
| 62 | + public void deRegisterBadFont(Font2D font2D); | |
| 63 | + | |
| 64 | + /** | |
| 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 may | |
| 68 | + * exist only in some other style. For non-native fonts the scaler | |
| 69 | + * may be able to emulate the required style. | |
| 70 | + */ | |
| 71 | + public Font2D findFont2D(String name, int style, int fallback); | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * Creates a Font2D for the specified font file, that is expected | |
| 75 | + * to be in the specified font format (according to the constants | |
| 76 | + * in java.awt.Font). The parameter {@code isCopy} is set to true | |
| 77 | + * when the specified font file is actually a copy of the font data | |
| 78 | + * and needs to be deleted afterwards. This method is called | |
| 79 | + * for the Font.createFont() methods. | |
| 80 | + * | |
| 81 | + * @param fontFile the file holding the font data | |
| 82 | + * @param fontFormat the expected font format | |
| 83 | + * @param isCopy {@code true} if the file is a copy and needs to be | |
| 84 | + * deleted, {@code false} otherwise | |
| 85 | + * | |
| 86 | + * @return the created Font2D instance | |
| 87 | + */ | |
| 88 | + public Font2D createFont2D(File fontFile, int fontFormat, | |
| 89 | + boolean isCopy, CreatedFontTracker tracker) | |
| 90 | + throws FontFormatException; | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * If usingPerAppContextComposites is true, we are in "applet" | |
| 94 | + * (eg browser) enviroment and at least one context has selected | |
| 95 | + * an alternate composite font behaviour. | |
| 96 | + */ | |
| 97 | + public boolean usingPerAppContextComposites(); | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * Creates a derived composite font from the specified font (handle). | |
| 101 | + * | |
| 102 | + * @param family the font family of the derived font | |
| 103 | + * @param style the font style of the derived font | |
| 104 | + * @param handle the original font (handle) | |
| 105 | + * | |
| 106 | + * @return the handle for the derived font | |
| 107 | + */ | |
| 108 | + public Font2DHandle getNewComposite(String family, int style, | |
| 109 | + Font2DHandle handle); | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * Indicates a preference for locale-specific fonts in the mapping of | |
| 113 | + * logical fonts to physical fonts. Calling this method indicates that font | |
| 114 | + * rendering should primarily use fonts specific to the primary writing | |
| 115 | + * system (the one indicated by the default encoding and the initial | |
| 116 | + * default locale). For example, if the primary writing system is | |
| 117 | + * Japanese, then characters should be rendered using a Japanese font | |
| 118 | + * if possible, and other fonts should only be used for characters for | |
| 119 | + * which the Japanese font doesn't have glyphs. | |
| 120 | + * <p> | |
| 121 | + * The actual change in font rendering behavior resulting from a call | |
| 122 | + * to this method is implementation dependent; it may have no effect at | |
| 123 | + * all, or the requested behavior may already match the default behavior. | |
| 124 | + * The behavior may differ between font rendering in lightweight | |
| 125 | + * and peered components. Since calling this method requests a | |
| 126 | + * different font, clients should expect different metrics, and may need | |
| 127 | + * to recalculate window sizes and layout. Therefore this method should | |
| 128 | + * be called before user interface initialisation. | |
| 129 | + * | |
| 130 | + * @see #preferProportionalFonts() | |
| 131 | + * @since 1.5 | |
| 132 | + */ | |
| 133 | + public void preferLocaleFonts(); | |
| 134 | + | |
| 135 | + /** | |
| 136 | + * preferLocaleFonts() and preferProportionalFonts() are called to inform | |
| 137 | + * that the application could be using an alternate set of composite | |
| 138 | + * fonts, and so the implementation should try to create a CompositeFonts | |
| 139 | + * with this directive in mind. | |
| 140 | + * | |
| 141 | + * @see #preferLocaleFonts() | |
| 142 | + */ | |
| 143 | + public void preferProportionalFonts(); | |
| 144 | + | |
| 145 | +} | |