Font WORA blues.

Discussion in 'Java' started by Roedy Green, Jul 27, 2008.

  1. Roedy Green

    Roedy Green Guest

    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
     
    Roedy Green, Jul 27, 2008
    #1
    1. Advertising

  2. Roedy Green

    Tom Anderson Guest

    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
     
    Tom Anderson, Jul 27, 2008
    #2
    1. Advertising

  3. Roedy Green

    Roedy Green Guest

    On Sun, 27 Jul 2008 12:18:30 +0100, RedGrittyBrick
    <> 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
     
    Roedy Green, Jul 27, 2008
    #3
  4. Roedy Green

    Roedy Green Guest

    On Sun, 27 Jul 2008 14:13:12 +0100, Tom Anderson
    <> 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
     
    Roedy Green, Jul 27, 2008
    #4
  5. Roedy Green wrote:
    > On Sun, 27 Jul 2008 12:18:30 +0100, RedGrittyBrick
    > <> 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
     
    RedGrittyBrick, Jul 28, 2008
    #5
  6. Roedy Green

    Roedy Green Guest

    On Mon, 28 Jul 2008 09:54:07 +0100, RedGrittyBrick
    <> 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
     
    Roedy Green, Jul 29, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karl Hungus

    Font class, external font files question

    Karl Hungus, Feb 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    565
    Karl Hungus
    Feb 4, 2004
  2. Roedy Green

    Mac WORA

    Roedy Green, May 4, 2008, in forum: Java
    Replies:
    15
    Views:
    846
    John B. Matthews
    May 18, 2008
  3. Tom Anderson

    Re: WORA high performance

    Tom Anderson, May 30, 2008, in forum: Java
    Replies:
    2
    Views:
    345
    Tom Anderson
    Jun 1, 2008
  4. mttc
    Replies:
    2
    Views:
    2,459
    Roedy Green
    Jul 3, 2009
  5. owais

    Java claims WORA

    owais, Jun 20, 2012, in forum: Java
    Replies:
    27
    Views:
    781
    John B. Matthews
    Jun 26, 2012
Loading...

Share This Page