I replied to this in the javadesktop forum on Friday but for
some reason it never showed up here in the email list :
So here it is again.

> 1) how to determine the max pixel with of the characters in a font ?
> Font.getMaxCharBounds() does not return correct values (expecially
> with some
> italic fonts). A silly workaround is to find the max size of the chars
> glyph
> outlines bounds..

IIRC we pull information from the font itself. If that
information is inaccurate that's a problem in the font.
But there's a couple of places you can get this in the
case of a TrueType font - the 'hhea' table
http://www.microsoft.com/typography/otspec/hhea.htm
is what I think our rasteriser accesses. I'm not where I can see our sources 
right now.
But the mention of italic fonts suggests that the
values for min left side bearing may not be included.
ie we are returning the maximunm logical bounds which
maybe isn't what you'd expect from this API

We'd have to think carefully before changing this
implementation as it may cause apps to layout differently
and also I still don't think it can be guaranteed to
enclose *all* the pixels.

If you want a definite answer then you'll need to go
through the expensive process of calling
GlyphVector.getPixelBounds() for each char in the font.

>
> 2) why Graphics2D.drawString() gives so different visual results from
> drawing a glyphVector as a Shape ?

The former does scan conversion into a bitmap in the
rasteriser. That scan conversion process in the font
understands hints for dropout control etc which are
specific to the technology. The shape path gets the
outline and is now completely out of the rasteriser
into the 2D geometric code. That is known to have
some deficiencies for small paths but you cannot
ever expect it to produce identical results as the
font rasteriser.

-phil.

Michele Puccini wrote:
Thanks all for the hints.

while stringWidth() is not for me (I want to get te maximum w,h of the
glyphs in a font), g2d.getFontMetrics().xxx() sounds promising. I'll do
further checks and let you know.

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: "Bill Dodson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 21, 2005 8:48 PM
Subject: Re: [JAVA2D] java2d Glyph questions


I am not the person to give a definitive answer, but have you tried the
FontMetrics class?  I get the total width and height of a string with
the following code:

   int sw = g2d.getFontMetrics().stringWidth(text);
   int sh = g2d.getFontMetrics().getHeight();

I notice there is also a getMaxCharBounds in this class. It uses a
Graphics context instead of FontRenderContext.

Hope this helps.
bill


===========================================================================
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".

Reply via email to