Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>'Airacobra Condensed' font available from <a href="http://www.webpagepublicity.com/free-fonts.html" rel="noreferrer">Download Free Fonts</a>.</p> <p><img src="https://i.stack.imgur.com/NCKKt.png" alt="Registered Font"></p> <pre><code>import java.awt.*; import javax.swing.*; import java.net.URL; class LoadFont { public static void main(String[] args) throws Exception { // This font is &lt; 35Kb. URL fontUrl = new URL("http://www.webpagepublicity.com/" + "free-fonts/a/Airacobra%20Condensed.ttf"); Font font = Font.createFont(Font.TRUETYPE_FONT, fontUrl.openStream()); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.registerFont(font); JList fonts = new JList( ge.getAvailableFontFamilyNames() ); JOptionPane.showMessageDialog(null, new JScrollPane(fonts)); } } </code></pre> <hr> <p>OK, that was fun, but what does this font actually look like?</p> <p><img src="https://i.stack.imgur.com/tWQZK.png" alt="Display Font"></p> <pre><code>import java.awt.*; import javax.swing.*; import java.net.URL; class DisplayFont { public static void main(String[] args) throws Exception { URL fontUrl = new URL("http://www.webpagepublicity.com/" + "free-fonts/a/Airacobra%20Condensed.ttf"); Font font = Font.createFont(Font.TRUETYPE_FONT, fontUrl.openStream()); font = font.deriveFont(Font.PLAIN,20); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.registerFont(font); JLabel l = new JLabel( "The quick brown fox jumps over the lazy dog. 0123456789"); l.setFont(font); JOptionPane.showMessageDialog(null, l); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload