|
|
|
@ -620,7 +620,7 @@ namespace cv {
|
|
|
|
|
// Update current position ( in FreeType coordinates )
|
|
|
|
|
|
|
|
|
|
float advance = mFace->glyph->advance.x >> 6;
|
|
|
|
|
currentPos.x += mFace->glyph->advance.x + mFace->glyph->bitmap_left;
|
|
|
|
|
currentPos.x += mFace->glyph->advance.x + mFace->glyph->metrics.horiBearingX;
|
|
|
|
|
currentPos.y += mFace->glyph->advance.y;
|
|
|
|
|
// currentPos.x += mFace->glyph->metrics.horiBearingX >> 6;
|
|
|
|
|
// currentPos.y += mFace->glyph->metrics.horiBearingY >> 6;
|
|
|
|
@ -628,7 +628,7 @@ namespace cv {
|
|
|
|
|
// currentPos.x += mFace->glyph->metrics.horiBearingX;
|
|
|
|
|
// currentPos.y += mFace->glyph->metrics.horiBearingY;
|
|
|
|
|
// break;
|
|
|
|
|
_org.x += (mFace->glyph->advance.x + mFace->glyph->bitmap_left) >> 6;
|
|
|
|
|
_org.x += (mFace->glyph->advance.x + mFace->glyph->metrics.horiBearingX) >> 6;
|
|
|
|
|
_org.y += mFace->glyph->advance.y >> 6;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -657,6 +657,13 @@ namespace cv {
|
|
|
|
|
|
|
|
|
|
CV_Assert(!FT_Set_Pixel_Sizes(mFace, _fontHeight, _fontHeight));
|
|
|
|
|
|
|
|
|
|
FT_UInt glyph_index;
|
|
|
|
|
FT_Bool use_kerning;
|
|
|
|
|
FT_UInt previous;
|
|
|
|
|
|
|
|
|
|
use_kerning = FT_HAS_KERNING(mFace);
|
|
|
|
|
previous = 0;
|
|
|
|
|
|
|
|
|
|
FT_Vector currentPos = { 0,0 };
|
|
|
|
|
FT_Set_Transform(mFace, 0, ¤tPos);
|
|
|
|
|
#if defined(USING_HB)
|
|
|
|
@ -681,7 +688,8 @@ namespace cv {
|
|
|
|
|
|
|
|
|
|
#if defined(USING_HB)
|
|
|
|
|
for (unsigned int i = 0; i < textLen; i++) {
|
|
|
|
|
CV_Assert(!FT_Load_Glyph(mFace, info[i].codepoint, 0));
|
|
|
|
|
glyph_index = info[i].codepoint;
|
|
|
|
|
CV_Assert(!FT_Load_Glyph(mFace, glyph_index, 0));
|
|
|
|
|
#else
|
|
|
|
|
for (unsigned int i = 0; i < wstr.size(); i++) {
|
|
|
|
|
if (wstr[i] == '\r' || wstr[i] == '\n')
|
|
|
|
@ -692,8 +700,17 @@ namespace cv {
|
|
|
|
|
// yMax = cv::max(yMax, currentPos.y + (mFace->glyph->advance.y));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
CV_Assert(!FT_Load_Glyph(mFace, FT_Get_Char_Index(mFace, wstr[i]), 0));
|
|
|
|
|
glyph_index = FT_Get_Char_Index(mFace, wstr[i]);
|
|
|
|
|
CV_Assert(!FT_Load_Glyph(mFace, glyph_index, 0));
|
|
|
|
|
#endif
|
|
|
|
|
/* retrieve kerning distance and move pen position */
|
|
|
|
|
if (use_kerning && previous)
|
|
|
|
|
{
|
|
|
|
|
FT_Vector delta;
|
|
|
|
|
FT_Get_Kerning(mFace, previous, glyph_index, FT_KERNING_DEFAULT, &delta);
|
|
|
|
|
currentPos.x += delta.x >> 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FT_GlyphSlot slot = mFace->glyph;
|
|
|
|
|
FT_Outline outline = slot->outline;
|
|
|
|
|
FT_BBox bbox;
|
|
|
|
@ -716,7 +733,7 @@ namespace cv {
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
bbox.xMin = currentPos.x;
|
|
|
|
|
bbox.xMax = currentPos.x + (mFace->glyph->advance.x);
|
|
|
|
|
bbox.xMax = currentPos.x + (mFace->glyph->advance.x + mFace->glyph->bitmap_left);
|
|
|
|
|
bbox.yMin = yMin;
|
|
|
|
|
bbox.yMax = yMax;
|
|
|
|
|
}
|
|
|
|
@ -730,6 +747,8 @@ namespace cv {
|
|
|
|
|
xMax = cv::max(xMax, ftd(bbox.xMax));
|
|
|
|
|
yMin = cv::min(yMin, ftd(bbox.yMin));
|
|
|
|
|
yMax = cv::max(yMax, ftd(bbox.yMax));
|
|
|
|
|
|
|
|
|
|
previous = glyph_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(USING_HB)
|
|
|
|
@ -756,6 +775,7 @@ namespace cv {
|
|
|
|
|
return Size(width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FreeType2Impl::putPixel_8UC1_mono(Mat& _dst, const int _py, const int _px, const uint8_t *_col)
|
|
|
|
|
{
|
|
|
|
|
uint8_t* ptr = _dst.ptr<uint8_t>(_py, _px);
|
|
|
|
@ -1038,6 +1058,7 @@ namespace cv {
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int FreeType2Impl::mvFn(const FT_Vector *to, void * user)
|
|
|
|
|
{
|
|
|
|
|
if (user == NULL) { return 1; }
|
|
|
|
|