I want to use this function to get contours and within these contours, I want to get cubic bezier. I think I have to call it with GGO_BEZIER. What puzzles me is how the return buffer works.
“A glyph outline is returned as a
series of one or more contours defined
by a TTPOLYGONHEADER structure
followed by one or more curves. Each
curve in the contour is defined by a
TTPOLYCURVE structure followed by a
number of POINTFX data points. POINTFX
points are absolute positions, not
relative moves. The starting point of
a contour is given by the pfxStart
member of the TTPOLYGONHEADER
structure. The starting point of each
curve is the last point of the
previous curve or the starting point
of the contour. The count of data
points in a curve is stored in the
cpfx member of TTPOLYCURVE structure.
The size of each contour in the
buffer, in bytes, is stored in the cb
member of TTPOLYGONHEADER structure.
Additional curve definitions are
packed into the buffer following
preceding curves and additional
contours are packed into the buffer
following preceding contours. The
buffer contains as many contours as
fit within the buffer returned by
GetGlyphOutline.”
I’m really not sure how to access the contours. I know that I can change a pointer another type of pointer but i’m not sure how I go about getting the contours based on this documentation.
Thanks
I have never used this API myself, but after reading the MSDN documentation I would think it works like this:
First you have to call
GetGlyphOutlinewith thelpvBufferparameter set toNULL. Then the function will return the required size of the buffer. You’ll then have to allocate a buffer with that size, then call the function again withlpvBufferset to your newly created buffer.If you take a look at the documentation for
TTPOLYGONHEADERit says:So, basically you have to do something like this:
Then, check the
pPolyCurve->cpfxmember which contains the number ofPOINTFXstructures.Then you can iterate all the points by doing something like this:
Since the
TTPOLYGONHEADERdoesn’t tell you how manyTTPOLYCURVEstructures are in the buffer, I guess you’ll have to keep track of that yourself by subtracting the size of the individual structures from the size of your buffer and keep going until you reach 0.Please excuse any potential errors as I didn’t test this myself 🙂