Java Code Examples for sun.font.FontManager#createFont2D()

The following examples show how to use sun.font.FontManager#createFont2D() . 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 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 2
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 3
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 4
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 5
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 6
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 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 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 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
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 17
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 18
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 19
Source File: Font.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: Font.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}