From ed99ad71a51ce1d054033a39e10e22b52210dad2 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 25 Apr 2024 17:37:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A9=BA=E6=A0=BC=E7=9A=84?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/CvText.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/CvText.cpp b/app/src/main/cpp/CvText.cpp index e54c320f..e8619d28 100644 --- a/app/src/main/cpp/CvText.cpp +++ b/app/src/main/cpp/CvText.cpp @@ -435,7 +435,7 @@ namespace cv { CV_Assert(!FT_Load_Glyph(mFace, FT_Get_Char_Index(mFace, wstr[i]), FT_LOAD_RENDER)); #endif - FT_GlyphSlot slot = mFace->glyph; + FT_GlyphSlot slot = mFace->glyph; FT_Glyph glyph = NULL; int error = FT_Get_Glyph(mFace->glyph, &glyph); @@ -605,7 +605,14 @@ namespace cv { // Update current position ( in FreeType coordinates ) // float advance = mFace->glyph->advance.x >> 6; - currentPos.x += mFace->glyph->advance.x; + if (wstr[i] == ' ') + { + currentPos.x += mFace->glyph->advance.x << 1; + } + else + { + currentPos.x += mFace->glyph->advance.x; + } currentPos.y += mFace->glyph->advance.y; } @@ -711,7 +718,7 @@ namespace cv { ) { bbox.xMin = currentPos.x; - bbox.xMax = currentPos.x + (mFace->glyph->advance.x + mFace->glyph->metrics.horiBearingX); + bbox.xMax = currentPos.x + ((mFace->glyph->advance.x << 1) + mFace->glyph->metrics.horiBearingX); bbox.yMin = yMin; bbox.yMax = yMax; }