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
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
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:
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();
}
no i want to make my own print system
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.
i want to make my method of like Graphics.printString()…
like i dont use Graphics.setFont …
sorry not Graphics.printString it is Graphics.drawString
lol i cant think today !!
You set the font and then you can draw as much as you want…
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)
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.