Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Font WORA blues.

Reply
Thread Tools

Font WORA blues.

 
 
Roedy Green
Guest
Posts: n/a
 
      07-27-2008
Hendrik Maryns sent me a screen shot of one of my Applets running on
his machine. It looks godawful.

I write some JLabel text with Font( "Dialog", Font.BOLD, 16 );

It looks beautiful on my Vista machine, but on his, it looks terrible.
The Font renders 12% bigger so there is not enough room in the various
boxes.

Further, it looks moth-eaten, even more than I might expect from
anti-alias turned off.

I don't yet know what platform/Browser/Java version he is using. Any
thoughts on what could be happening?

<rant>
If you look at http://mindprod.com/applet/fontshowerawt.html you can
view all the fonts available to Java on your machine. Set it to say
15 points. Then look at the various fonts. They won't be ANYWHERE
NEAR the same size! ARGGH!! Spit, splutter. Surely Java should
auto-compensate so that that font families are interchangeable.
</rant>

However, in this case I am using Dialog, a logical font 100% under
Sun's control. Sun have no excuse for it rendering so differently on
different platforms!

Is there some sort of font magnification feature of some platforms
that could be fouling things up?

Any tips for me and the peanut gallery on how to write WORA font code
when you only have one machine?

--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
 
Tom Anderson
Guest
Posts: n/a
 
      07-27-2008
On Sun, 27 Jul 2008, RedGrittyBrick wrote:

> Roedy Green wrote:
>
>> <rant>
>> If you look at http://mindprod.com/applet/fontshowerawt.html you can
>> view all the fonts available to Java on your machine. Set it to say
>> 15 points. Then look at the various fonts. They won't be ANYWHERE
>> NEAR the same size! ARGGH!! Spit, splutter. Surely Java should
>> auto-compensate so that that font families are interchangeable.
>> </rant>

>
> Not Java's fault?
> http://nwalsh.com/comp.fonts/FAQ/cf_8.htm#SEC16
>
> I don't think Java should be changed to misrepresent font sizes.


I think you're right.

But it *is* still *bloody annoying*. And not just in java - in a word
processor or whatever too. You have text in some typeface, you change the
typeface, and it's a completely different size. Why? Because point size
has become meaningless because designers are precious special snowflakes
whose freedom to design creatively, and impose their own beliefs about how
much leading their precious special snowflake font neeeds on its user, is
more import than their users' need to have practical, usable fonts.

> Maybe it could have some method of calculating a font size for a
> specified font to make that font fit some arbitrary metric (e.g. desired
> distance from top of tallest ascender to bottom of lowest descender)


That would be useful. I wrote code to do just that, back in the 1.1 days,
to deal with just the problem Roedy has - getting a font size that is
actually a particular pixel height. It's not too hard, you just write a
function int getFontHeight(Font base, float size, Graphics g) that uses
getFontMetrics etc to work out the font height in pixels, then do an
optimisation in a loop to work out the font size you need to specify to
get the pixel height you want.

tom

--
Initial thoughts - who cares? Subsequent thoughts - omg!!! (Female, 14,
Scotland) -- 4.5 million young Brits' futures could be compromised by
their electronic footprint, Information Commissioner's Office
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-27-2008
On Sun, 27 Jul 2008 12:18:30 +0100, RedGrittyBrick
<(E-Mail Removed)> wrote, quoted or indirectly quoted
someone who said :

>I don't think Java should be changed to misrepresent font sizes. Maybe
>it could have some method of calculating a font size for a specified
>font to make that font fit some arbitrary metric (e.g. desired distance
>from top of tallest ascender to bottom of lowest descender)


Your frame has a certain size. When a font is substituted, you want
it to take up the same amount of pixel space as the one you used to
design the app.

We need an Font constructor variant that redefines point size to be
max ascender - descender in pixels. e.g. put a boolean on the end to
request normalized sizes or create an ExactFont class. That would
even let you retrofit the feature into older JVMs.



--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-27-2008
On Sun, 27 Jul 2008 14:13:12 +0100, Tom Anderson
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>
>That would be useful. I wrote code to do just that, back in the 1.1 days,
>to deal with just the problem Roedy has - getting a font size that is
>actually a particular pixel height. It's not too hard, you just write a
>function int getFontHeight(Font base, float size, Graphics g) that uses
>getFontMetrics etc to work out the font height in pixels, then do an
>optimisation in a loop to work out the font size you need to specify to
>get the pixel height you want.


It is goofy to do that calculation in your app. The info is probably
already buried somewhere in the font file. All it needs is a way to
get at it, or possibly to precalculate and cache it as part of JVM
install.

--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
RedGrittyBrick
Guest
Posts: n/a
 
      07-28-2008
Roedy Green wrote:
> On Sun, 27 Jul 2008 12:18:30 +0100, RedGrittyBrick
> <(E-Mail Removed)> wrote, quoted or indirectly quoted
> someone who said :
>
>> I don't think Java should be changed to misrepresent font sizes. Maybe
>> it could have some method of calculating a font size for a specified
>> font to make that font fit some arbitrary metric (e.g. desired distance
>>from top of tallest ascender to bottom of lowest descender)

>
> Your frame has a certain size. When a font is substituted, you want
> it to take up the same amount of pixel space as the one you used to
> design the app.
>
> We need an Font constructor variant that redefines point size to be
> max ascender - descender in pixels. e.g. put a boolean on the end to
> request normalized sizes or create an ExactFont class. That would
> even let you retrofit the feature into older JVMs.
>
>
>



How do you handle Internationalization? Maybe you can treat this problem
as a subset of the problem of producing a layout that will work with
widely varying string lengths for labels etc.

Just a thought.


--
RGB
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-29-2008
On Mon, 28 Jul 2008 09:54:07 +0100, RedGrittyBrick
<(E-Mail Removed)> wrote, quoted or indirectly quoted
someone who said :

>How do you handle Internationalization? Maybe you can treat this problem
>as a subset of the problem of producing a layout that will work with
>widely varying string lengths for labels etc.


I have ignored the problem. I provide source. Somebody wanting a
version in another language could tweak the code for himself.

I have posted a fairly detailed design for detailed proposed
international tool, but it does not deal with size problems.

See http://mindprod.com/project/internationaliser.html

--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java claims WORA owais Java 27 06-26-2012 07:43 PM
Swing Font, it's Java Font? ot native? how install new font? mttc Java 2 07-03-2009 07:29 PM
Re: WORA high performance Tom Anderson Java 2 05-31-2008 11:41 PM
Mac WORA Roedy Green Java 15 05-18-2008 02:42 PM
Font class, external font files question Karl Hungus ASP .Net 1 02-04-2004 04:26 PM



Advertisments