Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   make drawString render fonts identically to PhotoShop 7.0 (http://www.velocityreviews.com/forums/t150724-make-drawstring-render-fonts-identically-to-photoshop-7-0-a.html)

opalpa@gmail.com opalinski from opalpaweb 02-27-2006 09:48 PM

make drawString render fonts identically to PhotoShop 7.0
 


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
opalpa@gmail.com
http://www.geocities.com/opalpaweb/


Larry Barowski 02-28-2006 02:21 AM

Re: make drawString render fonts identically to PhotoShop 7.0
 
> 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.



Thomas Weidenfeller 02-28-2006 08:28 AM

Re: make drawString render fonts identically to PhotoShop 7.0
 
opalpa@gmail.com 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/...g/java/gui/faq
http://www.uni-giessen.de/faq/archiv....java.gui.faq/

opalpa@gmail.com opalinski from opalpaweb 02-28-2006 12:58 PM

Re: make drawString render fonts identically to PhotoShop 7.0
 
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
opalpa@gmail.com
http://www.geocities.com/opalpaweb/


Roedy Green 02-28-2006 07:23 PM

Re: make drawString render fonts identically to PhotoShop 7.0
 
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 02-28-2006 07:25 PM

Re: make drawString render fonts identically to PhotoShop 7.0
 
On 28 Feb 2006 04:58:39 -0800, "opalpa@gmail.com opalinski from
opalpaweb" <opalpa@gmail.com> 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 02-28-2006 08:02 PM

Re: make drawString render fonts identically to PhotoShop 7.0
 
On Tue, 28 Feb 2006 19:25:27 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid > 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.

Thomas Weidenfeller 03-01-2006 08:36 AM

Re: make drawString render fonts identically to PhotoShop 7.0
 
opalpa@gmail.com 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/...g/java/gui/faq
http://www.uni-giessen.de/faq/archiv....java.gui.faq/

opalpa@gmail.com opalinski from opalpaweb 03-01-2006 01:14 PM

Re: make drawString render fonts identically to PhotoShop 7.0
 
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
opalpa@gmail.com
http://www.geocities.com/opalpaweb/


opalpa@gmail.com opalinski from opalpaweb 03-01-2006 01:19 PM

Re: make drawString render fonts identically to PhotoShop 7.0
 

> 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
opalpa@gmail.com
http://www.geocities.com/opalpaweb/



All times are GMT. The time now is 01:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.