Hi Anuj,

> I have written the program, you can find it at: 
> https://github.com/preversewharf45/freetype2-sdf
> To view the output I'm currently using a small OpenGL framework: 
> https://github.com/preversewharf45/freetype2-sdf-demo
> this already has the sdf code.

I like the style. Looks good.

> However there is an issue with the program, the glyphs which contain 
> intersecting contours have an issue.
> (example: https://imgur.com/MxJfAwY)

The intersecting contours used to be discouraged and still quite rare.
In general, you should assume that fonts have reasonable shapes
without intersections or wrong contour orientations. It is more
important that your code deals with thin stems and cursive fonts with
tiny details like serifs.

> Currently the sign of the distance is determined by the orientation of the 
> closest edge, so at places where
> one contour intersects another the pixel near that contour can be specified 
> as outside even though it is
> inside the shape.
> To fix this issue I'm thinking of using the winding of the contours, so is 
> there any function in freetype
> to get the winding or something similar?

We only have 
https://www.freetype.org/freetype2/docs/reference/ft2-outline_processing.html#ft_outline_get_orientation
You can cut the outline into individual contours manually. Keep in
mind that the orientation is different for TrueType and Type1/CFF
fonts.

> Also, should I start integrating this in freetype or first fix the issue?

Have you figured out FT_Fixed arithmetic? You still use floats in your
code. I think you should convert to FT_Fixed first.

Best,
Alexei

Reply via email to