Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (602)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
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  
  using fonts problem  (Read 1208 times)
0 Members and 1 Guest are viewing this topic.
Offline VirtuaCasper

Junior Newbie

Java games rock!

« Posted 2006-04-28 09:05:48 »

im having problems trying to load a font and display a string. all i seem to get is a little red blob.
heres the source code.

import java.awt.*;
import java.awt.event.*;

// font found @

class FrameResponce extends WindowAdapter
   public void windowClosing(WindowEvent e)

class FrameExt extends Frame
   private Font gameFont;

   public FrameExt()
         gameFont = Font.createFont(Font.TRUETYPE_FONT,new File("MYSCARS_.ttf"));
         setTitle("Font Test");
         addWindowListener(new FrameResponce());
      catch(Exception e)
         System.out.println("*** Exception ***");
         System.out.println("Message: "+e.getMessage());
         System.out.println("Cause:   "+e.getCause());
   public void paint(Graphics g)

class FontTest
   public static void main(String arg[])
      FrameExt fext = new FrameExt();
Offline Kova

Senior Devvie

« Reply #1 - Posted 2006-04-28 10:20:14 »

first of all
use code tags

second, for your font to display correctly you need to:

a) have a true type font (.ttf) or adobe type1 font.
b) make sure that font has unicode support (must contain a unicode glyphe map)

It's probably unicode problem.
was trying to use custom (non-system) font few days ago and I was greatly dissapointed. I mean if font dosen't support unicode why not properly display things that it supports? I don't even need something other then standard english letters. Anyway I was told to search for some converter that would convert font to unicode one, I didn't searched yet.
Offline VirtuaCasper

Junior Newbie

Java games rock!

« Reply #2 - Posted 2006-04-30 17:38:04 »

i have fixed the problem by placing the above font in c:\windows\font folder and then replacing Font.createFont with the Font contstructor and now it works fine.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kova

Senior Devvie

« Reply #3 - Posted 2006-04-30 19:24:33 »

well it might work but it's not a solution since you put stuff into user's windows folder... but since it works that means createFont() should work also (or  Huh). I have the font in fonts directory and it dosen't work.
Offline woogley
« Reply #4 - Posted 2006-04-30 19:43:22 »

you might as well just bitmap the entire font and then just draw each letter as an image. that will give you a boost in FPS anyway ..
Offline Kova

Senior Devvie

« Reply #5 - Posted 2006-04-30 23:32:43 »

that's a good idea, but it would be pain in the ass to cut out all characters in good size and there's always font size problem.
Actually since I don't have any important runtime created text I was planning to do all text in photoshop and then use pictures (if I don't find proper unicode font).
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (15 views)
2015-07-29 04:35:27

Riven (37 views)
2015-07-27 16:38:00

Riven (18 views)
2015-07-27 15:35:20

Riven (21 views)
2015-07-27 12:26:13

Riven (12 views)
2015-07-27 12:23:39

BurntPizza (30 views)
2015-07-25 00:14:37

BurntPizza (42 views)
2015-07-24 22:06:39

BurntPizza (24 views)
2015-07-24 06:06:53

NoxInc (31 views)
2015-07-22 22:16:53

NoxInc (18 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!