当前位置: 首页>>代码示例>>Java>>正文


Java FontManagerFactory.getInstance方法代码示例

本文整理汇总了Java中sun.font.FontManagerFactory.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FontManagerFactory.getInstance方法的具体用法?Java FontManagerFactory.getInstance怎么用?Java FontManagerFactory.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.font.FontManagerFactory的用法示例。


在下文中一共展示了FontManagerFactory.getInstance方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFont2D

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Font.java

示例2: Font

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:Font.java

示例3: Font

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
private Font(AttributeValues values, String oldName, int oldStyle,
             boolean created, Font2DHandle handle) {

    this.createdFont = created;
    if (created) {
        this.font2DHandle = handle;

        String newName = null;
        if (oldName != null) {
            newName = values.getFamily();
            if (oldName.equals(newName)) newName = null;
        }
        int newStyle = 0;
        if (oldStyle == -1) {
            newStyle = -1;
        } else {
            if (values.getWeight() >= 2f)   newStyle  = BOLD;
            if (values.getPosture() >= .2f) newStyle |= ITALIC;
            if (oldStyle == newStyle)       newStyle  = -1;
        }
        if (handle.font2D instanceof CompositeFont) {
            if (newStyle != -1 || newName != null) {
                FontManager fm = FontManagerFactory.getInstance();
                this.font2DHandle =
                    fm.getNewComposite(newName, newStyle, handle);
            }
        } else if (newName != null) {
            this.createdFont = false;
            this.font2DHandle = null;
        }
    }
    initFromValues(values);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:Font.java

示例4: getFontMetrics

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
@Override
public FontMetrics getFontMetrics(Font font) {
    // This is an unsupported hack, but left in for a customer.
    // Do not remove.
    FontManager fm = FontManagerFactory.getInstance();
    if (fm instanceof SunFontManager
        && ((SunFontManager) fm).usePlatformFontMetrics()) {
        return WFontMetrics.getFontMetrics(font);
    }
    return super.getFontMetrics(font);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:WToolkit.java

示例5: Font

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
private Font(File fontFile, int fontFormat,
             boolean isCopy, CreatedFontTracker tracker)
    throws FontFormatException {
    this.createdFont = true;
    /* Font2D instances created by this method track their font file
     * so that when the Font2D is GC'd it can also remove the file.
     */
    FontManager fm = FontManagerFactory.getInstance();
    this.font2DHandle = fm.createFont2D(fontFile, fontFormat, isCopy,
                                        tracker).handle;
    this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
    this.style = Font.PLAIN;
    this.size = 1;
    this.pointSize = 1f;
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:16,代码来源:Font.java

示例6: getFontMetrics

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
public FontMetrics getFontMetrics(Font font) {
    // This is an unsupported hack, but left in for a customer.
    // Do not remove.
    FontManager fm = FontManagerFactory.getInstance();
    if (fm instanceof SunFontManager
        && ((SunFontManager) fm).usePlatformFontMetrics()) {
        return WFontMetrics.getFontMetrics(font);
    }
    return super.getFontMetrics(font);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:11,代码来源:WToolkit.java

示例7: createFonts

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
/**
 * Returns a new array of {@code Font} decoded from the specified file.
 * The returned {@code Font[]} will have at least one element.
 * <p>
 * The explicit purpose of this variation on the
 * {@code createFont(int, File)} method is to support font
 * sources which represent a TrueType/OpenType font collection and
 * be able to return all individual fonts in that collection.
 * Consequently this method will throw {@code FontFormatException}
 * if the data source does not contain at least one TrueType/OpenType
 * font. The same exception will also be thrown if any of the fonts in
 * the collection does not contain the required font tables.
 * <p>
 * The condition "at least one", allows for the stream to represent
 * a single OpenType/TrueType font. That is, it does not have to be
 * a collection.
 * Each {@code Font} element of the returned array is
 * created with a point size of 1 and style {@link #PLAIN PLAIN}.
 * This base font can then be used with the {@code deriveFont}
 * methods in this class to derive new {@code Font} objects with
 * varying sizes, styles, transforms and font features.
 * <p>
 * To make each {@code Font} available to Font constructors it
 * must be registered in the {@code GraphicsEnvironment} by calling
 * {@link GraphicsEnvironment#registerFont(Font) registerFont(Font)}.
 * @param fontFile a {@code File} object containing the
 * input data for the font or font collection.
 * @return a new {@code Font[]}.
 * @throws FontFormatException if the {@code File} does
 *     not contain the required font tables for any of the elements of
 *     the collection, or if it contains no fonts at all.
 * @throws IOException if the {@code fontFile} cannot be read.
 * @see GraphicsEnvironment#registerFont(Font)
 * @since 9
 */
public static Font[] createFonts(File fontFile)
        throws FontFormatException, IOException
{
    int fontFormat = Font.TRUETYPE_FONT;
    fontFile = checkFontFile(fontFormat, fontFile);
    FontManager fm = FontManagerFactory.getInstance();
    Font2D[] font2DArr =
        fm.createFont2D(fontFile, fontFormat, true, false, null);
    int num = font2DArr.length;
    Font[] fonts = new Font[num];
    for (int i = 0; i < num; i++) {
       fonts[i] = new Font(font2DArr[i]);
    }
    return fonts;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:Font.java

示例8: getFontManagerForSGE

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
public static FontManagerForSGE getFontManagerForSGE() {
    FontManager fm = FontManagerFactory.getInstance();
    return (FontManagerForSGE) fm;
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:5,代码来源:SunGraphicsEnvironment.java

示例9: getFontMetrics

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
/**
 * Gets the font metrics for the specified font.
 * Warning: Since Font metrics are affected by the
 * {@link java.awt.font.FontRenderContext FontRenderContext} and
 * this method does not provide one, it can return only metrics for
 * the default render context which may not match that used when
 * rendering on the Component if {@link Graphics2D} functionality is being
 * used. Instead metrics can be obtained at rendering time by calling
 * {@link Graphics#getFontMetrics()} or text measurement APIs on the
 * {@link Font Font} class.
 * @param font the font for which font metrics is to be
 *          obtained
 * @return the font metrics for <code>font</code>
 * @see       #getFont
 * @see       #getPeer
 * @see       java.awt.peer.ComponentPeer#getFontMetrics(Font)
 * @see       Toolkit#getFontMetrics(Font)
 * @since     JDK1.0
 */
public FontMetrics getFontMetrics(Font font) {
    // This is an unsupported hack, but left in for a customer.
    // Do not remove.
    FontManager fm = FontManagerFactory.getInstance();
    if (fm instanceof SunFontManager
        && ((SunFontManager) fm).usePlatformFontMetrics()) {

        if (peer != null &&
            !(peer instanceof LightweightPeer)) {
            return peer.getFontMetrics(font);
        }
    }
    return sun.font.FontDesignMetrics.getMetrics(font);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:Component.java

示例10: registerFont

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
/**
 * Registers a <i>created</i> {@code Font} in this
 * {@code GraphicsEnvironment}.
 * A created font is one that was returned from calling
 * {@link Font#createFont}, or derived from a created font by
 * calling {@link Font#deriveFont}.
 * After calling this method for such a font, it is available to
 * be used in constructing new {@code Font}s by name or family name,
 * and is enumerated by {@link #getAvailableFontFamilyNames} and
 * {@link #getAllFonts} within the execution context of this
 * application or applet. This means applets cannot register fonts in
 * a way that they are visible to other applets.
 * <p>
 * Reasons that this method might not register the font and therefore
 * return {@code false} are:
 * <ul>
 * <li>The font is not a <i>created</i> {@code Font}.
 * <li>The font conflicts with a non-created {@code Font} already
 * in this {@code GraphicsEnvironment}. For example if the name
 * is that of a system font, or a logical font as described in the
 * documentation of the {@link Font} class. It is implementation dependent
 * whether a font may also conflict if it has the same family name
 * as a system font.
 * <p>Notice that an application can supersede the registration
 * of an earlier created font with a new one.
 * </ul>
 *
 * @param  font the font to be registered
 * @return true if the {@code font} is successfully
 * registered in this {@code GraphicsEnvironment}.
 * @throws NullPointerException if {@code font} is null
 * @since 1.6
 */
public boolean registerFont(Font font) {
    if (font == null) {
        throw new NullPointerException("font cannot be null.");
    }
    FontManager fm = FontManagerFactory.getInstance();
    return fm.registerFont(font);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:GraphicsEnvironment.java

示例11: getFontMetrics

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
/**
 * Gets the font metrics for the specified font.
 * Warning: Since Font metrics are affected by the
 * {@link java.awt.font.FontRenderContext FontRenderContext} and
 * this method does not provide one, it can return only metrics for
 * the default render context which may not match that used when
 * rendering on the Component if {@link Graphics2D} functionality is being
 * used. Instead metrics can be obtained at rendering time by calling
 * {@link Graphics#getFontMetrics()} or text measurement APIs on the
 * {@link Font Font} class.
 * @param font the font for which font metrics is to be
 *          obtained
 * @return the font metrics for {@code font}
 * @see       #getFont
 * @see       java.awt.peer.ComponentPeer#getFontMetrics(Font)
 * @see       Toolkit#getFontMetrics(Font)
 * @since     1.0
 */
public FontMetrics getFontMetrics(Font font) {
    // This is an unsupported hack, but left in for a customer.
    // Do not remove.
    FontManager fm = FontManagerFactory.getInstance();
    if (fm instanceof SunFontManager
        && ((SunFontManager) fm).usePlatformFontMetrics()) {

        if (peer != null &&
            !(peer instanceof LightweightPeer)) {
            return peer.getFontMetrics(font);
        }
    }
    return sun.font.FontDesignMetrics.getMetrics(font);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:Component.java

示例12: registerFont

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
/**
 * Registers a <i>created</i> <code>Font</code>in this
 * <code>GraphicsEnvironment</code>.
 * A created font is one that was returned from calling
 * {@link Font#createFont}, or derived from a created font by
 * calling {@link Font#deriveFont}.
 * After calling this method for such a font, it is available to
 * be used in constructing new <code>Font</code>s by name or family name,
 * and is enumerated by {@link #getAvailableFontFamilyNames} and
 * {@link #getAllFonts} within the execution context of this
 * application or applet. This means applets cannot register fonts in
 * a way that they are visible to other applets.
 * <p>
 * Reasons that this method might not register the font and therefore
 * return <code>false</code> are:
 * <ul>
 * <li>The font is not a <i>created</i> <code>Font</code>.
 * <li>The font conflicts with a non-created <code>Font</code> already
 * in this <code>GraphicsEnvironment</code>. For example if the name
 * is that of a system font, or a logical font as described in the
 * documentation of the {@link Font} class. It is implementation dependent
 * whether a font may also conflict if it has the same family name
 * as a system font.
 * <p>Notice that an application can supersede the registration
 * of an earlier created font with a new one.
 * </ul>
 * @return true if the <code>font</code> is successfully
 * registered in this <code>GraphicsEnvironment</code>.
 * @throws NullPointerException if <code>font</code> is null
 * @since 1.6
 */
public boolean registerFont(Font font) {
    if (font == null) {
        throw new NullPointerException("font cannot be null.");
    }
    FontManager fm = FontManagerFactory.getInstance();
    return fm.registerFont(font);
}
 
开发者ID:Java8-CNAPI-Team,项目名称:Java8CN,代码行数:39,代码来源:GraphicsEnvironment.java

示例13: preferProportionalFonts

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
/**
 * Indicates a preference for proportional over non-proportional (e.g.
 * dual-spaced CJK fonts) fonts in the mapping of logical fonts to
 * physical fonts. If the default mapping contains fonts for which
 * proportional and non-proportional variants exist, then calling
 * this method indicates the mapping should use a proportional variant.
 * <p>
 * The actual change in font rendering behavior resulting from a call to
 * this method is implementation dependent; it may have no effect at all.
 * The behavior may differ between font rendering in lightweight and
 * peered components. Since calling this method requests a
 * different font, clients should expect different metrics, and may need
 * to recalculate window sizes and layout. Therefore this method should
 * be called before user interface initialisation.
 * @since 1.5
 */
public void preferProportionalFonts() {
    FontManager fm = FontManagerFactory.getInstance();
    fm.preferProportionalFonts();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:GraphicsEnvironment.java

示例14: preferLocaleFonts

import sun.font.FontManagerFactory; //导入方法依赖的package包/类
/**
 * Indicates a preference for locale-specific fonts in the mapping of
 * logical fonts to physical fonts. Calling this method indicates that font
 * rendering should primarily use fonts specific to the primary writing
 * system (the one indicated by the default encoding and the initial
 * default locale). For example, if the primary writing system is
 * Japanese, then characters should be rendered using a Japanese font
 * if possible, and other fonts should only be used for characters for
 * which the Japanese font doesn't have glyphs.
 * <p>
 * The actual change in font rendering behavior resulting from a call
 * to this method is implementation dependent; it may have no effect at
 * all, or the requested behavior may already match the default behavior.
 * The behavior may differ between font rendering in lightweight
 * and peered components.  Since calling this method requests a
 * different font, clients should expect different metrics, and may need
 * to recalculate window sizes and layout. Therefore this method should
 * be called before user interface initialisation.
 * @since 1.5
 */
public void preferLocaleFonts() {
    FontManager fm = FontManagerFactory.getInstance();
    fm.preferLocaleFonts();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:GraphicsEnvironment.java


注:本文中的sun.font.FontManagerFactory.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。