freetype-devel
[Top][All Lists]
Advanced

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

Re: [Devel] pixel size, hinting and scaling


From: David Turner
Subject: Re: [Devel] pixel size, hinting and scaling
Date: Thu, 16 Jan 2003 13:26:24 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2a) Gecko/20020910

Hi Graham,

Graham Asher wrote:
Can someone explain how, and if, the problem of pixel size and scaling is
solved, when a font transformation has some scaling component? I noticed
that when TrueType glyphs are rendered certain important parameters
affecting hinting depend on the number of pixels per em - that is, the pixel
size. These parameters are set when FT_Set_Char_Size is called but not when
FT_Set_Transform is called. FT_Set_Transform can also affect the pixel size.
Thus a transform applied to a font can prevent hinting from working as
intended.

There are other, more difficult issues when pixels are not square or when
the transformation causes some skewing or rotation.

I hope I have simply misunderstood some part of FreeType. If not, there is a
defect here.


Here are some clarifications: up to three distinct transforms can be used
when loading a glyph within FreeType 2:

  * the "scaling transform", used to scale glyph coordinates from
    "font" to "device" units. It is entirely determined by the character
    sizes set through FT_Set_Pixel_Sizes or FT_Set_Char_Size. The so-called
    "device" space is where all hinting computations are performed.

  * the internal "glyph transform", that can be applied by glyph loaders
    for certain formats (e.g. artificially obliqued Type 1 fonts through
    a shearing transform). It is located in "glyph->internal.transform"
    as far as I remember.

    this transform is a bit specific because:

      # it is applied _after_ the scaled outlines have been hinted

      # except that its inverse translation is applied to the outline
        _before_ hinting.

    the last point ensures that grid fitting is preserved for the final
    hinted+transformed outline, whenever this makes sense.



  * the additional "user-level transform", set with FT_Set_Transform, which
    is always applied _after_ scaling and hinting. It has _zero_ interaction
    with the other transforms..


So, if all you have is a "master" to "device" transform of your own, you'll
need to perform the following steps to use FreeType with it:

  - decompose your transform into a two distinct ones: a scaling one, and
    a shearing / rotating one. Equivalent to finding the matrix's eigenvalues

  - use your scaling transform to call FT_Set_Pixel_Sizes() or 
FT_Set_Char_Size()

  - use your shearing/rotation one to call FT_Set_Transform()

  - load the glyph



Hope this helps,

- David Turner
- The FreeType Project  (www.freetype.org)





reply via email to

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