Re: [JAVA2D] AttributedString and Outline (the return of the glyph invaders!)

2006-11-16 Thread Phil Race

First, its not a bug in TextLayout drawString behaves identically.
You can prove this as follows, instead of your AttributedString use

Font fo = new Font("Serif", Font.PLAIN, 12);
fo = fo.deriveFont(AffineTransform.getScaleInstance(2 +
scale, 3));
g.setColor(Color.white);
g.setFont(fo);
g2d.drawString(text, x, y);

Second, text does not scale linearly because of the same hinting
and gridfitting effects I described earlier, and the glyphs are
fitted to the pixel grid and you are specifying fractional point sizes.

FRACTIONAL_METRICS is being specified but that affects only the
accumulation of the advance. It doesn't change the images.
You'd probably see a similar effect with the outline if you
disabled FRACTIONAL_METRICS.


-phil.



Michele Puccini wrote:

Thanks Phil,

I did a little mistake: is not a problem of the outline, which is indeed
correct.
Well, a piece of code is worth a thousand words.

The attached sample shows the "animated" difference between
TextLayout.draw() and g2d.draw(TextLayout.getOutline). Please give it a
try and see what happens. Is is quite funny to see the glyphs in the
first line jumping one pixel to the other just like the space invaders
in that old arcade game ;)

As you will see from the animation, the glyphs rendered with
TextLayout.draw() jump from one pixel to the other (at int coords ?),
while the glyph outlines are rendered with the expected quality.
Funny enough, the red cursor on the "C" letter is rendered "at float
coords".

So, in my opinion, TextLayout.draw() does not give the expected quality
resuls and this is a pity as it really is very useful.

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  <





- Original Message - From: "Phil Race" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 16, 2006 1:08 AM
Subject: Re: [JAVA2D] AttributedString and Outline



The bitmap glyph images are hinted and gridfitted.
This is not done for the returned outline as it
doesn't make sense to do that for a pure shape.

For most of what you are doing you need outlines
anyway as the rasteriser can only return glyph
images.

-phil.


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] AttributedString and Outline (the return of the glyph invaders!)

2006-11-16 Thread Michele Puccini

Thanks Jan,

the trick is what I call "old school". It takes me back to the good old
Amiga days..
Of course it is only applicable to a very limited number of cases. An
outline of 9 pixels will request much more than five times..

What I want to focus here is that maybe we're facing a bug in the TextLayout
implementation.
Give a try to my src code and get a picture of what I mean.

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  <



- Original Message -
From: ""Jan Bösenberg (INCORS GmbH)"" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 16, 2006 10:53 AM
Subject: Re: [JAVA2D] AttributedString and Outline (the return of the glyph
invaders!)



Michele,

I have not tested your showcase but I think I know what you mean.
Probably the only way to achieve what you want is to implement your own
outline rendering by draw the string five times. Four times using the
foreground color with x, y offsets (1, -1), (1, 1), (-1, 1), (-1, -1),
and finally once without offset using the background color (or white if
there is no background color). This will not look perfect and the glyphs
will not really be hollow as you would expect from and outlined glyph,
but maybe while TextLayout has no support for an Outline attribute this
will do the job.


Cheers

Jan


Michele Puccini schrieb:

Thanks Phil,

I did a little mistake: is not a problem of the outline, which is indeed
correct.
Well, a piece of code is worth a thousand words.

The attached sample shows the "animated" difference between
TextLayout.draw() and g2d.draw(TextLayout.getOutline). Please give it
a try
and see what happens. Is is quite funny to see the glyphs in the first
line
jumping one pixel to the other just like the space invaders in that old
arcade game ;)

As you will see from the animation, the glyphs rendered with
TextLayout.draw() jump from one pixel to the other (at int coords ?),
while
the glyph outlines are rendered with the expected quality.
Funny enough, the red cursor on the "C" letter is rendered "at float
coords".

So, in my opinion, TextLayout.draw() does not give the expected quality
resuls and this is a pity as it really is very useful.

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  <





- Original Message -
From: "Phil Race" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 16, 2006 1:08 AM
Subject: Re: [JAVA2D] AttributedString and Outline



The bitmap glyph images are hinted and gridfitted.
This is not done for the returned outline as it
doesn't make sense to do that for a pure shape.

For most of what you are doing you need outlines
anyway as the rasteriser can only return glyph
images.

-phil.


===

To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff JAVA2D-INTEREST".  For general help, send
email to
[EMAIL PROTECTED] and include in the body of the message "help".


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] AttributedString and Outline (the return of the glyph invaders!)

2006-11-16 Thread Jan Bösenberg (INCORS GmbH)

Michele,

I have not tested your showcase but I think I know what you mean.
Probably the only way to achieve what you want is to implement your own
outline rendering by draw the string five times. Four times using the
foreground color with x, y offsets (1, -1), (1, 1), (-1, 1), (-1, -1),
and finally once without offset using the background color (or white if
there is no background color). This will not look perfect and the glyphs
will not really be hollow as you would expect from and outlined glyph,
but maybe while TextLayout has no support for an Outline attribute this
will do the job.


Cheers

Jan


Michele Puccini schrieb:

Thanks Phil,

I did a little mistake: is not a problem of the outline, which is indeed
correct.
Well, a piece of code is worth a thousand words.

The attached sample shows the "animated" difference between
TextLayout.draw() and g2d.draw(TextLayout.getOutline). Please give it
a try
and see what happens. Is is quite funny to see the glyphs in the first
line
jumping one pixel to the other just like the space invaders in that old
arcade game ;)

As you will see from the animation, the glyphs rendered with
TextLayout.draw() jump from one pixel to the other (at int coords ?),
while
the glyph outlines are rendered with the expected quality.
Funny enough, the red cursor on the "C" letter is rendered "at float
coords".

So, in my opinion, TextLayout.draw() does not give the expected quality
resuls and this is a pity as it really is very useful.

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  <





- Original Message -
From: "Phil Race" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 16, 2006 1:08 AM
Subject: Re: [JAVA2D] AttributedString and Outline



The bitmap glyph images are hinted and gridfitted.
This is not done for the returned outline as it
doesn't make sense to do that for a pure shape.

For most of what you are doing you need outlines
anyway as the rasteriser can only return glyph
images.

-phil.


===

To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff JAVA2D-INTEREST".  For general help, send
email to
[EMAIL PROTECTED] and include in the body of the message "help".


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] AttributedString and Outline (the return of the glyph invaders!)

2006-11-16 Thread Michele Puccini

Thanks Phil,

I did a little mistake: is not a problem of the outline, which is indeed
correct.
Well, a piece of code is worth a thousand words.

The attached sample shows the "animated" difference between
TextLayout.draw() and g2d.draw(TextLayout.getOutline). Please give it a try
and see what happens. Is is quite funny to see the glyphs in the first line
jumping one pixel to the other just like the space invaders in that old
arcade game ;)

As you will see from the animation, the glyphs rendered with
TextLayout.draw() jump from one pixel to the other (at int coords ?), while
the glyph outlines are rendered with the expected quality.
Funny enough, the red cursor on the "C" letter is rendered "at float
coords".

So, in my opinion, TextLayout.draw() does not give the expected quality
resuls and this is a pity as it really is very useful.

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  <




- Original Message -
From: "Phil Race" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 16, 2006 1:08 AM
Subject: Re: [JAVA2D] AttributedString and Outline



The bitmap glyph images are hinted and gridfitted.
This is not done for the returned outline as it
doesn't make sense to do that for a pure shape.

For most of what you are doing you need outlines
anyway as the rasteriser can only return glyph
images.

-phil.


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


AttributedStringTest.java
Description: Binary data