Determining font letter center

  • Follow


How can I find out how high a letter is when using a particular font?
I am trying to place the center of capital letters at a specific
location.

The javadoc for FontMetrics says that getAscent() returns the distance
from the font's baseline to the top of most alphanumeric characters,
but that doesn't seem to be true.

For example, Font( "Serif", 1, 32 ) (serif font, bold, 32-points, its
FontMetric getAscent returns 33, but the height of every capital
letter is 21 pixels.

I have also tried to use the strikethroughOffset, but that is not in
the center of capital letters either.

--
Fred K
0
Reply fred.l.kleinschmidt1 (74) 1/13/2012 6:32:09 PM

On 01/13/2012 01:32 PM, Fred wrote:
> How can I find out how high a letter is when using a particular font?
> I am trying to place the center of capital letters at a specific
> location.
>
> The javadoc for FontMetrics says that getAscent() returns the distance
> from the font's baseline to the top of most alphanumeric characters,
> but that doesn't seem to be true.
>
> For example, Font( "Serif", 1, 32 ) (serif font, bold, 32-points, its
> FontMetric getAscent returns 33, but the height of every capital
> letter is 21 pixels.
>
> I have also tried to use the strikethroughOffset, but that is not in
> the center of capital letters either.
>
This may help.
<http://explodingpixels.wordpress.com/2009/01/29/drawing-text-about-its-visual-center/>
0
Reply jeff8956 (433) 1/13/2012 6:49:09 PM


On Jan 13, 10:49=A0am, Jeff Higgins <j...@invalid.invalid> wrote:
> On 01/13/2012 01:32 PM, Fred wrote:> How can I find out how high a letter=
 is when using a particular font?
> > I am trying to place the center of capital letters at a specific
> > location.
>
> > The javadoc for FontMetrics says that getAscent() returns the distance
> > from the font's baseline to the top of most alphanumeric characters,
> > but that doesn't seem to be true.
>
> > For example, Font( "Serif", 1, 32 ) (serif font, bold, 32-points, its
> > FontMetric getAscent returns 33, but the height of every capital
> > letter is 21 pixels.
>
> > I have also tried to use the strikethroughOffset, but that is not in
> > the center of capital letters either.
>
> This may help.
> <http://explodingpixels.wordpress.com/2009/01/29/drawing-text-about-it...=
>

Hey, that works for me, too! Thanks!
--
Fred K
0
Reply fred.l.kleinschmidt1 (74) 1/13/2012 7:58:23 PM

On Fri, 13 Jan 2012 10:32:09 -0800 (PST), Fred
<fred.l.kleinschmidt@gmail.com> wrote, quoted or indirectly quoted
someone who said :

>How can I find out how high a letter is when using a particular font?
>I am trying to place the center of capital letters at a specific
>location.

You can't get precise values, without analysing pixels, but you can
get approximations. See http://mindprod.com/jgloss/fontmetrics.html
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
One of the most useful comments you can put in a program is 
"If you change this, remember to change ?XXX? too".
 
0
Reply see_website (4858) 1/14/2012 9:28:47 AM

3 Replies
41 Views

(page loaded in 0.083 seconds)


Reply: