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


Java CreatedFontTracker类代码示例

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


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

示例1: Font

import sun.font.CreatedFontTracker; //导入依赖的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();
    Font2D[] fonts =
        fm.createFont2D(fontFile, fontFormat, false, isCopy, tracker);
    this.font2DHandle = fonts[0].handle;
    this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
    this.style = Font.PLAIN;
    this.size = 1;
    this.pointSize = 1f;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Font.java

示例2: Font

import sun.font.CreatedFontTracker; //导入依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:Font.java

示例3: createFont

import sun.font.CreatedFontTracker; //导入依赖的package包/类
/**
 * Returns a new <code>Font</code> using the specified font type
 * and input data.  The new <code>Font</code> is
 * created with a point size of 1 and style {@link #PLAIN PLAIN}.
 * This base font can then be used with the <code>deriveFont</code>
 * methods in this class to derive new <code>Font</code> objects with
 * varying sizes, styles, transforms and font features.  This
 * method does not close the {@link InputStream}.
 * <p>
 * To make the <code>Font</code> available to Font constructors the
 * returned <code>Font</code> must be registered in the
 * <code>GraphicsEnviroment</code> by calling
 * {@link GraphicsEnvironment#registerFont(Font) registerFont(Font)}.
 * @param fontFormat the type of the <code>Font</code>, which is
 * {@link #TRUETYPE_FONT TRUETYPE_FONT} if a TrueType resource is specified.
 * or {@link #TYPE1_FONT TYPE1_FONT} if a Type 1 resource is specified.
 * @param fontStream an <code>InputStream</code> object representing the
 * input data for the font.
 * @return a new <code>Font</code> created with the specified font type.
 * @throws IllegalArgumentException if <code>fontFormat</code> is not
 *     <code>TRUETYPE_FONT</code>or<code>TYPE1_FONT</code>.
 * @throws FontFormatException if the <code>fontStream</code> data does
 *     not contain the required font tables for the specified format.
 * @throws IOException if the <code>fontStream</code>
 *     cannot be completely read.
 * @see GraphicsEnvironment#registerFont(Font)
 * @since 1.3
 */
public static Font createFont(int fontFormat, InputStream fontStream)
    throws java.awt.FontFormatException, java.io.IOException {

    if (hasTempPermission()) {
        return createFont0(fontFormat, fontStream, null);
    }

    // Otherwise, be extra conscious of pending temp file creation and
    // resourcefully handle the temp file resources, among other things.
    CreatedFontTracker tracker = CreatedFontTracker.getTracker();
    boolean acquired = false;
    try {
        acquired = tracker.acquirePermit();
        if (!acquired) {
            throw new IOException("Timed out waiting for resources.");
        }
        return createFont0(fontFormat, fontStream, tracker);
    } catch (InterruptedException e) {
        throw new IOException("Problem reading font data.");
    } finally {
        if (acquired) {
            tracker.releasePermit();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:54,代码来源:Font.java

示例4: createFont

import sun.font.CreatedFontTracker; //导入依赖的package包/类
/**
 * Returns a new {@code Font} using the specified font type
 * and input data.  The new {@code Font} 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.  This
 * method does not close the {@link InputStream}.
 * <p>
 * To make the {@code Font} available to Font constructors the
 * returned {@code Font} must be registered in the
 * {@code GraphicsEnvironment} by calling
 * {@link GraphicsEnvironment#registerFont(Font) registerFont(Font)}.
 * @param fontFormat the type of the {@code Font}, which is
 * {@link #TRUETYPE_FONT TRUETYPE_FONT} if a TrueType resource is specified.
 * or {@link #TYPE1_FONT TYPE1_FONT} if a Type 1 resource is specified.
 * @param fontStream an {@code InputStream} object representing the
 * input data for the font.
 * @return a new {@code Font} created with the specified font type.
 * @throws IllegalArgumentException if {@code fontFormat} is not
 *     {@code TRUETYPE_FONT} or {@code TYPE1_FONT}.
 * @throws FontFormatException if the {@code fontStream} data does
 *     not contain the required font tables for the specified format.
 * @throws IOException if the {@code fontStream}
 *     cannot be completely read.
 * @see GraphicsEnvironment#registerFont(Font)
 * @since 1.3
 */
public static Font createFont(int fontFormat, InputStream fontStream)
    throws java.awt.FontFormatException, java.io.IOException {

    if (hasTempPermission()) {
        return createFont0(fontFormat, fontStream, false, null)[0];
    }

    // Otherwise, be extra conscious of pending temp file creation and
    // resourcefully handle the temp file resources, among other things.
    CreatedFontTracker tracker = CreatedFontTracker.getTracker();
    boolean acquired = false;
    try {
        acquired = tracker.acquirePermit();
        if (!acquired) {
            throw new IOException("Timed out waiting for resources.");
        }
        return createFont0(fontFormat, fontStream, false, tracker)[0];
    } catch (InterruptedException e) {
        throw new IOException("Problem reading font data.");
    } finally {
        if (acquired) {
            tracker.releasePermit();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:Font.java

示例5: createFonts

import sun.font.CreatedFontTracker; //导入依赖的package包/类
/**
 * Returns a new array of {@code Font} decoded from the specified stream.
 * The returned {@code Font[]} will have at least one element.
 * <p>
 * The explicit purpose of this variation on the
 * {@code createFont(int, InputStream)} 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>This method does not close the {@link InputStream}.
 * <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 fontStream an {@code InputStream} object representing the
 * input data for the font or font collection.
 * @return a new {@code Font[]}.
 * @throws FontFormatException if the {@code fontStream} data 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 fontStream} cannot be completely read.
 * @see GraphicsEnvironment#registerFont(Font)
 * @since 9
 */
public static Font[] createFonts(InputStream fontStream)
    throws FontFormatException, IOException {

    final int fontFormat = Font.TRUETYPE_FONT;
    if (hasTempPermission()) {
        return createFont0(fontFormat, fontStream, true, null);
    }

    // Otherwise, be extra conscious of pending temp file creation and
    // resourcefully handle the temp file resources, among other things.
    CreatedFontTracker tracker = CreatedFontTracker.getTracker();
    boolean acquired = false;
    try {
        acquired = tracker.acquirePermit();
        if (!acquired) {
            throw new IOException("Timed out waiting for resources.");
        }
        return createFont0(fontFormat, fontStream, true, tracker);
    } catch (InterruptedException e) {
        throw new IOException("Problem reading font data.");
    } finally {
        if (acquired) {
            tracker.releasePermit();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:Font.java


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