Skip to main content

Font kerning/spacing issues ?

4 replies [Last post]
Anonymous

Hello all at Java2D,

please take a look at this picture:

www.classx.it/public/font2dtest.jpg

the first "LATIN" text is rendered with Java2d (1.5, 1.6, winxp)
the second is rendered with CorelDraw (but I get the same result with any other gfx program).

You can notice an abnormal spacing between the "A" and the "T" glyphs in the java version.
The CorelDraw version looks more correct, IMHO.

I've tested many other fonts but I always got the same results.

Where's the problem with java2d font rendering ?

Cheers,

Mik
============================================================================
> ClassX Development Italy Via Francesca, 368/I I-56030 S.M. a Monte (PI) <
> Tel.(+39)-0587-705153 Fax.(+39)-0587-705153 WEB: http://www.classx.it <
============================================================================

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Michele Puccini

Phil, David,

many thanks for your help.

Phil, you say thay the KERNING hint is not there by default because:

1) changes the overall text length
2) requires extra processing steps at rendering time.

Do you mean that I may also encounter performance or compatibility issues ?

Mik
============================================================================
> ClassX Development Italy Via Francesca, 368/I I-56030 S.M. a Monte (PI) <
> Tel.(+39)-0587-705153 Fax.(+39)-0587-705153 WEB: http://www.classx.it <
============================================================================

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Phil Race

Michele Puccini wrote:
> Phil, David,
>
> many thanks for your help.
>
> Phil, you say thay the KERNING hint is not there by default because:
>
> 1) changes the overall text length
I mean that you obviously can't expect text to be the
same length with this option on, and so you need to
make sure any code that is fussy about the length
measures the font in the presence of the attribute.

> 2) requires extra processing steps at rendering time.

Yes, I mean that text that is rendered with kerning will be much
slower to render. This is unlikely to be an issue in practice
unless you are doing massive and continual updates, but its
a fact that if you ask for more work to be done, it takes longer.

-phil.

>
> Do you mean that I may also encounter performance or compatibility issues ?
>
> Mik
> ============================================================================
> > ClassX Development Italy Via Francesca, 368/I I-56030 S.M. a Monte
> (PI) <
> > Tel.(+39)-0587-705153 Fax.(+39)-0587-705153 WEB:
> http://www.classx.it <
> ============================================================================
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body of the message "signoff JAVA2D-INTEREST". For general help, send
> email to listserv@java.sun.com and include in the body of the message
> "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Phil Race

> Where's the problem with java2d font rendering ?

Nothing's wrong.

CorelDraw is a word-processor and is applying kerning.

Not sure what you mean by "any other gfx program".

If you use windows notepad I see the same there in Font2DTest,
which is what I would expect since windows GDI provides
no way to request kerning.

The way to get kerning in jdk6 is to say you want it by
adding the appropriate attribute to the font :
http://java.sun.com/javase/6/docs/api/java/awt/font/TextAttribute.html#K...

Its not applied by default since it
1) changes the overall text length
2) requires extra processing steps at rendering time.

-phil.

Michele Puccini wrote:
> Hello all at Java2D,
>
> please take a look at this picture:
>
> www.classx.it/public/font2dtest.jpg
>
>
> the first "LATIN" text is rendered with Java2d (1.5, 1.6, winxp)
> the second is rendered with CorelDraw (but I get the same result with
> any other gfx program).
>
> You can notice an abnormal spacing between the "A" and the "T" glyphs in
> the java version.
> The CorelDraw version looks more correct, IMHO.
>
> I've tested many other fonts but I always got the same results.
>
> Where's the problem with java2d font rendering ?
>
> Cheers,
>
> Mik
> ============================================================================
> > ClassX Development Italy Via Francesca, 368/I I-56030 S.M. a Monte
> (PI) <
> > Tel.(+39)-0587-705153 Fax.(+39)-0587-705153 WEB:
> http://www.classx.it <
> ============================================================================
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body of the message "signoff JAVA2D-INTEREST". For general help, send
> email to listserv@java.sun.com and include in the body of the message
> "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

David Eisner

On 12/14/2007 12:50 PM, Phil Race wrote:
> > Where's the problem with java2d font rendering ?
> [...]
> The way to get kerning in jdk6 is to say you want it by
> adding the appropriate attribute to the font :
> http://java.sun.com/javase/6/docs/api/java/awt/font/TextAttribute.html#K...
>

Also see:

http://gceclub.sun.com.cn/java_one_online/2005/TS-3214/ts-3214.pdf

Slides 42-43, in particular.

-David

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".