Skip to content

Commit

Permalink
[graf3d] use the proper (unsigned) type in FTContour
Browse files Browse the repository at this point in the history
Freetype 2.13.3 changed the type of a data member from char* to
unsigned char*, so we need to pass the correct type to FTContour to
avoid compiler warnings
  • Loading branch information
silverweed committed Oct 18, 2024
1 parent 2f7462f commit 48c82e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 10 additions & 1 deletion graf3d/ftgl/inc/FTContour.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@
class FTGL_EXPORT FTContour
{
public:
#define FREETYPE_VER_HEX ((FREETYPE_MAJOR << 16) | (FREETYPE_MINOR << 8) | (FREETYPE_PATCH))
#if FREETYPE_VER_HEX >= 0x20d03
// enabled from 2.13.3
using PointTag_t = unsigned char;
#else
using PointTag_t = char;
#endif
#undef FREETYPE_VER_HEX

/**
* Constructor
*
* @param contour
* @param pointTags
* @param numberOfPoints
*/
FTContour( FT_Vector* contour, char* pointTags, unsigned int numberOfPoints);
FTContour( FT_Vector* contour, PointTag_t* pointTags, unsigned int numberOfPoints);

/**
* Destructor
Expand Down
10 changes: 5 additions & 5 deletions graf3d/ftgl/src/FTContour.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ void FTContour::evaluateCubicCurve()
}


FTContour::FTContour( FT_Vector* contour, char* pointTags, unsigned int numberOfPoints)
FTContour::FTContour( FT_Vector* contour, PointTag_t* pointTags, unsigned int numberOfPoints)
{
for( unsigned int pointIndex = 0; pointIndex < numberOfPoints; ++ pointIndex)
{
char pointTag = pointTags[pointIndex];
PointTag_t pointTag = pointTags[pointIndex];

if( pointTag == FT_Curve_Tag_On || numberOfPoints < 2)
{
Expand All @@ -93,9 +93,9 @@ FTContour::FTContour( FT_Vector* contour, char* pointTags, unsigned int numberOf

if( pointTag == FT_Curve_Tag_Conic)
{
char nextPointTag = ( pointIndex == numberOfPoints - 1)
? pointTags[0]
: pointTags[pointIndex + 1];
PointTag_t nextPointTag = ( pointIndex == numberOfPoints - 1)
? pointTags[0]
: pointTags[pointIndex + 1];

while( nextPointTag == FT_Curve_Tag_Conic)
{
Expand Down
2 changes: 1 addition & 1 deletion graf3d/ftgl/src/FTVectoriser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void FTVectoriser::ProcessContours()
for( short contourIndex = 0; contourIndex < ftContourCount; ++contourIndex)
{
FT_Vector* pointList = &outline.points[startIndex];
char* tagList = &outline.tags[startIndex];
auto* tagList = &outline.tags[startIndex];

endIndex = outline.contours[contourIndex];
contourLength = ( endIndex - startIndex) + 1;
Expand Down

0 comments on commit 48c82e2

Please sign in to comment.