Re: [Freetype-devel] Re: GSOC - Distance Fields

2020-08-07 Thread Alexei Podtelezhnikov
On Fri, Aug 7, 2020 at 10:58 AM Anuj Verma  wrote:
>
> > Yeah. We should basically think of overlaying or combining two
> > distance fields, generated independently one for each contour.
> > Has this been discussed in the literature?
>
> No, it has not been. That sounds interesting, thanks for the idea.
> I will think about it tomorrow, perhaps it might solve the issue. My
> only concern would be the additional memory usage, because some
> glyphs have many contours. But yeah we can turn it ON only for
> overlapping contours.

I meant it all along but perhaps it is hard to do it on the fly. Ther
rules seem to be as follows:

1) Both outside (both positive), choose a smaller value
2) Both inside (both negative), choose a smaller value as in (-5 < -4)
not by absolute value
3) one inside one outside, choose a smaller value as in (-3 < 2) not
by absolute value

I.e. always choose a smaller value combining two contours so it seems



Re: [Freetype-devel] Re: GSOC - Distance Fields

2020-08-07 Thread Anuj Verma
 > Yeah. We should basically think of overlaying or combining two
> distance fields, generated independently one for each contour.
> Has this been discussed in the literature?

No, it has not been. That sounds interesting, thanks for the idea.
I will think about it tomorrow, perhaps it might solve the issue. My
only concern would be the additional memory usage, because some
glyphs have many contours. But yeah we can turn it ON only for
overlapping contours.

Thanks for the idea,
Anuj


Re: [Freetype-devel] Re: GSOC - Distance Fields

2020-08-07 Thread Alexei Podtelezhnikov
On Fri, Aug 7, 2020 at 12:54 AM Anuj Verma  wrote:
>
> Hello Alexei,
>
> > Can you describe discontinuities with the same sign if I overlook them?
>
> So, I found there are two types of discontinuities due to overlapping 
> contours:
>
> A) Discontinuity in sign. (i.e. there is a sudden jump from negative to 
> positive)
> B) Discontinuity in distances. (i.e. the points that should be at 
> infinity/spread have smaller distances)

Yeah. We should basically think of overlaying or combining two
distance fields, generated independently one for each contour.
Has this been discussed in the literature?

> Also, I looked at a library (msdfgen) which handles overlapping contours 
> without
> removing the overlaps. It works well, but it doesn't work for 
> self-intersecting contours,
> that is why I'm not sure whether it's worth implementing.

Self intersecting contours should never and hopefully will never be
allowed in fonts.

> Finally, I can find and fix signs such that all points inside a shape are 
> positive and
> all points outside are negative. But I don't know how I can fix the incorrect 
> distances
> caused by the overlaps. Here is one final example: 
> https://i.imgur.com/jiaqiBS.png
> In this the point `P' has a positive sign and it points to a line inside the 
> shape, which
> is not correct, instead it should point to the corner. Moreover there is no 
> corner in the
> shape because they are two separate contours, so I think removing the 
> overlaps is
> the best way to handle this.

Here I concede we will never find proper distance unless we define the
intersection point.

Alexei