Hi Phil,<br><br>I believe that the underlying problem here is that it should be legal to create a font from a file, even if the FontManager doesn't have any fonts installed.<br><br>So, code like the one in the example:<br>
<pre class="" id="comment_text_0">public class Test {
public static void main(String[] args) throws Exception {
Font.createFont(Font.TRUETYPE_FONT, new File("example.ttf"));
}
}</pre><br>When passed a real, valid font (example.ttf in this case) would still fail with the old code, and instead would work with the given patch (at least, I think this is the idea here, Jiri can probably explain in more details his intentions?).<br>
<br>Cheers,<br>Mario<br><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/12 Phil Race <span dir="ltr"><<a href="mailto:philip.race@oracle.com" target="_blank">philip.race@oracle.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Jiri,<br>
<br>
Doesn't this just move the point of failure to a bit later ?<br>
I can't see how having zero fonts on the system is survivable for an<br>
app that uses fonts. That's the principal reason we haven't tried<br>
to do something like this already.<br>
<br>
When facing system configuration issues maybe we just need to<br>
print a better message for the exception such as<br>
throw new InternalError("Can't find any fonts installed on this system.");<br>
<br>
Or make the default font more configurable and distros could ship one in jre/lib/fonts.<br>
<br>
BTW it appears you are only trying to solve the problem for Linux/Unix.<br>
Nothing for Windows or OS X.<span class="HOEnZb"><font color="#888888"><br>
<br>
-phil.</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 11/12/2012 10:07 AM, Jiri Vanek wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi!<br>
<br>
This is attempt to fix <a href="https://bugzilla.redhat.com/show_bug.cgi?id=862355" target="_blank">https://bugzilla.redhat.com/<u></u>show_bug.cgi?id=862355</a><br>
The patch is introducing new exception src/share/classes/sun/font/<u></u>NoFontsFoundException.java, which is thrown from /src/solaris/classes/sun/awt/<u></u>X11FontManager.java instead of null pointer exception when no fonts are found on system.<br>
Exception is then catch in src/share/classes/sun/font/<u></u>FontManagerFactory.java, and in this case it returns (and not caching the instance of it) dummy font manager instead of continue in failure.<br>
the dummy manager do nothing, except that it is able to create java.awt.Font in same way as SunFontManager is doing, but is not doing any caching.<br>
<br>
To avoid duplicate code with src/share/classes/sun/font/<u></u>SunFontManager.java, i have extracted code from method createFont2D to new method here - prepareFont2D - which is responsible for creating font until caching..<br>
<br>
Best regards,<br>
J.<br>
<br>
webrev<br>
<a href="http://jvanek.fedorapeople.org/oracle/jdk8/webrevs/fontProperties/" target="_blank">http://jvanek.fedorapeople.<u></u>org/oracle/jdk8/webrevs/<u></u>fontProperties/</a><br>
with test (although it will probably need some tuning and I'm not sure where is the best place for it)<br>
<a href="http://jvanek.fedorapeople.org/oracle/jdk8/webrevs/fontProperties/test/src/nofontsreproducer/" target="_blank">http://jvanek.fedorapeople.<u></u>org/oracle/jdk8/webrevs/<u></u>fontProperties/test/src/<u></u>nofontsreproducer/</a> <br>
</blockquote>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>pgp key: <a href="http://subkeys.pgp.net/" target="_blank">http://subkeys.pgp.net/</a> PGP Key ID: 80F240CF<br>Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF<br>
<br>IcedRobot: <a href="http://www.icedrobot.org" target="_blank">www.icedrobot.org</a><br>Proud GNU Classpath developer: <a href="http://www.classpath.org/" target="_blank">http://www.classpath.org/</a><br>Read About us at: <a href="http://planet.classpath.org" target="_blank">http://planet.classpath.org</a><br>
OpenJDK: <a href="http://openjdk.java.net/projects/caciocavallo/" target="_blank">http://openjdk.java.net/projects/caciocavallo/</a><br><br>Please, support open standards:<br><a href="http://endsoftpatents.org/" target="_blank">http://endsoftpatents.org/</a><br>
</div>