Click here to Skip to main content
15,900,461 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Polygon filling, and TTF mess Pin
honey the codewitch5-Jul-21 4:53
mvahoney the codewitch5-Jul-21 4:53 
GeneralRe: Polygon filling, and TTF mess Pin
honey the codewitch5-Jul-21 4:58
mvahoney the codewitch5-Jul-21 4:58 
AnswerRe: Polygon filling, and TTF mess Pin
Randor 5-Jul-21 7:18
professional Randor 5-Jul-21 7:18 
GeneralRe: Polygon filling, and TTF mess Pin
honey the codewitch5-Jul-21 9:09
mvahoney the codewitch5-Jul-21 9:09 
GeneralRe: Polygon filling, and TTF mess Pin
Randor 5-Jul-21 11:28
professional Randor 5-Jul-21 11:28 
GeneralRe: Polygon filling, and TTF mess Pin
honey the codewitch5-Jul-21 12:19
mvahoney the codewitch5-Jul-21 12:19 
GeneralRe: Polygon filling, and TTF mess Pin
honey the codewitch5-Jul-21 12:29
mvahoney the codewitch5-Jul-21 12:29 
GeneralRe: Polygon filling, and TTF mess Pin
Randor 6-Jul-21 4:28
professional Randor 6-Jul-21 4:28 
Good morning,

Ok, I took a brief look at your code and believe that I have identified the problem. In your Main() function[^] you are naively loading alll of the polygon points and simply passing that to your 'point in polygon' function. That would only work for simple polygons.

Some comments:

1.) TrueType patents have expired but were previously held by Apple. So you should refer to the Apple reference documents[^].
2.) I see that the Apple reference docs state that the TTF file format is specificially designed for the non-zero winding algorithm[^] so maybe you should go back to using that. Although I don't think it would be a problem to continue working with PNPOLY, the PNPOLY algorithm simply requires a [0,0] between each contour/hole. I actually think it might be less work if you keep using PNPOLY.
3.) You need to read the Contours section of the TrueType reference manual[^], it specifically says that the letter 'B' contains three distinct closed shapes, each being a contour.
4.) It looks like you already have some code for using contours. In your OpenFont.Glyph.cs[^] code I can see that you are already using ContourEndpoints.

Contours[^]

I can see that your TTF parser seems to correctly identify the three contours. When I added a breakpoint I can see the letter 'B' has [84, 116, 136] as the contour endpoints in your letter 'B'.

See if this works:

Pseudocode:
1.) Looping through the list of points in the TTF file, add the next point to your polygon.
2.) If the index of the point is equal to the index of a 'contour end point' then break
3.) Close your polygon.
4.) If there are more points in the list goto step 1

Then I believe (if you wanted to continue using PNPOLY) that you can pass all those points to PNPOLY separated by a [0,0] vertex.

Good luck,
-David Delaune
GeneralRe: Polygon filling, and TTF mess Pin
honey the codewitch6-Jul-21 4:36
mvahoney the codewitch6-Jul-21 4:36 
GeneralRe: Polygon filling, and TTF mess Pin
Super Lloyd5-Jul-21 5:00
Super Lloyd5-Jul-21 5:00 
GeneralRe: Polygon filling, and TTF mess Pin
honey the codewitch5-Jul-21 12:53
mvahoney the codewitch5-Jul-21 12:53 
QuestionMessage Closed Pin
5-Jul-21 2:19
Marketing Media Hub5-Jul-21 2:19 
AnswerRe: Is there a way to add strings to a list without the quotation marks in C++? Pin
Maximilien5-Jul-21 2:26
Maximilien5-Jul-21 2:26 
GeneralRe: Is there a way to add strings to a list without the quotation marks in C++? Pin
OriginalGriff5-Jul-21 2:28
mveOriginalGriff5-Jul-21 2:28 
AnswerRe: Is there a way to add strings to a list without the quotation marks in C++? Pin
OriginalGriff5-Jul-21 2:27
mveOriginalGriff5-Jul-21 2:27 
AnswerRe: Is there a way to add strings to a list without the quotation marks in C++? Pin
harold aptroot5-Jul-21 2:34
harold aptroot5-Jul-21 2:34 
GeneralRe: Is there a way to add strings to a list without the quotation marks in C++? Pin
KarstenK5-Jul-21 4:14
mveKarstenK5-Jul-21 4:14 
QuestionMessage Closed Pin
5-Jul-21 2:24
Marketing Media Hub5-Jul-21 2:24 
AnswerRe: Dont work, it´s something whit the loops? Pin
Maximilien5-Jul-21 2:25
Maximilien5-Jul-21 2:25 
AnswerRe: Dont work, it´s something whit the loops? Pin
OriginalGriff5-Jul-21 2:26
mveOriginalGriff5-Jul-21 2:26 
AnswerRe: Dont work, it´s something whit the loops? Pin
honey the codewitch5-Jul-21 2:26
mvahoney the codewitch5-Jul-21 2:26 
AnswerRe: Dont work, it´s something whit the loops? Pin
Greg Utas5-Jul-21 2:37
professionalGreg Utas5-Jul-21 2:37 
AnswerRe: Dont work, it´s something whit the loops? Pin
Mike Hankey5-Jul-21 3:12
mveMike Hankey5-Jul-21 3:12 
GeneralThis is the end... Pin
CodeWraith5-Jul-21 0:00
CodeWraith5-Jul-21 0:00 
GeneralRe: This is the end... Pin
honey the codewitch5-Jul-21 2:25
mvahoney the codewitch5-Jul-21 2:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   488 votes