Java Code Examples for sun.java2d.Disposer#addObjectRecord()

The following examples show how to use sun.java2d.Disposer#addObjectRecord() . 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: TrueTypeFont.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * - does basic verification of the file
 * - reads the header table for this font (within a collection)
 * - reads the names (full, family).
 * - determines the style of the font.
 * - initializes the CMAP
 * @throws FontFormatException - if the font can't be opened
 * or fails verification,  or there's no usable cmap
 */
public TrueTypeFont(String platname, Object nativeNames, int fIndex,
             boolean javaRasterizer, boolean useFilePool)
    throws FontFormatException {
    super(platname, nativeNames);
    useJavaRasterizer = javaRasterizer;
    fontRank = Font2D.TTF_RANK;
    try {
        verify(useFilePool);
        init(fIndex);
        if (!useFilePool) {
           close();
        }
    } catch (Throwable t) {
        close();
        if (t instanceof FontFormatException) {
            throw (FontFormatException)t;
        } else {
            throw new FontFormatException("Unexpected runtime exception.");
        }
    }
    Disposer.addObjectRecord(this, disposerRecord);
}
 
Example 2
Source File: Type1Font.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * - does basic verification of the file
 * - reads the names (full, family).
 * - determines the style of the font.
 * @throws FontFormatException - if the font can't be opened
 * or fails verification,  or there's no usable cmap
 */
public Type1Font(String platname, Object nativeNames, boolean createdCopy)
    throws FontFormatException {
    super(platname, nativeNames);
    fontRank = Font2D.TYPE1_RANK;
    checkedNatives = true;
    try {
        verify();
    } catch (Throwable t) {
        if (createdCopy) {
            T1DisposerRecord ref = new T1DisposerRecord(platname);
            Disposer.addObjectRecord(bufferRef, ref);
            bufferRef = null;
        }
        if (t instanceof FontFormatException) {
            throw (FontFormatException)t;
        } else {
            throw new FontFormatException("Unexpected runtime exception.");
        }
    }
}
 
Example 3
Source File: TrueTypeFont.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * - does basic verification of the file
 * - reads the header table for this font (within a collection)
 * - reads the names (full, family).
 * - determines the style of the font.
 * - initializes the CMAP
 * @throws FontFormatException - if the font can't be opened
 * or fails verification,  or there's no usable cmap
 */
public TrueTypeFont(String platname, Object nativeNames, int fIndex,
             boolean javaRasterizer)
    throws FontFormatException {
    super(platname, nativeNames);
    useJavaRasterizer = javaRasterizer;
    fontRank = Font2D.TTF_RANK;
    try {
        verify();
        init(fIndex);
    } catch (Throwable t) {
        close();
        if (t instanceof FontFormatException) {
            throw (FontFormatException)t;
        } else {
            throw new FontFormatException("Unexpected runtime exception.");
        }
    }
    Disposer.addObjectRecord(this, disposerRecord);
}
 
Example 4
Source File: FontScaler.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static FontScaler getScaler(Font2D font,
                            int indexInCollection,
                            boolean supportsCJK,
                            int filesize) {
    FontScaler scaler = null;

    try {
        Object args[] = new Object[] {font, indexInCollection,
                                      supportsCJK, filesize};
        scaler = scalerConstructor.newInstance(args);
        Disposer.addObjectRecord(font, scaler);
    } catch (Throwable e) {
        scaler = nullScaler;

        //if we can not instantiate scaler assume bad font
        //NB: technically it could be also because of internal scaler
        //    error but here we are assuming scaler is ok.
        FontManager fm = FontManagerFactory.getInstance();
        fm.deRegisterBadFont(font);
    }
    return scaler;
}
 
Example 5
Source File: FontScaler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static FontScaler getScaler(Font2D font,
                            int indexInCollection,
                            boolean supportsCJK,
                            int filesize) {
    FontScaler scaler = null;

    try {
        Object args[] = new Object[] {font, indexInCollection,
                                      supportsCJK, filesize};
        scaler = scalerConstructor.newInstance(args);
        Disposer.addObjectRecord(font, scaler);
    } catch (Throwable e) {
        scaler = nullScaler;

        //if we can not instantiate scaler assume bad font
        //NB: technically it could be also because of internal scaler
        //    error but here we are assuming scaler is ok.
        FontManager fm = FontManagerFactory.getInstance();
        fm.deRegisterBadFont(font);
    }
    return scaler;
}
 
Example 6
Source File: TrueTypeFont.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * - does basic verification of the file
 * - reads the header table for this font (within a collection)
 * - reads the names (full, family).
 * - determines the style of the font.
 * - initializes the CMAP
 * @throws FontFormatException - if the font can't be opened
 * or fails verification,  or there's no usable cmap
 */
public TrueTypeFont(String platname, Object nativeNames, int fIndex,
             boolean javaRasterizer, boolean useFilePool)
    throws FontFormatException {
    super(platname, nativeNames);
    useJavaRasterizer = javaRasterizer;
    fontRank = Font2D.TTF_RANK;
    try {
        verify(useFilePool);
        init(fIndex);
        if (!useFilePool) {
           close();
        }
    } catch (Throwable t) {
        close();
        if (t instanceof FontFormatException) {
            throw (FontFormatException)t;
        } else {
            throw new FontFormatException("Unexpected runtime exception.");
        }
    }
    Disposer.addObjectRecord(this, disposerRecord);
}
 
Example 7
Source File: Type1Font.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * - does basic verification of the file
 * - reads the names (full, family).
 * - determines the style of the font.
 * @throws FontFormatException if the font can't be opened
 * or fails verification,  or there's no usable cmap
 */
public Type1Font(String platname, Object nativeNames, boolean createdCopy)
    throws FontFormatException {
    super(platname, nativeNames);
    fontRank = Font2D.TYPE1_RANK;
    checkedNatives = true;
    try {
        verify();
    } catch (Throwable t) {
        if (createdCopy) {
            T1DisposerRecord ref = new T1DisposerRecord(platname);
            Disposer.addObjectRecord(bufferRef, ref);
            bufferRef = null;
        }
        if (t instanceof FontFormatException) {
            throw (FontFormatException)t;
        } else {
            throw new FontFormatException("Unexpected runtime exception.");
        }
    }
}
 
Example 8
Source File: TrueTypeFont.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * - does basic verification of the file
 * - reads the header table for this font (within a collection)
 * - reads the names (full, family).
 * - determines the style of the font.
 * - initializes the CMAP
 * @throws FontFormatException - if the font can't be opened
 * or fails verification,  or there's no usable cmap
 */
public TrueTypeFont(String platname, Object nativeNames, int fIndex,
             boolean javaRasterizer)
    throws FontFormatException {
    super(platname, nativeNames);
    useJavaRasterizer = javaRasterizer;
    fontRank = Font2D.TTF_RANK;
    try {
        verify();
        init(fIndex);
    } catch (Throwable t) {
        close();
        if (t instanceof FontFormatException) {
            throw (FontFormatException)t;
        } else {
            throw new FontFormatException("Unexpected runtime exception.");
        }
    }
    Disposer.addObjectRecord(this, disposerRecord);
}
 
Example 9
Source File: FontScaler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static FontScaler getScaler(Font2D font,
                            int indexInCollection,
                            boolean supportsCJK,
                            int filesize) {
    FontScaler scaler = null;

    try {
        Object args[] = new Object[] {font, indexInCollection,
                                      supportsCJK, filesize};
        scaler = scalerConstructor.newInstance(args);
        Disposer.addObjectRecord(font, scaler);
    } catch (Throwable e) {
        scaler = nullScaler;

        //if we can not instantiate scaler assume bad font
        //NB: technically it could be also because of internal scaler
        //    error but here we are assuming scaler is ok.
        FontManager fm = FontManagerFactory.getInstance();
        fm.deRegisterBadFont(font);
    }
    return scaler;
}
 
Example 10
Source File: TrueTypeFont.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * - does basic verification of the file
 * - reads the header table for this font (within a collection)
 * - reads the names (full, family).
 * - determines the style of the font.
 * - initializes the CMAP
 * @throws FontFormatException if the font can't be opened
 * or fails verification,  or there's no usable cmap
 */
public TrueTypeFont(String platname, Object nativeNames, int fIndex,
             boolean javaRasterizer, boolean useFilePool)
    throws FontFormatException {
    super(platname, nativeNames);
    useJavaRasterizer = javaRasterizer;
    fontRank = Font2D.TTF_RANK;
    try {
        verify(useFilePool);
        init(fIndex);
        if (!useFilePool) {
           close();
        }
    } catch (Throwable t) {
        close();
        if (t instanceof FontFormatException) {
            throw (FontFormatException)t;
        } else {
            throw new FontFormatException("Unexpected runtime exception.");
        }
    }
    Disposer.addObjectRecord(this, disposerRecord);
}
 
Example 11
Source File: TestDisposerLeak.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testLeak() throws Exception {
    MyDisposerRec disposerRecord = new MyDisposerRec();
    for (int i = 0; i < 30000; i++) {
        Disposer.addObjectRecord(new Object(), disposerRecord);
    }
    generateOOME();
    readyForDispose = true;
    Disposer.addObjectRecord(new Object(), new EndRec());
    generateOOME();
}
 
Example 12
Source File: FileFont.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static void setFileToRemove(List<Font2D> fonts,
                            File file, int cnt,
                            CreatedFontTracker tracker)
{
    CreatedFontFileDisposerRecord dr =
        new CreatedFontFileDisposerRecord(file, cnt, tracker);

    for (Font2D f : fonts) {
        Disposer.addObjectRecord(f, dr);
    }
}
 
Example 13
Source File: SunLayoutEngine.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private synchronized long getNativePtr() {
    if (facePtr == null) {
        facePtr = createFace(font, isAAT(font),
                font.getPlatformNativeFontPtr());
        if (facePtr != 0) {
            Disposer.addObjectRecord(font, this);
        }
        font = null;
    }
    return facePtr;
}
 
Example 14
Source File: FileFont.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void setFileToRemove(File file, CreatedFontTracker tracker) {
    Disposer.addObjectRecord(this,
                     new CreatedFontFileDisposerRecord(file, tracker));
}
 
Example 15
Source File: FileFont.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void setFileToRemove(File file, CreatedFontTracker tracker) {
    Disposer.addObjectRecord(this,
                     new CreatedFontFileDisposerRecord(file, tracker));
}
 
Example 16
Source File: FileFont.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void setFileToRemove(File file, CreatedFontTracker tracker) {
    Disposer.addObjectRecord(this,
                     new CreatedFontFileDisposerRecord(file, tracker));
}
 
Example 17
Source File: FileFont.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static void setFileToRemove(Object font, File file, CreatedFontTracker tracker) {
    Disposer.addObjectRecord(font,
                     new CreatedFontFileDisposerRecord(file, tracker));
}
 
Example 18
Source File: FileFont.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void setFileToRemove(File file, CreatedFontTracker tracker) {
    Disposer.addObjectRecord(this,
                     new CreatedFontFileDisposerRecord(file, tracker));
}
 
Example 19
Source File: FileFont.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void setFileToRemove(Object font, File file, CreatedFontTracker tracker) {
    Disposer.addObjectRecord(font,
                     new CreatedFontFileDisposerRecord(file, tracker));
}
 
Example 20
Source File: FileFont.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static void setFileToRemove(Object font, File file, CreatedFontTracker tracker) {
    Disposer.addObjectRecord(font,
                     new CreatedFontFileDisposerRecord(file, tracker));
}