修复文字size计算的bug

serial
Matthew 1 year ago
parent 15bcce850f
commit 9177325dbd

@ -712,11 +712,13 @@ namespace cv {
// If codepoint is space(0x20), it has no glyph. // If codepoint is space(0x20), it has no glyph.
// A dummy boundary box is needed when last code is space. // A dummy boundary box is needed when last code is space.
bool isSpace = false;
if ( if (
(bbox.xMin == 0) && (bbox.xMax == 0) && (bbox.xMin == 0) && (bbox.xMax == 0) &&
(bbox.yMin == 0) && (bbox.yMax == 0) (bbox.yMin == 0) && (bbox.yMax == 0)
) )
{ {
isSpace = true;
bbox.xMin = currentPos.x; bbox.xMin = currentPos.x;
bbox.xMax = currentPos.x + ((mFace->glyph->advance.x << 1) + mFace->glyph->metrics.horiBearingX); bbox.xMax = currentPos.x + ((mFace->glyph->advance.x << 1) + mFace->glyph->metrics.horiBearingX);
bbox.yMin = yMin; bbox.yMin = yMin;
@ -724,7 +726,7 @@ namespace cv {
} }
// Update current position ( in FreeType coordinates ) // Update current position ( in FreeType coordinates )
currentPos.x += mFace->glyph->advance.x; currentPos.x += isSpace ? (mFace->glyph->advance.x << 1) : mFace->glyph->advance.x;
currentPos.y += mFace->glyph->advance.y; currentPos.y += mFace->glyph->advance.y;
// Update BoundaryBox ( in OpenCV coordinates ) // Update BoundaryBox ( in OpenCV coordinates )

Loading…
Cancel
Save