Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions modules/freetype/src/freetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,23 @@ void FreeType2Impl::putTextOutline(
hb_buffer_t *hb_buffer = hb_buffer_create ();
CV_Assert( hb_buffer != NULL );

unsigned int textLen;
hb_buffer_guess_segment_properties (hb_buffer);
hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
FT_Vector currentPos = {0,0};
hb_buffer_guess_segment_properties (hb_buffer);
hb_shape (mHb_font, hb_buffer, NULL, 0);

unsigned int textLen = 0;
hb_glyph_info_t *info =
hb_buffer_get_glyph_infos(hb_buffer,&textLen );
CV_Assert( info != NULL );

hb_shape (mHb_font, hb_buffer, NULL, 0);

PathUserData *userData = new PathUserData( _img );
userData->mColor = _color;
userData->mCtoL = mCtoL;
userData->mThickness = _thickness;
userData->mLine_type = _line_type;

// Initilize currentPosition ( in FreeType coordinates)
FT_Vector currentPos = {0,0};
currentPos.x = _org.x * 64;
currentPos.y = _org.y * 64;

Expand Down Expand Up @@ -305,15 +304,15 @@ void FreeType2Impl::putTextBitmapMono(
hb_buffer_t *hb_buffer = hb_buffer_create ();
CV_Assert( hb_buffer != NULL );

unsigned int textLen;
hb_buffer_guess_segment_properties (hb_buffer);
hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
hb_buffer_guess_segment_properties (hb_buffer);
hb_shape (mHb_font, hb_buffer, NULL, 0);

unsigned int textLen = 0;
hb_glyph_info_t *info =
hb_buffer_get_glyph_infos(hb_buffer,&textLen );
CV_Assert( info != NULL );

hb_shape (mHb_font, hb_buffer, NULL, 0);

_org.y += _fontHeight;
if( _bottomLeftOrigin == true ){
_org.y -= _fontHeight;
Expand Down Expand Up @@ -372,22 +371,23 @@ void FreeType2Impl::putTextBitmapBlend(
int _fontHeight, Scalar _color,
int _thickness, int _line_type, bool _bottomLeftOrigin )
{

CV_Assert( _thickness < 0 );
CV_Assert( _line_type == 16 );

Mat dst = _img.getMat();
hb_buffer_t *hb_buffer = hb_buffer_create ();
CV_Assert( hb_buffer != NULL );

unsigned int textLen;
hb_buffer_guess_segment_properties (hb_buffer);
hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
hb_buffer_guess_segment_properties (hb_buffer);
hb_shape (mHb_font, hb_buffer, NULL, 0);

unsigned int textLen = 0;
hb_glyph_info_t *info =
hb_buffer_get_glyph_infos(hb_buffer,&textLen );
CV_Assert( info != NULL );

hb_shape (mHb_font, hb_buffer, NULL, 0);

_org.y += _fontHeight;
if( _bottomLeftOrigin == true ){
_org.y -= _fontHeight;
Expand Down Expand Up @@ -461,13 +461,14 @@ Size FreeType2Impl::getTextSize(
CV_Assert( hb_buffer != NULL );
FT_Vector currentPos = {0,0};

unsigned int textLen;
hb_buffer_guess_segment_properties (hb_buffer);
hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
hb_buffer_guess_segment_properties (hb_buffer);
hb_shape (mHb_font, hb_buffer, NULL, 0);

unsigned int textLen = 0;
hb_glyph_info_t *info =
hb_buffer_get_glyph_infos(hb_buffer,&textLen );
CV_Assert( info != NULL );
hb_shape (mHb_font, hb_buffer, NULL, 0);

// Initilize BoundaryBox ( in OpenCV coordinates )
int xMin = INT_MAX, yMin = INT_MAX;
Expand Down