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: Wed, 19 Feb 2003 00:12:20 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030210

Hello Gustavo,

Gustavo J. A. M. Carneiro wrote:
  I'd just like to add this information to this thead that I found in
the archives when I wasn't subscribed.
  Regarding the subject of decomposing a transformation matrix into
(scale x rest), libart_lgpl has this function that is probably what you
want:


/**
 * art_affine_expansion: Find the affine's expansion factor.
 * @src: The affine transformation.
 *
 * Finds the expansion factor, i.e. the square root of the factor
 * by which the affine transform affects area. In an affine transform
 * composed of scaling, rotation, shearing, and translation, returns
 * the amount of scaling.
 *
 * Return value: the expansion factor.
 **/
double
art_affine_expansion (const double src[6])
{
  return sqrt (fabs (src[0] * src[3] - src[1] * src[2]));
}


I'll try to summarize all that has been said in this thread.

As Artur already said, defining an "amount" of scaling, rotation, shearing
from a linear transform is ambiguous and can be performed in different ways.

the formula used by libart really computes the *area* of the square
delimited by coordinates (0,0)-(1,1) in 2D space after the transform has
been applied to it. We could call it an "area scale".

Graham proposes a different method which basically decomposes the transform
into successive scaling, rotation and horizontal shearing, where each axis
is scaled from a different amount.

Finally, Alexander Gefelbain did propose an alternative decomposition, that
looks like Graham's algorithm, except that the scaling coefficients are
computed differently (basically introducing horizontal _and_ vertical
shearing in the "third" transform).

My point will be that there is no "perfect" algorithm to choose among these
three, since all of them will produce absolutely *identical* results when the
transformation only consists of rotation and homogenous scaling (i.e. the
same scale being applied to both X and Y axis), and this is by far the most
common case.

However, their output will slightly differ when some "shearing" is part of the
transform, for example, when trying to display rotated text on a display surface
with non-square pixels, and that's because they compute different scaling
coefficients, which are the only things to influence the hinting process
here.

Though my opinion is not backed by strong experimentation, I would favor 
Graham's
algorithm, simply because it minimizes the shearing to only one axis; however,
the probability that these differences are visible to un-trained users is
probably pretty weak anyway.

Hope this helps,

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




reply via email to

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