Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 635563 Details for
Bug 862355
The method Font.createFont() fails if no fonts are installed
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
First patch
noFontFound.patch (text/plain), 12.51 KB, created by
jiri vanek
on 2012-10-30 12:58:21 UTC
(
hide
)
Description:
First patch
Filename:
MIME Type:
Creator:
jiri vanek
Created:
2012-10-30 12:58:21 UTC
Size:
12.51 KB
patch
obsolete
>diff -r 65d2c6726487 src/share/classes/java/awt/NoFontFoundException.java >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/src/share/classes/java/awt/NoFontFoundException.java Tue Oct 30 13:46:48 2012 +0100 >@@ -0,0 +1,51 @@ >+/* >+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. >+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. >+ * >+ * This code is free software; you can redistribute it and/or modify it >+ * under the terms of the GNU General Public License version 2 only, as >+ * published by the Free Software Foundation. Oracle designates this >+ * particular file as subject to the "Classpath" exception as provided >+ * by Oracle in the LICENSE file that accompanied this code. >+ * >+ * This code is distributed in the hope that it will be useful, but WITHOUT >+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or >+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License >+ * version 2 for more details (a copy is included in the LICENSE file that >+ * accompanied this code). >+ * >+ * You should have received a copy of the GNU General Public License version >+ * 2 along with this work; if not, write to the Free Software Foundation, >+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. >+ * >+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA >+ * or visit www.oracle.com if you need additional information or have any >+ * questions. >+ */ >+ >+package java.awt; >+ >+/** >+ * Thrown by method getDefaultPlatformFont in the <code>X11FontManager</code> class to indicate >+ * that no fonts are installed. >+ * >+ * @author Jiri Vanek >+ * @see java.awt.Font >+ * @since 1.8 >+ */ >+public >+class NoFontFoundException extends RuntimeException { >+ /* >+ * serialVersionUID >+ */ >+ private static final long serialVersionUID = -4346654667845761562L; >+ >+ /** >+ * Report a FontFormatException for the reason specified. >+ * @param reason a <code>String</code> message indicating why >+ * the font was not found. >+ */ >+ public NoFontFoundException(String reason) { >+ super (reason); >+ } >+} >diff -r 65d2c6726487 src/share/classes/sun/font/FontManagerFactory.java >--- a/src/share/classes/sun/font/FontManagerFactory.java Thu Oct 25 09:54:03 2012 -0700 >+++ b/src/share/classes/sun/font/FontManagerFactory.java Tue Oct 30 13:46:48 2012 +0100 >@@ -27,8 +27,11 @@ > > import java.awt.AWTError; > import java.awt.Font; >+import java.awt.FontFormatException; > import java.awt.GraphicsEnvironment; >+import java.awt.NoFontFoundException; > import java.awt.Toolkit; >+import java.io.File; > import java.security.AccessController; > import java.security.PrivilegedAction; > >@@ -86,10 +89,62 @@ > IllegalAccessException ex) { > throw new InternalError(ex); > >+ } catch (NoFontFoundException fex) { >+ //This do not need to lead to crash, if font is supplied. >+ //After this null is returned, no instance set and dummy, >+ // not caching, not cached FontManager is returned later >+ //fex.printStackTrace(); > } > return null; > } > }); >+ >+ if (instance == null){ >+ return new FontManager() { >+ >+ @Override >+ public boolean registerFont(Font font) { >+ return false; >+ } >+ >+ @Override >+ public void deRegisterBadFont(Font2D font2D) { >+ //no op in dummy one >+ } >+ >+ @Override >+ public Font2D findFont2D(String name, int style, int fallback) { >+ return null; >+ } >+ >+ @Override >+ public Font2D createFont2D(File fontFile, int fontFormat, >+ boolean isCopy, CreatedFontTracker tracker) >+ throws FontFormatException { >+ return SunFontManager.prepareFont2D(fontFile, fontFormat, isCopy, tracker); >+ } >+ >+ @Override >+ public boolean usingPerAppContextComposites() { >+ return false; >+ } >+ >+ @Override >+ public Font2DHandle getNewComposite(String family, int style, Font2DHandle handle) { >+ return handle; >+ } >+ >+ @Override >+ public void preferLocaleFonts() { >+ //no op in dummy one >+ } >+ >+ @Override >+ public void preferProportionalFonts() { >+ //no op in dummy one >+ } >+ }; >+ } > > return instance; > } >diff -r 65d2c6726487 src/share/classes/sun/font/SunFontManager.java >--- a/src/share/classes/sun/font/SunFontManager.java Thu Oct 25 09:54:03 2012 -0700 >+++ b/src/share/classes/sun/font/SunFontManager.java Tue Oct 30 13:46:48 2012 +0100 >@@ -2446,14 +2446,85 @@ > // MACOSX end > Vector<File> tmpFontFiles = null; > >+ @Override > public Font2D createFont2D(File fontFile, int fontFormat, > boolean isCopy, CreatedFontTracker tracker) > throws FontFormatException { > >- String fontFilePath = fontFile.getPath(); >- FileFont font2D = null; > final File fFile = fontFile; > final CreatedFontTracker _tracker = tracker; >+ FileFont font2D = prepareFont2D(fFile, fontFormat, isCopy, _tracker); >+ if (isCopy) { >+ font2D.setFileToRemove(fontFile, tracker); >+ synchronized (FontManager.class) { >+ >+ if (tmpFontFiles == null) { >+ tmpFontFiles = new Vector<File>(); >+ } >+ tmpFontFiles.add(fontFile); >+ >+ if (fileCloser == null) { >+ final Runnable fileCloserRunnable = new Runnable() { >+ public void run() { >+ java.security.AccessController.doPrivileged( >+ new java.security.PrivilegedAction() { >+ public Object run() { >+ >+ for (int i=0;i<CHANNELPOOLSIZE;i++) { >+ if (fontFileCache[i] != null) { >+ try { >+ fontFileCache[i].close(); >+ } catch (Exception e) { >+ } >+ } >+ } >+ if (tmpFontFiles != null) { >+ File[] files = new File[tmpFontFiles.size()]; >+ files = tmpFontFiles.toArray(files); >+ for (int f=0; f<files.length;f++) { >+ try { >+ files[f].delete(); >+ } catch (Exception e) { >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ }); >+ } >+ }; >+ java.security.AccessController.doPrivileged( >+ new java.security.PrivilegedAction() { >+ public Object run() { >+ /* The thread must be a member of a thread group >+ * which will not get GCed before VM exit. >+ * Make its parent the top-level thread group. >+ */ >+ ThreadGroup tg = >+ Thread.currentThread().getThreadGroup(); >+ for (ThreadGroup tgn = tg; >+ tgn != null; >+ tg = tgn, tgn = tg.getParent()); >+ fileCloser = new Thread(tg, fileCloserRunnable); >+ fileCloser.setContextClassLoader(null); >+ Runtime.getRuntime().addShutdownHook(fileCloser); >+ return null; >+ } >+ }); >+ } >+ } >+ } >+ return font2D; >+ } >+ >+ >+ public static FileFont prepareFont2D(final File fFile, int fontFormat, >+ boolean isCopy, final CreatedFontTracker _tracker) >+ throws FontFormatException { >+ FileFont font2D = null; >+ String fontFilePath = fFile.getPath(); > try { > switch (fontFormat) { > case Font.TRUETYPE_FONT: >@@ -2480,68 +2551,7 @@ > } > throw(e); > } >- if (isCopy) { >- font2D.setFileToRemove(fontFile, tracker); >- synchronized (FontManager.class) { >- >- if (tmpFontFiles == null) { >- tmpFontFiles = new Vector<File>(); >- } >- tmpFontFiles.add(fontFile); >- >- if (fileCloser == null) { >- final Runnable fileCloserRunnable = new Runnable() { >- public void run() { >- java.security.AccessController.doPrivileged( >- new java.security.PrivilegedAction() { >- public Object run() { >- >- for (int i=0;i<CHANNELPOOLSIZE;i++) { >- if (fontFileCache[i] != null) { >- try { >- fontFileCache[i].close(); >- } catch (Exception e) { >- } >- } >- } >- if (tmpFontFiles != null) { >- File[] files = new File[tmpFontFiles.size()]; >- files = tmpFontFiles.toArray(files); >- for (int f=0; f<files.length;f++) { >- try { >- files[f].delete(); >- } catch (Exception e) { >- } >- } >- } >- >- return null; >- } >- >- }); >- } >- }; >- java.security.AccessController.doPrivileged( >- new java.security.PrivilegedAction() { >- public Object run() { >- /* The thread must be a member of a thread group >- * which will not get GCed before VM exit. >- * Make its parent the top-level thread group. >- */ >- ThreadGroup tg = >- Thread.currentThread().getThreadGroup(); >- for (ThreadGroup tgn = tg; >- tgn != null; >- tg = tgn, tgn = tg.getParent()); >- fileCloser = new Thread(tg, fileCloserRunnable); >- fileCloser.setContextClassLoader(null); >- Runtime.getRuntime().addShutdownHook(fileCloser); >- return null; >- } >- }); >- } >- } >- } >+ > return font2D; > } > >diff -r 65d2c6726487 src/solaris/classes/sun/awt/X11FontManager.java >--- a/src/solaris/classes/sun/awt/X11FontManager.java Thu Oct 25 09:54:03 2012 -0700 >+++ b/src/solaris/classes/sun/awt/X11FontManager.java Tue Oct 30 13:46:48 2012 +0100 >@@ -1,6 +1,7 @@ > package sun.awt; > > import java.awt.GraphicsEnvironment; >+import java.awt.NoFontFoundException; > import java.io.BufferedReader; > import java.io.File; > import java.io.FileReader; >@@ -776,6 +777,9 @@ > getFontConfigManager().initFontConfigFonts(false); > FontConfigManager.FcCompFont[] fontConfigFonts = > getFontConfigManager().getFontConfigFonts(); >+ if (fontConfigFonts == null) { >+ throw new NoFontFoundException("getFontConfigManager().getFontConfigFonts() returned null"); >+ } > for (int i=0; i<fontConfigFonts.length; i++) { > if ("sans".equals(fontConfigFonts[i].fcFamily) && > 0 == fontConfigFonts[i].style) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 862355
: 635563