make drawString render fonts identically to PhotoShop 7.0

Discussion in 'Java' started by opalpa@gmail.com opalinski from opalpaweb, Feb 27, 2006.

  1. Hello,

    I've noticed that there are differences, pixel for pixel, when
    rendering characters in the same Font with Java and with Photoshop.
    Most characters match pixel for pixel, but a significant percentage do
    not. The percentage varies with font choice. I've been googling to
    find information about how Java draws characters, but I am not coming
    across nuanced information. Also, I notice that PhotoShop renderings
    match the renderings of Windows applications that appear not to be
    written in Java.

    I have tried a variety of rendering hints in Java, so I do not think
    the answer lies in setting rendering hints. I suppose my question is:
    does Java do its own font rendering instead of calling out to system
    libraries? If Java does so, that is perfectly acceptable, I'd like a
    confirmation.

    Thanks for your time and attention.

    Opalinski

    http://www.geocities.com/opalpaweb/
    opalinski from opalpaweb, Feb 27, 2006
    #1
    1. Advertising

  2. > I've noticed that there are differences, pixel for pixel, when
    > rendering characters in the same Font with Java and with Photoshop.
    > Most characters match pixel for pixel, but a significant percentage do
    > not. The percentage varies with font choice. I've been googling to
    > find information about how Java draws characters, but I am not coming
    > across nuanced information. Also, I notice that PhotoShop renderings
    > match the renderings of Windows applications that appear not to be
    > written in Java.
    >
    > I have tried a variety of rendering hints in Java, so I do not think
    > the answer lies in setting rendering hints. I suppose my question is:
    > does Java do its own font rendering instead of calling out to system
    > libraries? If Java does so, that is perfectly acceptable, I'd like a
    > confirmation.


    Java is doing it's own rendering. I'm sure PhotoShop does the
    same. Rendering a TrueType font is quite complicated, and
    the Java renderer may not follow the TrueType specification
    to the letter in all cases. This has improved over time. In my
    experience, the Windows renderer follows the spec. exactly
    (I have a font that is very sensitive to control point placement).

    I once complained to Adobe about their TrueType font
    rendering in Acrobat, which even with "Font Smoothing"
    turned off, does not follow the TrueType specification
    exactly. Their answer (or perhaps the opinion of the guy
    who did not want to fix the problem), was that the hinting
    is just a suggestion. In my opinion, if the font specification,
    including hints, leaves no room for doubt about where a
    control point should go, then that's where it should go.
    Larry Barowski, Feb 28, 2006
    #2
    1. Advertising

  3. opalinski from opalpaweb wrote:
    >
    > Hello,
    >
    > I've noticed that there are differences, pixel for pixel, when
    > rendering characters in the same Font with Java and with Photoshop.
    > Most characters match pixel for pixel, but a significant percentage do
    > not. The percentage varies with font choice. I've been googling to
    > find information about how Java draws characters, but I am not coming
    > across nuanced information.


    Java uses Typesolution's T2K rasterizer (until recently it used a
    version which didn't use hints from the font data). On some platforms it
    can alternatively use the native rasterizer from the OS. When one uses
    AWT (the old AWT, not the one reimplemented on top of Swing), the native
    AWT components typically use the OS' font rasterizer.

    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
    Thomas Weidenfeller, Feb 28, 2006
    #3
  4. Thomas, how can one insert a character rasterized by OS' font
    rasterizer into a BufferedImage when using Java 5.0? Is this feat
    possible? Or is it that the old AWT is no longer available in current
    versions of Java?


    Opalinski

    http://www.geocities.com/opalpaweb/
    opalinski from opalpaweb, Feb 28, 2006
    #4
  5.  opalinski from opalpaweb

    Roedy Green Guest

    On Mon, 27 Feb 2006 20:21:26 -0600, "Larry Barowski"
    <MElarrybar-AT-eng_DOT_auburnANOTHERDOTeduEND> wrote, quoted or
    indirectly quoted someone who said :

    >
    >Java is doing it's own rendering


    It sometimes does anti-aliasing but it is terrible at small font sizes
    because it does not pay attention to hints. The solution is, stick to
    font sizes 11+

    see http://mindprod.com/jgloss/font.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Feb 28, 2006
    #5
  6.  opalinski from opalpaweb

    Roedy Green Guest

    On 28 Feb 2006 04:58:39 -0800, " opalinski from
    opalpaweb" <> wrote, quoted or indirectly quoted
    someone who said :

    >Thomas, how can one insert a character rasterized by OS' font
    >rasterizer into a BufferedImage when using Java 5.0? Is this feat
    >possible? Or is it that the old AWT is no longer available in current
    >versions of Java?


    You could use image files prepared off line.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Feb 28, 2006
    #6
  7.  opalinski from opalpaweb

    Roedy Green Guest

    On Tue, 28 Feb 2006 19:25:27 GMT, Roedy Green
    <> wrote, quoted or
    indirectly quoted someone who said :

    >You could use image files prepared off line.


    This is not as crazy as it sounds. You might want a line of fine
    print for legal matters that is still readable, or a line of
    instructions for something obvious that most people would never read.
    They could be field labels that most people never look at.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Feb 28, 2006
    #7
  8. opalinski from opalpaweb wrote:
    > Thomas, how can one insert a character rasterized by OS' font
    > rasterizer into a BufferedImage when using Java 5.0? Is this feat
    > possible? Or is it that the old AWT is no longer available in current
    > versions of Java?


    I don't know. I seem to remember that there once was a system property
    which one could set on the command line for the whole application, but I
    can't remember what it was, or where Sun has buried the description.

    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
    Thomas Weidenfeller, Mar 1, 2006
    #8
  9. Your comment got me searching for the system property which one could
    set on the command line. Do any of these ring a bell?

    java2d.font.usePlatformFont
    sun.awt.fontconfig
    sun.java2d.font.minstrikes
    sun.java2d.fontpath
    sun.java2d.noType1Font

    java.awt.fonts
    swing.useSystemFontSettings

    Do you recall any of these and appropriate associated value? I located
    some info via google on last two and believe I can exclude them from
    being the correct property.

    Thank you for continuing with this pursuit.

    Opalinski

    http://www.geocities.com/opalpaweb/
    opalinski from opalpaweb, Mar 1, 2006
    #9

  10. > You could use image files prepared off line.
    > This is not as crazy as it sounds.


    Crazy? No! Precisely what I did! For the short term, anyway. It
    seems there might be a way to defer font rendering to OS' renderer (per
    Thomas Weidenfeller's posts in this thread).

    Opalinski

    http://www.geocities.com/opalpaweb/
    opalinski from opalpaweb, Mar 1, 2006
    #10
    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. Jesse
    Replies:
    2
    Views:
    427
    Jesse
    May 27, 2004
  2. Stanimir Stamenkov
    Replies:
    9
    Views:
    998
    David Carlisle
    Jan 26, 2005
  3. Joris Gillis
    Replies:
    9
    Views:
    394
    Jan Roland Eriksson
    Jan 8, 2005
  4. Spoon
    Replies:
    2
    Views:
    306
    Rahul
    Dec 20, 2007
  5. Simon Strandgaard

    compare two identically hashes fails

    Simon Strandgaard, Oct 6, 2003, in forum: Ruby
    Replies:
    6
    Views:
    139
    Kent Dahl
    Oct 6, 2003
Loading...

Share This Page