title: How do you import a font?
body: <p>I'm wondering how you would go about <i>importing</i> a font.</p>
  
  <p>I'm trying to use a custom downloaded font but since most computers that would go to run this would not have this font as it's not a default font. How would I go about making the font work even if they don't have the font?</p>
  
  <p>I'm using it for a gameover screen and need to display a score with it and want the score text to be the same font. This is the image,</p>
  
  <p><img src="https://i.stack.imgur.com/yXO0g.png" alt="enter image description here"></p>
  
  <p>In case it matters the font name on my computer is <code>Terminal</code></p>
  
  <p>Edit: I'm assuming it would have to have the font in the directory of the java file and there would be some way of using that but I'm not sure how. Or is there a better way?</p>
  
  <p>Edit2: I have found a nice tutorial on how to do it but need some help on how I go about using this... <a href="http://docs.oracle.com/javase/tutorial/2d/text/fonts.html" rel="noreferrer">click me for link</a></p>
  
  <p>Edit3:</p>
  
  <pre><code>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);
  g.setFont(font);
  </code></pre>
  
  <p>Error Message</p>
  
  <pre><code>File: F:\Computer Science\draw.java  [line: 252]
  Error: F:\Computer Science\draw.java:252: font is not public in java.awt.Component; cannot be accessed from outside package
  </code></pre>
  
  <p>Here is what I'm trying:</p>
  
  <pre><code>URL fontUrl = new URL("http://img.dafont.com/dl/?f=badaboom_bb");
  Font font = Font.createFont(Font.TRUETYPE_FONT, fontUrl.openStream());
  GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  ge.registerFont(font);
  g.setFont(font);
  </code></pre>
  
  <p>Edit4:</p>
  
  <pre><code>File fontfile = new File("TexasLED.ttf");
  File.toURI(fontfile).toURL(fontfile);
  URL fontUrl = new URL("fontfile");
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>Error: F:\Computer Science\draw.java:250: toURI() in java.io.File cannot be applied to (java.io.File)
  </code></pre>