make drawString render fonts identically to PhotoShop 7.0

O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
L

Larry Barowski

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.
 
T

Thomas Weidenfeller

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
 
O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
T

Thomas Weidenfeller

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
 
O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
O

opalpa

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
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top