97  std::vector<std::vector<std::string> > words;
 
   98  max_width = std::max(max_width, 1);
 
  103  std::istringstream is_line(input);
 
  106  while (getline(is_line, line, 
'\n'))
 
  108    words.push_back(std::vector<std::string>());
 
  109    std::istringstream is_word(line);
 
  111    while (getline(is_word, word, 
' '))
 
  114      words.back().push_back(word);
 
  118  std::vector<std::string> output;
 
  120  for (
unsigned line_index = 0; line_index < words.size(); line_index++)
 
  123    unsigned int word_index = 0;
 
  128        std::string text_line = 
"";
 
  130        unsigned int local_word_index = word_index;
 
  131        unsigned int word_count = 0;
 
  134        while (line_size.width <= max_width)
 
  137          if (local_word_index >= words[line_index].size())
 
  144            text_line += words[line_index][local_word_index];
 
  146            text_line += 
" " + words[line_index][local_word_index];
 
  148#ifdef BT_USE_FREETYPE 
  150            line_size = obj_font->ft2->getTextSize(text_line, obj_font->
size, obj_font->
thickness, NULL);
 
  153            line_size = cv::getTextSize(text_line, obj_font->
face, obj_font->
scale, obj_font->
thickness, NULL);
 
  160        if (local_word_index >= words[line_index].size() && (words[line_index].size() <= 1))
 
  164        if (!done && word_count > 1)
 
  166          word_index = local_word_index - 1;
 
  167          text_line = text_line.substr(0, text_line.length() - words[line_index][local_word_index - 1].length() - 1);
 
  172          text_line = text_line.substr(0, text_line.length());
 
  175        output.push_back(text_line);
 
  180      std::string text_line = 
"";
 
  181      unsigned int local_word_index = word_index;
 
  182      unsigned int word_count = 0;
 
  185      while (local_word_index < words[line_index].size())
 
  188          text_line += words[line_index][local_word_index];
 
  190          text_line += 
" " + words[line_index][local_word_index];
 
  197      text_line = text_line.substr(0, text_line.length());
 
  199      output.push_back(text_line);
 
 
  368  int ilineoffset = MMpull(m);
 
  369  int iflags = MMpull(m);
 
  370  int isize = MMpull(m);
 
  371  int ipath = MMpull(m);
 
  379#ifndef BT_USE_FREETYPE 
  389  int scol_font_size = 16;
 
  394    scol_font_size = MTOI(isize);
 
  397    scol_font_flags = MTOI(iflags);
 
  399  if (ilineoffset != NIL)
 
  404  boost::filesystem::path fontPathBase = MMstartstr(m, MTOP(ipath));
 
  421    boost::filesystem::path fontPath;
 
  425      std::string path = fontPathBase.parent_path().generic_string();
 
  426      std::string fname = fontPathBase.stem().generic_string();
 
  427      std::string ext = fontPathBase.extension().generic_string();
 
  432        if ((fcheck = SCfopen((path + 
"/" + fname + 
"bi" + ext).c_str(), 
"rb")) != 0)
 
  435          fontPath = boost::filesystem::path(path + 
"/" + fname + 
"bi" + ext);
 
  437      if (fontPath.empty() && (scol_font_flags & 
BT_FONT_BOLD))
 
  438        if ((fcheck = SCfopen((path + 
"/" + fname + 
"b" + ext).c_str(), 
"rb")) != 0)
 
  441          fontPath = boost::filesystem::path(path + 
"/" + fname + 
"b" + ext);
 
  445        if ((fcheck = SCfopen((path + 
"/" + fname + 
"i" + ext).c_str(), 
"rb")) != 0)
 
  448          fontPath = boost::filesystem::path(path + 
"/" + fname + 
"i" + ext);
 
  452        if (boost::filesystem::exists(path + 
"/" + fname + 
"bi" + ext))
 
  453          fontPath = boost::filesystem::path(path + 
"/" + fname + 
"bi" + ext);
 
  455      if (fontPath.empty() && (scol_font_flags & 
BT_FONT_BOLD))
 
  456        if (boost::filesystem::exists(path + 
"/" + fname + 
"b" + ext))
 
  457          fontPath = boost::filesystem::path(path + 
"/" + fname + 
"b" + ext);
 
  460        if (boost::filesystem::exists(path + 
"/" + fname + 
"i" + ext))
 
  461          fontPath = boost::filesystem::path(path + 
"/" + fname + 
"i" + ext);
 
  466    if (fontPath.empty())
 
  467      fontPath = fontPathBase;
 
  469    if (!font->ft2->loadFontData(fontPath.generic_string(), 0))
 
  471      MMechostr(MSKDEBUG, 
"Warning on _CRBTfontFromFile : %s, not found", fontPath.generic_string().c_str());
 
  481    font->
face |= cv::FONT_ITALIC;
 
  492  cv::Size cv_font_size = font->ft2->getTextSize(
BT_CHARSETREF, 16, 1, NULL);
 
  493  font->
scale = (float)(cv_font_size.height) / 11.0f;
 
  494  font->
size = (int)((
float)scol_font_size * font->
scale);
 
  504  if ((MMpushPointer(m, font) != 0))
 
  512  return OBJcreate(m, 
SObjBTFont, SCOL_PTR font, NIL, 0);
 
 
  556  MMechostr(MSKDEBUG, 
"_BTDRAWtextBitmap");
 
  560  int itext = MMpull(m);
 
  561  int icolor = MMpull(m);
 
  562  int ialignmentFlags = MMpull(m);
 
  563  int icoordinates = MMpull(m);
 
  564  int ifont = MMpull(m);
 
  565  int ibitmap = MMget(m, 0);
 
  566  if (ibitmap == NIL || itext == NIL || icoordinates == NIL || ifont == NIL)
 
  568    MMechostr(MSKDEBUG, 
"input bitmap, text or coordinates are NIL");
 
  576  PtrObjVoid ptr_bitmap = (PtrObjVoid)MMstart(m, MTOP(ibitmap));
 
  577  PtrObjBitmap obj_bitmap = (PtrObjBitmap)MMstart(m, MTOP(ptr_bitmap->Buffer));
 
  582    MMechostr(MSKDEBUG, 
"input bitmap, is empty");
 
  588  int iposx = MMfetch(m, MTOP(icoordinates), 0);
 
  589  int iposy = MMfetch(m, MTOP(icoordinates), 1);
 
  590  if (iposx == NIL || iposy == NIL)
 
  592    MMechostr(MSKDEBUG, 
"coordinates x or y are NIL");
 
  596  int posx = MTOI(iposx);
 
  597  int posy = MTOI(iposy);
 
  602    int c = MTOI(icolor) & 0xffffff;
 
  603    color = cv::Scalar((c >> 16) & 255, (c >> 8) & 255, c & 255);
 
  607  std::string text = MMstartstr(m, MTOP(itext));
 
  618  PtrObjBTFont obj_font = MMgetPointer<PtrObjBTFont>(m, MTOP(ifont));
 
  626  if (ialignmentFlags != NIL)
 
  627    alignment = MTOI(ialignmentFlags);
 
  631  cv::Point cv_position;
 
  634#ifdef BT_USE_FREETYPE 
  636    line_size = obj_font->ft2->getTextSize(text, obj_font->
size, obj_font->
thickness, NULL);
 
  639    line_size = cv::getTextSize(text, obj_font->
face, obj_font->
scale, obj_font->
thickness, NULL);
 
  645    cv_position.x = posx;
 
  648    cv_position.x = posx - line_size.width;
 
  651    cv_position.x = posx - line_size.width / 2;
 
  654    cv_position.x = posx - line_size.width / 2;
 
  657    cv_position.x = posx;
 
  665    cv_position.y = posy + line_size.height;
 
  668    cv_position.y = posy + line_size.height / 2;
 
  671    cv_position.y = posy;
 
  674    cv_position.y = posy + line_size.height;
 
  681#ifdef BT_USE_FREETYPE 
  683      obj_font->ft2->putText(bitmap, text, cv_position, obj_font->
size, color, obj_font->
thickness, obj_font->
linetype, 
true);
 
  688  catch (cv::Exception e)
 
  690    MMechostr(MSKDEBUG, 
"error on cv::putText : %s in %s:%s:%d", e.msg.c_str(), e.file.c_str(), e.func.c_str(), e.line);
 
  694  cv::line(bitmap, cv::Point(cv_position.x - 4, cv_position.y), cv::Point(cv_position.x, cv_position.y), cv::Scalar(0, 125, 255));
 
  695  cv::line(bitmap, cv::Point(cv_position.x, cv_position.y), cv::Point(cv_position.x, cv_position.y + 4), cv::Scalar(0, 125, 255));
 
  696  cv::line(bitmap, cv::Point(posx - 4, posy), cv::Point(posx + 4, posy), cv::Scalar(0, 255, 125));
 
  697  cv::line(bitmap, cv::Point(posx, posy - 4), cv::Point(posx, posy + 4), cv::Scalar(0, 255, 125));
 
  701  MMechostr(MSKDEBUG, 
"end _BTDRAWtextBitmap");
 
 
  726  MMechostr(MSKDEBUG, 
"_BTDRAWtextAreaBitmap");
 
  730  int itext = MMpull(m);
 
  731  int icolor = MMpull(m);
 
  732  int ialignmentFlags = MMpull(m);
 
  733  int ioffset = MMpull(m);
 
  734  int icoordinates = MMpull(m);
 
  735  int ifont = MMpull(m);
 
  736  int ibitmap = MMget(m, 0);
 
  737  if (ibitmap == NIL || itext == NIL || icoordinates == NIL || ifont == NIL)
 
  739    MMechostr(MSKDEBUG, 
"input bitmap, text or coordinates are NIL");
 
  747    int c = MTOI(icolor) & 0xffffff;
 
  748    color = cv::Scalar((c >> 16) & 255, (c >> 8) & 255, c & 255);
 
  754  PtrObjVoid ptr_bitmap = (PtrObjVoid)MMstart(m, MTOP(ibitmap));
 
  755  PtrObjBitmap obj_bitmap = (PtrObjBitmap)MMstart(m, MTOP(ptr_bitmap->Buffer));
 
  760    MMechostr(MSKDEBUG, 
"input bitmap, is empty");
 
  766  cv::Point offset(0, 0);
 
  769    int ioffx = MMfetch(m, MTOP(ioffset), 0);
 
  770    int ioffy = MMfetch(m, MTOP(ioffset), 1);
 
  773      offset.x = MTOI(ioffx);
 
  776      offset.y = MTOI(ioffy);
 
  780  int iposx = MMfetch(m, MTOP(icoordinates), 0);
 
  781  int iposy = MMfetch(m, MTOP(icoordinates), 1);
 
  782  int iwidth = MMfetch(m, MTOP(icoordinates), 2);
 
  783  int iheight = MMfetch(m, MTOP(icoordinates), 3);
 
  784  if (iposx == NIL || iposy == NIL || iwidth == NIL || iheight == NIL)
 
  786    MMechostr(MSKDEBUG, 
"coordinates x, y, or size width, height are NIL");
 
  790  int rect_posx = MTOI(iposx);
 
  791  int rect_posy = MTOI(iposy);
 
  792  int rect_width = MTOI(iwidth);
 
  793  int rect_height = MTOI(iheight);
 
  796  if (rect_posx >= obj_bitmap->TailleW || rect_posy >= obj_bitmap->TailleH)
 
  798    MMechostr(MSKRUNTIME, 
"_BTDRAWtextAreaAlphaBitmap : error, tried to write text outside the bitmap");
 
  803  if (rect_width <= 0 || rect_height <= 0)
 
  805    MMechostr(MSKRUNTIME, 
"_BTDRAWtextAreaAlphaBitmap : error, negative rect bounds");
 
  816  if ((rect_posx + rect_width) > obj_bitmap->TailleW)
 
  817    rect_width = obj_bitmap->TailleW - rect_posx;
 
  819  if ((rect_posy + rect_height) > obj_bitmap->TailleH)
 
  820    rect_height = obj_bitmap->TailleH - rect_posy;
 
  823  cv::Rect brect(rect_posx, rect_posy, rect_width, rect_height);
 
  825  cv::Mat subBitmap = bitmap(brect);
 
  828  std::string text = MMstartstr(m, MTOP(itext));
 
  836  PtrObjBTFont obj_font = MMgetPointer<PtrObjBTFont>(m, MTOP(ifont));
 
  844  if (ialignmentFlags != NIL)
 
  845    alignment = MTOI(ialignmentFlags);
 
  849  cv::Point cv_position;
 
  852  cv::Size base_size = obj_font->
baseSize;
 
  854  line_shiftSize = (int)((
float)base_size.height * obj_font->
lineOffset) + abs(obj_font->
thickness);
 
  860    cv_position.y = line_shiftSize - (line_shiftSize - base_size.height) + obj_font->
xoffset;
 
  864    if (line_shiftSize * (
int)lines.size() < rect_height)
 
  866      cv_position.y = (rect_height / 2) - (((line_shiftSize * lines.size()) / 2) - base_size.height);
 
  869      cv_position.y = line_shiftSize;
 
  874    if (line_shiftSize * (
int)lines.size() < rect_height)
 
  876      cv_position.y = rect_height - (line_shiftSize * lines.size()) + base_size.height - obj_font->
xoffset;
 
  879      cv_position.y = line_shiftSize;
 
  886  cv_position.y += offset.y;
 
  888  for (
unsigned i = 0; i < lines.size(); i++)
 
  890    if (!lines[i].empty())
 
  892#ifdef BT_USE_FREETYPE 
  894        line_size = obj_font->ft2->getTextSize(lines[i], obj_font->
size, obj_font->
thickness, NULL);
 
  897        line_size = cv::getTextSize(lines[i], obj_font->
face, obj_font->
scale, obj_font->
thickness, NULL);      
 
  900    line_size.height = line_shiftSize;
 
  905      cv_position.x = obj_font->
xoffset;
 
  908      cv_position.x = rect_width - line_size.width - obj_font->
xoffset;
 
  911      cv_position.x = (rect_width / 2) - (line_size.width / 2);
 
  914      cv_position.x = obj_font->
xoffset;
 
  917      cv_position.x = obj_font->
xoffset;
 
  920    cv_position.x += offset.x;
 
  923    if (!lines[i].empty() && (cv_position.y < rect_height))
 
  926      cv::line(subBitmap, cv::Point(cv_position.x - 4, cv_position.y), cv::Point(cv_position.x, cv_position.y), cv::Scalar(0, 125, 255));
 
  927      cv::line(subBitmap, cv::Point(cv_position.x, cv_position.y), cv::Point(cv_position.x, cv_position.y + 4), cv::Scalar(0, 125, 255));
 
  932#ifdef BT_USE_FREETYPE 
  934          obj_font->ft2->putText(bitmap, lines[i], cv_position, obj_font->
size, color, obj_font->
thickness, obj_font->
linetype, 
true);
 
  937          cv::putText(subBitmap, lines[i], cv_position, obj_font->
face, obj_font->
scale, color, obj_font->
thickness, obj_font->
linetype);
 
  939      catch (cv::Exception e)
 
  941        MMechostr(MSKDEBUG, 
"error on cv::putText : %s in %s:%s:%d", e.msg.c_str(), e.file.c_str(), e.func.c_str(), e.line);
 
  945    cv_position.y += line_shiftSize;
 
  953  cv::rectangle(subBitmap, cv::Rect(0, 0, rect_width, rect_height), cv::Scalar(255, 0, 0));
 
  957  MMechostr(MSKDEBUG, 
"end _BTDRAWtextAreaBitmap");
 
 
  980  MMechostr(MSKDEBUG, 
"_BTDRAWtextAlphaBitmap");
 
  984  int itext = MMpull(m);
 
  985  int iopacity = MMpull(m);
 
  986  int icolor = MMpull(m);
 
  987  int ialignmentFlags = MMpull(m);
 
  988  int icoordinates = MMpull(m);
 
  989  int ifont = MMpull(m);
 
  990  int ibitmap = MMget(m, 0);
 
  991  if (ibitmap == NIL || itext == NIL || icoordinates == NIL || ifont == NIL)
 
  993    MMechostr(MSKDEBUG, 
"input bitmap, text or coordinates are NIL");
 
 1001    int c = MTOI(icolor) & 0xffffff;
 
 1002    color = cv::Scalar((c >> 16) & 255, (c >> 8) & 255, c & 255);
 
 1006  if (iopacity != NIL)
 
 1007    opacity = MTOI(iopacity) & 0xff;
 
 1009  cv::Scalar alpha = cv::Scalar(opacity);
 
 1014  int bmp24 = MMfetch(m, MTOP(ibitmap), 0);
 
 1015  int bmp8 = MMfetch(m, MTOP(ibitmap), 1);
 
 1018  PtrObjVoid ptr_bitmap = (PtrObjVoid)MMstart(m, MTOP(bmp24));
 
 1019  PtrObjBitmap obj_bitmap = (PtrObjBitmap)MMstart(m, MTOP(ptr_bitmap->Buffer));
 
 1021  PtrObjVoid ptr_bitmap8 = (PtrObjVoid)MMstart(m, MTOP(bmp8));
 
 1022  PtrObjBitmap obj_bitmap8 = (PtrObjBitmap)MMstart(m, MTOP(ptr_bitmap8->Buffer));
 
 1027    MMechostr(MSKDEBUG, 
"input bitmap, is empty");
 
 1033  if (bitmap8.empty())
 
 1035    MMechostr(MSKDEBUG, 
"input bitmap8, is empty");
 
 1041  int iposx = MMfetch(m, MTOP(icoordinates), 0);
 
 1042  int iposy = MMfetch(m, MTOP(icoordinates), 1);
 
 1043  if (iposx == NIL || iposy == NIL)
 
 1045    MMechostr(MSKDEBUG, 
"coordinates x or y are NIL");
 
 1049  int posx = MTOI(iposx);
 
 1050  int posy = MTOI(iposy);
 
 1053  std::string text = MMstartstr(m, MTOP(itext));
 
 1065  PtrObjBTFont obj_font = MMgetPointer<PtrObjBTFont>(m, MTOP(ifont));
 
 1073  if (ialignmentFlags != NIL)
 
 1074    alignment = MTOI(ialignmentFlags);
 
 1078  cv::Point cv_position;
 
 1080#ifdef BT_USE_FREETYPE 
 1082    line_size = obj_font->ft2->getTextSize(text, obj_font->
size, obj_font->
thickness, NULL);
 
 1085    line_size = cv::getTextSize(text, obj_font->
face, obj_font->
scale, obj_font->
thickness, NULL);
 
 1091    cv_position.x = posx;
 
 1094    cv_position.x = posx - line_size.width;
 
 1097    cv_position.x = posx - line_size.width / 2;
 
 1100    cv_position.x = posx - line_size.width / 2;
 
 1103    cv_position.x = posx;
 
 1111    cv_position.y = posy + line_size.height;
 
 1114    cv_position.y = posy + line_size.height / 2;
 
 1117    cv_position.y = posy;
 
 1120    cv_position.y = posy + line_size.height;
 
 1127#ifdef BT_USE_FREETYPE 
 1130      obj_font->ft2->putText(bitmap, text, cv_position, obj_font->
size, color, obj_font->
thickness, obj_font->
linetype, 
true);
 
 1131      obj_font->ft2->putText(bitmap8, text, cv_position, obj_font->
size, alpha, obj_font->
thickness, obj_font->
linetype, 
true);
 
 1140  catch (cv::Exception e)
 
 1142    MMechostr(MSKDEBUG, 
"error on cv::putText : %s in %s:%s:%d", e.msg.c_str(), e.file.c_str(), e.func.c_str(), e.line);
 
 1146  cv::line(bitmap, cv::Point(cv_position.x - 4, cv_position.y), cv::Point(cv_position.x, cv_position.y), cv::Scalar(0, 125, 255));
 
 1147  cv::line(bitmap, cv::Point(cv_position.x, cv_position.y), cv::Point(cv_position.x, cv_position.y + 4), cv::Scalar(0, 125, 255));
 
 1148  cv::line(bitmap, cv::Point(posx - 4, posy), cv::Point(posx + 4, posy), cv::Scalar(0, 255, 125));
 
 1149  cv::line(bitmap, cv::Point(posx, posy - 4), cv::Point(posx, posy + 4), cv::Scalar(0, 255, 125));
 
 1153  MMechostr(MSKDEBUG, 
"end _BTDRAWtextAlphaBitmap");
 
 
 1178  MMechostr(MSKDEBUG, 
"_BTDRAWtextAreaAlphaBitmap\n");
 
 1182  int itext = MMpull(m);
 
 1183  int iopacity = MMpull(m);
 
 1184  int icolor = MMpull(m);
 
 1185  int ialignmentFlags = MMpull(m);
 
 1186  int ioffset = MMpull(m);
 
 1187  int icoordinates = MMpull(m);
 
 1188  int ifont = MMpull(m);
 
 1189  int ibitmap = MMget(m, 0);
 
 1190  if (ibitmap == NIL || itext == NIL || icoordinates == NIL || ifont == NIL)
 
 1192    MMechostr(MSKDEBUG, 
"input bitmap, text or coordinates are NIL\n");
 
 1198  std::string text = MMstartstr(m, MTOP(itext));
 
 1201    MMechostr(MSKRUNTIME, 
"_BTDRAWtextAreaAlphaBitmap : text is nil\n");
 
 1206  cv::Scalar color(0);
 
 1209    int c = MTOI(icolor) & 0xffffff;
 
 1210    color = cv::Scalar((c >> 16) & 255, (c >> 8) & 255, c & 255);
 
 1214  if (iopacity != NIL)
 
 1215    opacity = MTOI(iopacity) & 0xff;
 
 1217  cv::Scalar alpha = cv::Scalar(opacity);
 
 1222  int bmp24 = MMfetch(m, MTOP(ibitmap), 0);
 
 1223  int bmp8 = MMfetch(m, MTOP(ibitmap), 1);
 
 1226  PtrObjVoid ptr_bitmap = (PtrObjVoid)MMstart(m, MTOP(bmp24));
 
 1227  PtrObjBitmap obj_bitmap = (PtrObjBitmap)MMstart(m, MTOP(ptr_bitmap->Buffer));
 
 1229  PtrObjVoid ptr_bitmap8 = (PtrObjVoid)MMstart(m, MTOP(bmp8));
 
 1230  PtrObjBitmap obj_bitmap8 = (PtrObjBitmap)MMstart(m, MTOP(ptr_bitmap8->Buffer));
 
 1235    MMechostr(MSKDEBUG, 
"input bitmap, is empty");
 
 1241  if (bitmap8.empty())
 
 1243    MMechostr(MSKDEBUG, 
"input bitmap8, is empty");
 
 1249  cv::Point offset(0, 0);
 
 1252    int ioffx = MMfetch(m, MTOP(ioffset), 0);
 
 1253    int ioffy = MMfetch(m, MTOP(ioffset), 1);
 
 1256      offset.x = MTOI(ioffx);
 
 1259      offset.y = MTOI(ioffy);
 
 1263  int iposx = MMfetch(m, MTOP(icoordinates), 0);
 
 1264  int iposy = MMfetch(m, MTOP(icoordinates), 1);
 
 1265  int iwidth = MMfetch(m, MTOP(icoordinates), 2);
 
 1266  int iheight = MMfetch(m, MTOP(icoordinates), 3);
 
 1267  if (iposx == NIL || iposy == NIL || iwidth == NIL || iheight == NIL)
 
 1269    MMechostr(MSKDEBUG, 
"coordinates x, y, or size width, height are NIL\n");
 
 1274  int rect_posx = MTOI(iposx);
 
 1275  int rect_posy = MTOI(iposy);
 
 1276  int rect_width = MTOI(iwidth);
 
 1277  int rect_height = MTOI(iheight);
 
 1280  if (rect_posx >= obj_bitmap->TailleW || rect_posy >= obj_bitmap->TailleH)
 
 1282    MMechostr(MSKRUNTIME, 
"_BTDRAWtextAreaAlphaBitmap : error, tried to write text outside the bitmap\n");
 
 1287  if (rect_width <= 0 || rect_height <= 0)
 
 1289    MMechostr(MSKRUNTIME, 
"_BTDRAWtextAreaAlphaBitmap : error, negative rect bounds\n");
 
 1300  if ((rect_posx + rect_width) > obj_bitmap->TailleW)
 
 1301    rect_width = obj_bitmap->TailleW - rect_posx;
 
 1303  if ((rect_posy + rect_height) > obj_bitmap->TailleH)
 
 1304    rect_height = obj_bitmap->TailleH - rect_posy;
 
 1307  cv::Rect brect(rect_posx, rect_posy, rect_width, rect_height);
 
 1309  cv::Mat subBitmap = bitmap(brect);
 
 1310  cv::Mat subBitmap8 = bitmap8(brect);
 
 1313  PtrObjBTFont obj_font = MMgetPointer<PtrObjBTFont>(m, MTOP(ifont));
 
 1321  if (ialignmentFlags != NIL)
 
 1322    alignment = MTOI(ialignmentFlags);
 
 1326  cv::Point cv_position;
 
 1328  cv::Size base_size = obj_font->
baseSize;
 
 1330  int line_shiftSize = (int)((
float)base_size.height * obj_font->
lineOffset) + abs(obj_font->
thickness);
 
 1336    cv_position.y = line_shiftSize - (line_shiftSize - base_size.height) + obj_font->
xoffset;
 
 1340    if (line_shiftSize * (
int)lines.size() < rect_height)
 
 1341      cv_position.y = (rect_height / 2) - (((line_shiftSize * lines.size()) / 2) - base_size.height);
 
 1343      cv_position.y = line_shiftSize;
 
 1348    if (line_shiftSize * (
int)lines.size() < rect_height)
 
 1349      cv_position.y = rect_height - (line_shiftSize * lines.size()) + base_size.height - obj_font->
xoffset;
 
 1351      cv_position.y = line_shiftSize;
 
 1358  cv_position.y += offset.y;
 
 1360  for (
unsigned i = 0; i < lines.size(); i++)
 
 1362    if (!lines[i].empty())
 
 1364#ifdef BT_USE_FREETYPE 
 1366        line_size = obj_font->ft2->getTextSize(lines[i], obj_font->
size, obj_font->
thickness, NULL);
 
 1369        line_size = cv::getTextSize(lines[i], obj_font->
face, obj_font->
scale, obj_font->
thickness, NULL);
 
 1372    line_size.height = line_shiftSize;
 
 1377      cv_position.x = obj_font->
xoffset;
 
 1380      cv_position.x = rect_width - line_size.width - obj_font->
xoffset;
 
 1383      cv_position.x = (rect_width / 2) - (line_size.width / 2);
 
 1386      cv_position.x = obj_font->
xoffset;
 
 1389      cv_position.x = obj_font->
xoffset;
 
 1392    cv_position.x += offset.x;
 
 1394    if (!lines[i].empty() && (cv_position.y < rect_height))
 
 1397      cv::line(subBitmap, cv::Point(cv_position.x - 4, cv_position.y), cv::Point(cv_position.x, cv_position.y), cv::Scalar(0, 125, 255));
 
 1398      cv::line(subBitmap, cv::Point(cv_position.x, cv_position.y), cv::Point(cv_position.x, cv_position.y + 4), cv::Scalar(0, 125, 255));
 
 1399      cv::rectangle(subBitmap, cv::Rect(cv_position.x, cv_position.y - base_size.height, line_size.width, line_shiftSize), cv::Scalar(0, 125, 255));
 
 1402      if (!lines[i].empty())
 
 1406#ifdef BT_USE_FREETYPE 
 1409            obj_font->ft2->putText(subBitmap, lines[i], cv_position, obj_font->
size, color, obj_font->
thickness, obj_font->
linetype, 
true);
 
 1410            obj_font->ft2->putText(subBitmap8, lines[i], cv_position, obj_font->
size, alpha, obj_font->
thickness, obj_font->
linetype, 
true);
 
 1415            cv::putText(subBitmap, lines[i], cv_position, obj_font->
face, obj_font->
scale, color, obj_font->
thickness, obj_font->
linetype);
 
 1416            cv::putText(subBitmap8, lines[i], cv_position, obj_font->
face, obj_font->
scale, alpha, obj_font->
thickness, obj_font->
linetype);
 
 1419        catch (cv::Exception e)
 
 1421          MMechostr(MSKDEBUG, 
"error on cv::putText : %s in %s:%s:%d", e.msg.c_str(), e.file.c_str(), e.func.c_str(), e.line);
 
 1426    cv_position.y += line_shiftSize;
 
 1434  cv::rectangle(subBitmap, cv::Rect(0, 0, rect_width, rect_height), cv::Scalar(255, 0, 0));
 
 1438  MMechostr(MSKDEBUG, 
"end _BTDRAWtextAreaAlphaBitmap\n");
 
 
 1454  MMechostr(MSKDEBUG, 
"_BTGETtextSize\n");
 
 1457  int itext = MMpull(m);
 
 1458  int ifont = MMget(m, 0);
 
 1466  std::string text = (itext == NIL) ? 
"" : MMstartstr(m, MTOP(itext));
 
 1468  std::vector<std::string> lines;
 
 1472  std::istringstream is_line(text);
 
 1475  while (getline(is_line, line, 
'\n'))
 
 1477    lines.push_back(line);
 
 1481  PtrObjBTFont obj_font = MMgetPointer<PtrObjBTFont>(m, MTOP(ifont));
 
 1490  cv::Size textsize(0, 0);
 
 1492  for (
unsigned i = 0; i < lines.size(); i++)
 
 1494    if (!lines[i].empty())
 
 1496#ifdef BT_USE_FREETYPE 
 1498        linesize = obj_font->ft2->getTextSize(lines[i], obj_font->
size, obj_font->
thickness, NULL);
 
 1501        linesize = cv::getTextSize(lines[i], obj_font->
face, obj_font->
scale, obj_font->
thickness, NULL);
 
 1505    linesize.height = line_shiftSize;
 
 1507    if (textsize.width < linesize.width)
 
 1508      textsize.width = linesize.width;
 
 1509    textsize.height += linesize.height;
 
 1512  textsize.width += obj_font->
xoffset * 2;
 
 1513  textsize.height += obj_font->
xoffset * 2;
 
 1515  int itextsize = MMmalloc(m, 2, TYPETAB);
 
 1516  if (itextsize == NIL)
 
 1522  MMstore(m, itextsize, 0, ITOM(textsize.width));
 
 1523  MMstore(m, itextsize, 1, ITOM(textsize.height));
 
 1524  MMset(m, 0, PTOM(itextsize));
 
 1527  MMechostr(MSKDEBUG, 
"end _BTGETtextSize\n");
 
 
 1545  MMechostr(MSKDEBUG, 
"_BTGETtextAreaHeight\n");
 
 1548  int iwidth = MMpull(m);
 
 1549  int ialignmentFlags = MMpull(m);
 
 1550  int itext = MMpull(m);
 
 1551  int ifont = MMget(m, 0);
 
 1553  if (ifont == NIL || iwidth == NIL)
 
 1559  std::string text = (itext == NIL) ? 
"" : MMstartstr(m, MTOP(itext));
 
 1562  PtrObjBTFont obj_font = MMgetPointer<PtrObjBTFont>(m, MTOP(ifont));
 
 1569  int width = MTOI(iwidth);
 
 1578    if (ialignmentFlags != NIL)
 
 1579      alignment = MTOI(ialignmentFlags);
 
 1583    cv::Point cv_position;
 
 1587    cv_position.y = obj_font->
xoffset;
 
 1588    for (
unsigned i = 0; i < lines.size(); i++)
 
 1590      if (!lines[i].empty())
 
 1592#ifdef BT_USE_FREETYPE 
 1594          linesize = obj_font->ft2->getTextSize(lines[i], obj_font->
size, obj_font->
thickness, NULL);
 
 1597          linesize = cv::getTextSize(lines[i], obj_font->
face, obj_font->
scale, obj_font->
thickness, NULL);
 
 1600      linesize.height = line_shiftSize;
 
 1605        cv_position.x = obj_font->
xoffset;
 
 1608        cv_position.x = width - linesize.width - obj_font->
xoffset;;
 
 1611        cv_position.x = (width / 2) - (linesize.width / 2);
 
 1614        cv_position.x = obj_font->
xoffset;
 
 1617        cv_position.x = obj_font->
xoffset;
 
 1621      cv_position.y += line_shiftSize;
 
 1627    linesize.height = cv_position.y + obj_font->
xoffset;
 
 1630  MMset(m, 0, ITOM(linesize.height));
 
 1633  MMechostr(MSKDEBUG, 
"end _BTGETtextAreaHeight\n");
 
 
int _CRBTfont(mmachine m)
_CRBTfont : Creates a ObjBTFont object Prototype: fun [Chn S I I F] ObjBTFont
 
int _CRBTfontFromFile(mmachine m)
_CRBTfontFromFile : Creates a ObjBTFont object Prototype: fun [Chn P I I F] ObjBTFont
 
int _BTDRAWtextAlphaBitmap(mmachine m)
_BTDRAWtextAlphaBitmap : Draws a text to a bitmap Prototype: fun [AlphaBitmap ObjBTFont [I I] I I I S...
 
int _BTDRAWtextAreaAlphaBitmap(mmachine m)
_BTDRAWtextAreaAlphaBitmap : Draws a text to an alpha bitmap, within a defined area Prototype: fun [A...
 
int _BTDRAWtextBitmap(mmachine m)
_BTDRAWtextBitmap : Draws a text to a bitmap Prototype: fun [ObjBitmap S ObjBTFont [I I] I I] ObjBitm...
 
int _BTGETtextSize(mmachine m)
_BTGETtextSize : Gets the length of a text line Prototype: fun [ObjBTFont S] [I I]
 
int _BTGETtextAreaHeight(mmachine m)
_BTGETtextAreaHeight : Gets the height of a formated text area Prototype: fun [ObjBTFont S I I] I
 
int _DSBTfont(mmachine m)
_DSBTfont : Deletes a cv font object Prototype: fun [ObjBTFont] I
 
int _BTDRAWtextAreaBitmap(mmachine m)
_BTDRAWtextAreaBitmap : Draws a text to a bitmap, within a defined area Prototype: fun [ObjBitmap Obj...