Java Code Examples for sun.font.CreatedFontTracker#acquirePermit()
The following examples show how to use
sun.font.CreatedFontTracker#acquirePermit() .
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 | 4 votes |
/** * 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 2
Source File: Font.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 3
Source File: Font.java From jdk-1.7-annotated with Apache License 2.0 | 4 votes |
/** * 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 4
Source File: Font.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 5
Source File: Font.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 6
Source File: Font.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * 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 7
Source File: Font.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * 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 8
Source File: Font.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * 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 9
Source File: Font.java From Java8CN with Apache License 2.0 | 4 votes |
/** * 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 10
Source File: Font.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 11
Source File: Font.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * 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 12
Source File: Font.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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 13
Source File: Font.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * 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 14
Source File: Font.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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 15
Source File: Font.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * 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 16
Source File: Font.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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 17
Source File: Font.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * 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 18
Source File: Font.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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 19
Source File: Font.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * 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(); } } }
Example 20
Source File: Font.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * 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(); } } }