Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-31 Thread Werner LEMBERG

Hello Alexei, hello Vivek!


 according to Hain's paper

   dmax = (s/L) * dnorm ;

 here `s' is not normalized.  `dmax' is the tolerance for flatness
 and `dnorm' is the normalized flatness of the curve.

 So

   s_limit = (dmax / dnorm) * L ;

 by putting `dnorm = 0.75' we get the permissible height of the
 control point for the curve not to be split.

 So should we not be comparing `s = abs(dy * dxi - dx * dyi)' with
 `s_limit * L' instead of `s' and `s_limit' (because `s' is
 perpendicular distance of control point multiplied by `L')?

 It is actually not just cross-product but

   s = abs(dx * dxi - dx * dyi)  / L

 otherwise the dimensionality is wrong.

 Some Hain's equations just need to be creatively modified to avoid
 divisions in the code.

After resolving this issue I would be glad if someone could provide a
patch which improves the comments in the source code.


Werner

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-31 Thread Vivek Rathod
On Mon, Oct 31, 2011 at 5:46 AM, Alexei Podtelezhnikov
apodt...@gmail.comwrote:

  On 30/10/2011 08:25, Vivek Rathod wrote:
  according to Hain's paper
  dmax = (s/L) * dnorm ;  here s  is not normalized. dmax is the tolerance
 for
  flatness and dnorm is the normalized flatness of the curve.
 
  so s_limit = (dmax / dnorm) * L ; by putting dnorm = 0.75 we get the
  permissible height of the control point for the curve not to be split.
 
  so should we  not be comparing s= abs(dy * dxi - dx * dyi) with s_limit *
  Linstead of s and s_limit  ( because s is perpendicular distance of
  control point multiplied by L) ?


 It is actually not just cross-product but

 s = abs(dx * dxi - dx * dyi)  / L

 otherwise the dimensionality is wrong.
 Some Hain's equations just need to be creatively modified to avoid
 divisions
 in the code.

Alexei, I understand the subtle modifications made to avoid division. But I
still feel s_limit needs to be multiplied another time by L before making
the comparison.

s is calculated as
*s = FT_ABS( dy * dx1 - dx * dy1 );*   which means *s* is the
perpendicular distance of the control point from chord multiplied by *L*

which means currently  *s_limit* is being compared with *perpendicular
distance of control point * L* .

but *s_limit* is actual distance, so in order to do the correct comparison
(and to avoid division) don't you think we need to multiply *s_limit* once
more by *L  *?
___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-31 Thread Alexei Podtelezhnikov
On Mon, Oct 31, 2011 at 3:22 AM, Vivek Rathod vivekmrat...@gmail.com wrote:
 s is calculated as
 s = FT_ABS( dy * dx1 - dx * dy1 );   which means s is the perpendicular
 distance of the control point from chord multiplied by L


 which means currently  s_limit is being compared with perpendicular distance
 of control point * L .

Correct. s_limit is also multiplied by L on line 1065 in ftgrays.c:

s_limit = L * (TPos)( ONE_PIXEL / 6 );

I do not see a problem here.

 but s_limit is actual distance, so in order to do the correct comparison
 (and to avoid division) don't you think we need to multiply s_limit once
 more by L  ?

This is wrong. Look at the actual code.

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-31 Thread Alexei Podtelezhnikov
On Mon, Oct 31, 2011 at 7:43 AM, Vivek Rathod vivekmrat...@gmail.com wrote:
 The formula for deviation ( from Hein's paper).
 d = dnorm * s ; here s is normalized --- (1)
 so the formula when s is not normalized becomes d = dnorm * (s / L)  ;
 -(2)
 and I think the L you are mentioning comes from this formula.
 therefore s = (dmax/dnorm) * L;

 Please correct me if I am wrong about this whole normalization assumption.

Stop confusing yourself and everybody else!
Do you know what ONE_PIXEL is? Learn that and read the damn code!
ONE_PIXEL is an absolute value and does not need any damn normalization.

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-31 Thread Alexei Podtelezhnikov
Hi All,

I finally understand where Vivek is coming from. There is a temptation
to tolerate deviations larger than ONE_PIXEL on long arches that may appear
with larger font sizes (say, 24 pixels or more). Sure, they'll look
smooth (not angular).
We are not about smoothness though. We need correct pixel-by-pixel shape.
Therefore, we *always* tolerate a constant fraction of ONE_PIXEL no matter
how long the arch is.

Alexei





On Mon, Oct 31, 2011 at 7:51 AM, Alexei Podtelezhnikov
apodt...@gmail.com wrote:
 On Mon, Oct 31, 2011 at 7:43 AM, Vivek Rathod vivekmrat...@gmail.com wrote:
 The formula for deviation ( from Hein's paper).
 d = dnorm * s ; here s is normalized --- (1)
 so the formula when s is not normalized becomes d = dnorm * (s / L)  ;
 -(2)
 and I think the L you are mentioning comes from this formula.
 therefore s = (dmax/dnorm) * L;

 Please correct me if I am wrong about this whole normalization assumption.

 Stop confusing yourself and everybody else!
 Do you know what ONE_PIXEL is? Learn that and read the damn code!
 ONE_PIXEL is an absolute value and does not need any damn normalization.




-- 
Alexei A. Podtelezhnikov, PhD

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-31 Thread Vivek Rathod
On Mon, Oct 31, 2011 at 4:45 PM, Alexei Podtelezhnikov
apodt...@gmail.com wrote:
 On Mon, Oct 31, 2011 at 3:22 AM, Vivek Rathod vivekmrat...@gmail.com wrote:
 s is calculated as
 s = FT_ABS( dy * dx1 - dx * dy1 );   which means s is the perpendicular
 distance of the control point from chord multiplied by L


 which means currently  s_limit is being compared with perpendicular distance
 of control point * L .

 Correct. s_limit is also multiplied by L on line 1065 in ftgrays.c:

 s_limit = L * (TPos)( ONE_PIXEL / 6 );

 I do not see a problem here.
The formula for deviation ( from Hein's paper).
d = dnorm * s ; here s is normalized --- (1)
so the formula when s is not normalized becomes d = dnorm * (s / L)  ;
-(2)
and I think the L you are mentioning comes from this formula.
therefore s = (dmax/dnorm) * L;

Please correct me if I am wrong about this whole normalization assumption.

 but s_limit is actual distance, so in order to do the correct comparison
 (and to avoid division) don't you think we need to multiply s_limit once
 more by L  ?

 This is wrong. Look at the actual code.


___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-31 Thread Vivek Rathod
Alexei,

I did not mean to talk about the tolerance on deviation.

I misunderstood this comment.
/* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */
Here, I think, the max deviation is in Hain's r s coordinate system(
section 3) and s is the actual control point distance limit.

In that case s_limit - calculated as s_limit = L * (TPos)( ONE_PIXEL
/ 6 ); - is correct for comparing with distance of the control
points.

Sorry for this confusion.
Thanks.


On Mon, Oct 31, 2011 at 5:57 PM, Alexei Podtelezhnikov
apodt...@gmail.com wrote:
 Hi All,

 I finally understand where Vivek is coming from. There is a temptation
 to tolerate deviations larger than ONE_PIXEL on long arches that may appear
 with larger font sizes (say, 24 pixels or more). Sure, they'll look
 smooth (not angular).
 We are not about smoothness though. We need correct pixel-by-pixel shape.
 Therefore, we *always* tolerate a constant fraction of ONE_PIXEL no matter
 how long the arch is.

 Alexei





 On Mon, Oct 31, 2011 at 7:51 AM, Alexei Podtelezhnikov
 apodt...@gmail.com wrote:
 On Mon, Oct 31, 2011 at 7:43 AM, Vivek Rathod vivekmrat...@gmail.com wrote:
 The formula for deviation ( from Hein's paper).
 d = dnorm * s ; here s is normalized --- (1)
 so the formula when s is not normalized becomes d = dnorm * (s / L)  ;
 -(2)
 and I think the L you are mentioning comes from this formula.
 therefore s = (dmax/dnorm) * L;

 Please correct me if I am wrong about this whole normalization assumption.

 Stop confusing yourself and everybody else!
 Do you know what ONE_PIXEL is? Learn that and read the damn code!
 ONE_PIXEL is an absolute value and does not need any damn normalization.




 --
 Alexei A. Podtelezhnikov, PhD


___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-30 Thread Graham Asher

Vivek,

in fact the great work is David's, not mine - I made the original 
attempt, which was buggy, and then supplied a fix, but David wrote a new 
version which was justified mathematically and based on Hain's paper, as 
you mention. So I'll have to pass the responsibility for explaining it 
to David Bevan.


Best regards,

Graham


On 30/10/2011 08:25, Vivek Rathod wrote:

Hello Graham,

I was looking at the new spline flattening algorithm that you and 
David worked on.

The speed up due to this is fantastic. Great work!

I could not understand the part of the code where you compare 
*s_limit* with *s


*according to Hain's paper
*dmax = (s/L) * dnorm ; *here s  is not normalized. dmax is the 
tolerance for flatness and dnorm is the normalized flatness of the curve.


so *s_limit* *= (dmax / dnorm) * L* ; by putting *dnorm* = 0.75 we get 
the permissible height of the control point for the curve not to be split.


so should we  not be comparing *s= abs(dy * dxi - dx * dyi)* with 
*s_limit * L *instead of *s* and *s_limit*  ( because s is 
perpendicular distance of control point multiplied by L) ?


Am I missing something very obvious?
*
*Thanks,
Vivek Rathod



___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] regarding freetype 2 cubic curve flattening

2011-10-30 Thread Alexei Podtelezhnikov
 On 30/10/2011 08:25, Vivek Rathod wrote:
 according to Hain's paper
 dmax = (s/L) * dnorm ;  here s  is not normalized. dmax is the tolerance for
 flatness and dnorm is the normalized flatness of the curve.

 so s_limit = (dmax / dnorm) * L ; by putting dnorm = 0.75 we get the
 permissible height of the control point for the curve not to be split.

 so should we  not be comparing s= abs(dy * dxi - dx * dyi) with s_limit *
 L    instead of s and s_limit  ( because s is perpendicular distance of
 control point multiplied by L) ?


It is actually not just cross-product but

s = abs(dx * dxi - dx * dyi)  / L

otherwise the dimensionality is wrong.
Some Hain's equations just need to be creatively modified to avoid divisions
in the code.

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel