< prev index next >

src/java.desktop/share/classes/sun/font/FontManager.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2013, 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 /**
  37  * Interface between Java Fonts (java.awt.Font) and the underlying
  38  * font files/native font resources and the Java and native font scalers.
  39  */
  40 public interface FontManager {
  41 
  42     // These constants are used in findFont().
  43     public static final int NO_FALLBACK = 0;
  44     public static final int PHYSICAL_FALLBACK = 1;
  45     public static final int LOGICAL_FALLBACK = 2;
  46 
  47     /**
  48      * Register a new font. Please, note that {@code null} is not a valid
  49      * argument, and it's caller's responsibility to ensure that, but to keep
  50      * compatibility, if {@code null} is passed as an argument, {@code false}
  51      * is returned, and no {@link NullPointerException}
  52      * is thrown.
  53      *
  54      * As additional note, an implementation should ensure that this font


  76      * to be in the specified font format (according to the constants
  77      * in java.awt.Font). The parameter {@code isCopy} is set to true
  78      * when the specified font file is actually a copy of the font data
  79      * and needs to be deleted afterwards. This method is called
  80      * for the Font.createFont() methods.
  81      *
  82      * @param fontFile the file holding the font data
  83      * @param fontFormat the expected font format
  84      * @param all whether to retrieve all fonts in the resource or
  85      *        just the first one.
  86      * @param isCopy {@code true} if the file is a copy and needs to be
  87      *        deleted, {@code false} otherwise
  88      *
  89      * @return the created Font2D instance
  90      */
  91     public Font2D[] createFont2D(File fontFile, int fontFormat, boolean all,
  92                                  boolean isCopy, CreatedFontTracker tracker)
  93         throws FontFormatException;
  94 
  95     /**
  96      * If usingPerAppContextComposites is true, we are in "applet"
  97      * (eg browser) environment and at least one context has selected
  98      * an alternate composite font behaviour.
  99      */
 100     public boolean usingPerAppContextComposites();
 101 
 102     /**
 103      * Creates a derived composite font from the specified font (handle).
 104      *
 105      * @param family the font family of the derived font
 106      * @param style the font style of the derived font
 107      * @param handle the original font (handle)
 108      *
 109      * @return the handle for the derived font
 110      */
 111     public Font2DHandle getNewComposite(String family, int style,
 112                                         Font2DHandle handle);
 113 
 114     /**
 115      * Indicates a preference for locale-specific fonts in the mapping of
 116      * logical fonts to physical fonts. Calling this method indicates that font
 117      * rendering should primarily use fonts specific to the primary writing
 118      * system (the one indicated by the default encoding and the initial
 119      * default locale). For example, if the primary writing system is
 120      * Japanese, then characters should be rendered using a Japanese font
 121      * if possible, and other fonts should only be used for characters for
 122      * which the Japanese font doesn't have glyphs.


   1 /*
   2  * Copyright (c) 2003, 2019, 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 
  26 package sun.font;
  27 
  28 import java.awt.Font;
  29 import java.awt.FontFormatException;
  30 import java.io.File;





  31 
  32 /**
  33  * Interface between Java Fonts (java.awt.Font) and the underlying
  34  * font files/native font resources and the Java and native font scalers.
  35  */
  36 public interface FontManager {
  37 
  38     // These constants are used in findFont().
  39     public static final int NO_FALLBACK = 0;
  40     public static final int PHYSICAL_FALLBACK = 1;
  41     public static final int LOGICAL_FALLBACK = 2;
  42 
  43     /**
  44      * Register a new font. Please, note that {@code null} is not a valid
  45      * argument, and it's caller's responsibility to ensure that, but to keep
  46      * compatibility, if {@code null} is passed as an argument, {@code false}
  47      * is returned, and no {@link NullPointerException}
  48      * is thrown.
  49      *
  50      * As additional note, an implementation should ensure that this font


  72      * to be in the specified font format (according to the constants
  73      * in java.awt.Font). The parameter {@code isCopy} is set to true
  74      * when the specified font file is actually a copy of the font data
  75      * and needs to be deleted afterwards. This method is called
  76      * for the Font.createFont() methods.
  77      *
  78      * @param fontFile the file holding the font data
  79      * @param fontFormat the expected font format
  80      * @param all whether to retrieve all fonts in the resource or
  81      *        just the first one.
  82      * @param isCopy {@code true} if the file is a copy and needs to be
  83      *        deleted, {@code false} otherwise
  84      *
  85      * @return the created Font2D instance
  86      */
  87     public Font2D[] createFont2D(File fontFile, int fontFormat, boolean all,
  88                                  boolean isCopy, CreatedFontTracker tracker)
  89         throws FontFormatException;
  90 
  91     /**







  92      * Creates a derived composite font from the specified font (handle).
  93      *
  94      * @param family the font family of the derived font
  95      * @param style the font style of the derived font
  96      * @param handle the original font (handle)
  97      *
  98      * @return the handle for the derived font
  99      */
 100     public Font2DHandle getNewComposite(String family, int style,
 101                                         Font2DHandle handle);
 102 
 103     /**
 104      * Indicates a preference for locale-specific fonts in the mapping of
 105      * logical fonts to physical fonts. Calling this method indicates that font
 106      * rendering should primarily use fonts specific to the primary writing
 107      * system (the one indicated by the default encoding and the initial
 108      * default locale). For example, if the primary writing system is
 109      * Japanese, then characters should be rendered using a Japanese font
 110      * if possible, and other fonts should only be used for characters for
 111      * which the Japanese font doesn't have glyphs.


< prev index next >