freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Freetype] Help with kerning troubles?


From: Steve Johnson
Subject: RE: [Freetype] Help with kerning troubles?
Date: Thu, 1 Nov 2001 21:05:27 -0800

It all comes down to this line:

    xx += chr.glyph->advance.x+chr.kern.x;

This line computes the next character's starting position.  The
chr.glyph->advance.x always seems to be right since no matter what point
size I draw strings at, the letters seem to be properly spaced.

The chr.kern.x value, however, seems to always be too small.  I multiply
this value by 4, I get something close to correct behavior at a variety
of point sizes.

For example, here's are the values I get when I draw the 'A' in the
string 'Av' at a point size of 100:

   chr.glyph->advance.x = 5288
   chr.kern.x = -128

But what I should be getting is something more like:

   chr.glyph->advance.x = 5288
   chr.kern.x = -512

The resulting value (xx) is passed into code that eventually divides by
64 to produce a pixel increment.  I don't think that the units of xx
really matter though, since chr.glyph->advance.x seems to be in the
correct units (since normal spacing works).  I just have to figure out
why chr.kern.x isn't in the same units as chr.glyph->advance.x.  That's
what's got me stumped.

BTW: To directly answer your question about the kerning offset...when I
trace through the code that produces the -128 value, I see that the
computation starts by extracting the -37 value from the font's kern
table.  It then does some math that combines the scaling modes and the
current point size to turn -37 into -128.  This all looks reasonable to
me.

S


-----Original Message-----
From: Leonard Rosenthol [mailto:address@hidden
Sent: Thursday, November 01, 2001 5:45 PM
To: Steve Johnson; address@hidden
Subject: RE: [Freetype] Help with kerning troubles?


At 4:22 PM -0800 11/1/01, Steve Johnson wrote:
>I've only tried this with Truetype so far.  I'm loading fonts from a
>file.  I've seen the problem on both our platforms...Win2K and Solaris.

        Good to know it's consistant!


>I'm  using using FreeType 2.0.3, but I just downloaded 2.0.5 and tried
>my code with that version and I get the same behavior.

        And also that the version doesn't matter. Thanks for trying
that!


>Specifically, I'm currently looking at the "Av" combination using
>Microsoft's standard Arial font.  I pulled down a font editor that let
>me see the kerning values.  The value for this pair is -37.

        Sounds about right.


>  I can see
>that this value is coming in properly and being used in what seem like
>reasonable calculations to come up with the final offset value.  All
>seems well except that the offset isn't visually correct.
>
        What is the offset that you are getting then?   You are 
saying that the value is read in correct from the file, but that when 
you query the kerning tables, you get the wrong values?


Leonard
-- 
------------------------------------------------------------------------
----
                   You've got a SmartFriend in Pennsylvania
------------------------------------------------------------------------
----
Leonard Rosenthol                       Internet:
address@hidden
Web Site: <http://www.lazerware.com/>
Coola Signature: <http://signature.coola.com/address@hidden>
PGP Fingerprint: C76E 0497 C459 182D 0C6B  AB6B CA10 B4DF 8067 5E65




reply via email to

[Prev in Thread] Current Thread [Next in Thread]