sun.font.CreatedFontTracker Java Examples

The following examples show how to use sun.font.CreatedFontTracker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Font.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: Font.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: Font.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: Font.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: Font.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: Font.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: Font.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: Font.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: Font.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: Font.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #11
Source File: Font.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: Font.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #13
Source File: Font.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
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;
}
 
Example #14
Source File: Font.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #15
Source File: Font.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #16
Source File: Font.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #17
Source File: Font.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #18
Source File: Font.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #19
Source File: Font.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #20
Source File: Font.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #21
Source File: Font.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #22
Source File: Font.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #23
Source File: Font.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #24
Source File: Font.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #25
Source File: Font.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #26
Source File: Font.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #27
Source File: Font.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #28
Source File: Font.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #29
Source File: Font.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example #30
Source File: Font.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
        }
    }
}