Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  New font for my game ????  (Read 476 times)
0 Members and 1 Guest are viewing this topic.
Offline 666DemonThe

Senior Newbie





« Posted 2013-07-24 13:28:21 »

i want to make my own font and make my own print method to print something on the screen
can you tell me how to do it or send me a video ?

Edit : i want to make my own print system
Offline Sethir

Senior Newbie


Exp: 3 years



« Reply #1 - Posted 2013-07-24 13:34:47 »

Do you want to implement an existing font or creat your very own?
If you want to implement an existing one, then there are many ways.
Here is the way I implement my custom font:
1  
2  
3  
4  
5  
6  
7  
8  
9  
Font font = new Font("Arial", Font.PLAIN, 16); // fallback if font not found
     
try{
  font = Font.createFont(Font.TRUETYPE_FONT, new File("resources/fonts/sao_font.ttf"));
  font = font.deriveFont(Font.PLAIN, 16);
} catch (Exception e) {
  System.err.println("Font not found");
  e.printStackTrace();
}
Offline 666DemonThe

Senior Newbie





« Reply #2 - Posted 2013-07-24 13:47:55 »

no i want to make my own print system :/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jonjava
« Reply #3 - Posted 2013-07-24 14:07:49 »

What do you mean by "your own print system"??

The "System.out.println()" is just a wrap around for your programs output. You can't change the font on that since you can only control the things that are shown on your programs screen. System.out.println() sends it directly to the console where you don't have control of it anymore.

If you want to show text on a screen like a JFrame you can use various classes like JTextArea or JTextField that come with a bunch of nifty options. Or simply draw text with the Graphics objects drawText() method.

Or if you're using other libraries you use their way of printing out text (and changing the font).

You could certainly wrap your text drawing calls (in whatever library you use) inside of your own methods to have them come out a certain way you prefer and for ease of access.

Offline 666DemonThe

Senior Newbie





« Reply #4 - Posted 2013-07-24 14:26:06 »

i want to make my method of like Graphics.printString().....
like i dont use Graphics.setFont .....
Offline jonjava
« Reply #5 - Posted 2013-07-24 14:40:46 »

i want to make my method of like Graphics.printString().....
like i dont use Graphics.setFont .....


Offline 666DemonThe

Senior Newbie





« Reply #6 - Posted 2013-07-24 14:46:22 »

sorry not Graphics.printString it is Graphics.drawString Cheesy Cheesy lol i cant think today !!
Online Longarmx
« Reply #7 - Posted 2013-07-24 14:48:00 »

You set the font and then you can draw as much as you want...

Offline jonjava
« Reply #8 - Posted 2013-07-24 14:50:21 »

You can change the font the Graphics object uses with the setFont(Font font) method, look at these:

Make new font
http://docs.oracle.com/javase/6/docs/api/java/awt/Font.html#Font(java.lang.String, int, int)

Set the font for the graphics object
http://docs.oracle.com/javase/6/docs/api/java/awt/Graphics.html#setFont(java.awt.Font)

drawString()
http://docs.oracle.com/javase/6/docs/api/java/awt/Graphics.html#drawString(java.lang.String, int, int)

Online kpars

JGO Wizard


Medals: 79
Projects: 4
Exp: 3 years


Extreme Typist.


« Reply #9 - Posted 2013-07-24 16:53:42 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
public class Fonts {
    private static Color color1;
    private static Color color2;

    private static Font font;

    public static void setFont(String face, int size) {
        font = new Font(face, 0, size);
    }

    public static void setCol(Color col1, Color col2) {
        color1 = col1;
        color2 = col2;
    }

    public static void drawString(String msg, int x, int y) {
        Graphics g = YourGameClass.getGraphics();

        g.setFont(font);
        g.setColor(color1);
        g.drawString(msg, x-1, y-1);
        g.setColor(color2);
        g.drawString(msg, x, y);
    }
}


Here, use this.  Wink

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (22 views)
2014-09-12 09:08:26

Norakomi (55 views)
2014-09-10 13:57:51

TehJavaDev (66 views)
2014-09-10 06:39:09

Tekkerue (33 views)
2014-09-09 02:24:56

mitcheeb (54 views)
2014-09-08 06:06:29

BurntPizza (38 views)
2014-09-07 01:13:42

Longarmx (24 views)
2014-09-07 01:12:14

Longarmx (30 views)
2014-09-07 01:11:22

Longarmx (28 views)
2014-09-07 01:10:19

mitcheeb (37 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!