@@ -238,24 +238,23 @@ void FreeType2Impl::putTextOutline(
238238 hb_buffer_t *hb_buffer = hb_buffer_create ();
239239 CV_Assert ( hb_buffer != NULL );
240240
241- unsigned int textLen;
242- hb_buffer_guess_segment_properties (hb_buffer);
243241 hb_buffer_add_utf8 (hb_buffer, _text.c_str (), -1 , 0 , -1 );
244- FT_Vector currentPos = {0 ,0 };
242+ hb_buffer_guess_segment_properties (hb_buffer);
243+ hb_shape (mHb_font , hb_buffer, NULL , 0 );
245244
245+ unsigned int textLen = 0 ;
246246 hb_glyph_info_t *info =
247247 hb_buffer_get_glyph_infos (hb_buffer,&textLen );
248248 CV_Assert ( info != NULL );
249249
250- hb_shape (mHb_font , hb_buffer, NULL , 0 );
251-
252250 PathUserData *userData = new PathUserData ( _img );
253251 userData->mColor = _color;
254252 userData->mCtoL = mCtoL ;
255253 userData->mThickness = _thickness;
256254 userData->mLine_type = _line_type;
257255
258256 // Initilize currentPosition ( in FreeType coordinates)
257+ FT_Vector currentPos = {0 ,0 };
259258 currentPos.x = _org.x * 64 ;
260259 currentPos.y = _org.y * 64 ;
261260
@@ -305,15 +304,15 @@ void FreeType2Impl::putTextBitmapMono(
305304 hb_buffer_t *hb_buffer = hb_buffer_create ();
306305 CV_Assert ( hb_buffer != NULL );
307306
308- unsigned int textLen;
309- hb_buffer_guess_segment_properties (hb_buffer);
310307 hb_buffer_add_utf8 (hb_buffer, _text.c_str (), -1 , 0 , -1 );
308+ hb_buffer_guess_segment_properties (hb_buffer);
309+ hb_shape (mHb_font , hb_buffer, NULL , 0 );
310+
311+ unsigned int textLen = 0 ;
311312 hb_glyph_info_t *info =
312313 hb_buffer_get_glyph_infos (hb_buffer,&textLen );
313314 CV_Assert ( info != NULL );
314315
315- hb_shape (mHb_font , hb_buffer, NULL , 0 );
316-
317316 _org.y += _fontHeight;
318317 if ( _bottomLeftOrigin == true ){
319318 _org.y -= _fontHeight;
@@ -372,22 +371,23 @@ void FreeType2Impl::putTextBitmapBlend(
372371 int _fontHeight, Scalar _color,
373372 int _thickness, int _line_type, bool _bottomLeftOrigin )
374373{
374+
375375 CV_Assert ( _thickness < 0 );
376376 CV_Assert ( _line_type == 16 );
377377
378378 Mat dst = _img.getMat ();
379379 hb_buffer_t *hb_buffer = hb_buffer_create ();
380380 CV_Assert ( hb_buffer != NULL );
381381
382- unsigned int textLen;
383- hb_buffer_guess_segment_properties (hb_buffer);
384382 hb_buffer_add_utf8 (hb_buffer, _text.c_str (), -1 , 0 , -1 );
383+ hb_buffer_guess_segment_properties (hb_buffer);
384+ hb_shape (mHb_font , hb_buffer, NULL , 0 );
385+
386+ unsigned int textLen = 0 ;
385387 hb_glyph_info_t *info =
386388 hb_buffer_get_glyph_infos (hb_buffer,&textLen );
387389 CV_Assert ( info != NULL );
388390
389- hb_shape (mHb_font , hb_buffer, NULL , 0 );
390-
391391 _org.y += _fontHeight;
392392 if ( _bottomLeftOrigin == true ){
393393 _org.y -= _fontHeight;
@@ -461,13 +461,14 @@ Size FreeType2Impl::getTextSize(
461461 CV_Assert ( hb_buffer != NULL );
462462 FT_Vector currentPos = {0 ,0 };
463463
464- unsigned int textLen;
465- hb_buffer_guess_segment_properties (hb_buffer);
466464 hb_buffer_add_utf8 (hb_buffer, _text.c_str (), -1 , 0 , -1 );
465+ hb_buffer_guess_segment_properties (hb_buffer);
466+ hb_shape (mHb_font , hb_buffer, NULL , 0 );
467+
468+ unsigned int textLen = 0 ;
467469 hb_glyph_info_t *info =
468470 hb_buffer_get_glyph_infos (hb_buffer,&textLen );
469471 CV_Assert ( info != NULL );
470- hb_shape (mHb_font , hb_buffer, NULL , 0 );
471472
472473 // Initilize BoundaryBox ( in OpenCV coordinates )
473474 int xMin = INT_MAX, yMin = INT_MAX;
0 commit comments