Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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  
  Fonts  (Read 1252 times)
0 Members and 1 Guest are viewing this topic.
Offline zeroone
« Posted 2011-12-27 18:15:13 »

What are the best practices for fonts and Graphics.drawString() ?  What is the minimum set of things to do to get consistent rendering results across different systems?
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #1 - Posted 2011-12-28 09:02:48 »

Java has some in built mappings for virtual serif and sans-serif.  (Serif, Sans-serif, Monospaced, Dialog, and DialogInput.)  These map in an implementation specific way, but work cross platform.  If you request an actual physical font by name, the system may not have it.

Serif tend to map to Times Roman generally.  Sams-serif maps to a Helvetica style font (Arial on Windows)

Time flies like a bird. Fruit flies like a banana.
Offline zeroone
« Reply #2 - Posted 2011-12-28 15:45:46 »

Quote
Java has some in built mappings for virtual serif and sans-serif.  (Serif, Sans-serif, Monospaced, Dialog, and DialogInput.)  These map in an implementation specific way, but work cross platform.  If you request an actual physical font by name, the system may not have it.

Serif tend to map to Times Roman generally.  Sams-serif maps to a Helvetica style font (Arial on Windows)

But what about the effects of different DPI settings and OS's in terms of size and positioning?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2011-12-28 23:13:40 »

Yes different OS's will have different font sizes.

Offline zeroone
« Reply #4 - Posted 2011-12-29 00:03:47 »

Quote
Yes different OS's will have different font sizes.

So, we're stuck with bitmap fonts?
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #5 - Posted 2011-12-29 00:05:26 »

Not really, the differences aren't huge anyway. I played my game on a Mac and even though the font was a tiny bit bigger than on Windows, nothing was broken at all. You just have to give yourself some breathing space.

Offline zeroone
« Reply #6 - Posted 2011-12-29 00:20:19 »

I only have access to a Vector-06C.  I'm not sure how much "breathing space" to leave.
Offline ShannonSmith
« Reply #7 - Posted 2011-12-29 00:22:49 »

Quote
Yes different OS's will have different font sizes.

So, we're stuck with bitmap fonts?

You can always use FontMetrics to get the pixel size and either derive a font to get the pixel size you are after or scale appropriately before drawing.
Offline pjt33
« Reply #8 - Posted 2011-12-30 12:32:04 »

If you have sufficient bytes, FontMetrics is the way to go. It lets you align to left, right or centre, and it lets you get line spacing correct. I used it for Gravitational Fourks because that had quite a lot of text.

If you don't then allowing for a variation of 15% either way is ample. If you're feeling bold you could assume that Sun chose suitably consistent default fonts and that other organisations haven't messed them up too much and reduce that to 5%. OTOH I know that Flash games often break badly for me because of bad assumptions about text layout or font sizes, so I'm inclined to caution.
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.

pw (35 views)
2014-07-24 01:59:36

Riven (34 views)
2014-07-23 21:16:32

Riven (22 views)
2014-07-23 21:07:15

Riven (25 views)
2014-07-23 20:56:16

ctomni231 (56 views)
2014-07-18 06:55:21

Zero Volt (48 views)
2014-07-17 23:47:54

danieldean (39 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!