tesseract  4.00.00dev
tesseract::StringRenderer Class Reference

#include <stringrenderer.h>

Public Member Functions

 StringRenderer (const string &font_desc, int page_width, int page_height)
 
 ~StringRenderer ()
 
int RenderToImage (const char *text, int text_length, Pix **pix)
 
int RenderToGrayscaleImage (const char *text, int text_length, Pix **pix)
 
int RenderToBinaryImage (const char *text, int text_length, int threshold, Pix **pix)
 
int RenderAllFontsToImage (double min_coverage, const char *text, int text_length, string *font_used, Pix **pix)
 
bool set_font (const string &desc)
 
void set_char_spacing (double char_spacing)
 
void set_leading (int leading)
 
void set_resolution (const int resolution)
 
void set_vertical_text (bool vertical_text)
 
void set_gravity_hint_strong (bool gravity_hint_strong)
 
void set_render_fullwidth_latin (bool render_fullwidth_latin)
 
void set_underline_start_prob (const double frac)
 
void set_underline_continuation_prob (const double frac)
 
void set_underline_style (const PangoUnderline style)
 
void set_features (const char *features)
 
void set_page (int page)
 
void set_box_padding (int val)
 
void set_drop_uncovered_chars (bool val)
 
void set_strip_unrenderable_words (bool val)
 
void set_output_word_boxes (bool val)
 
void set_add_ligatures (bool add_ligatures)
 
void set_pen_color (double r, double g, double b)
 
void set_h_margin (const int h_margin)
 
void set_v_margin (const int v_margin)
 
const PangoFontInfofont () const
 
int h_margin () const
 
int v_margin () const
 
const std::vector< BoxChar * > & GetBoxes () const
 
Boxa * GetPageBoxes () const
 
void RotatePageBoxes (float rotation)
 
void ClearBoxes ()
 
string GetBoxesStr ()
 
void WriteAllBoxes (const string &filename)
 
int StripUnrenderableWords (string *utf8_text) const
 

Static Public Member Functions

static string InsertWordJoiners (const string &text)
 
static string ConvertBasicLatinToFullwidthLatin (const string &text)
 
static string ConvertFullwidthLatinToBasicLatin (const string &text)
 

Protected Member Functions

void InitPangoCairo ()
 
void FreePangoCairo ()
 
void SetLayoutProperties ()
 
void SetWordUnderlineAttributes (const string &page_text)
 
void ComputeClusterBoxes ()
 
void CorrectBoxPositionsToLayout (std::vector< BoxChar *> *boxchars)
 
bool GetClusterStrings (std::vector< string > *cluster_text)
 
int FindFirstPageBreakOffset (const char *text, int text_length)
 

Protected Attributes

PangoFontInfo font_
 
int page_width_
 
int page_height_
 
int h_margin_
 
int v_margin_
 
int pen_color_ [3]
 
double char_spacing_
 
int leading_
 
int resolution_
 
bool vertical_text_
 
bool gravity_hint_strong_
 
bool render_fullwidth_latin_
 
double underline_start_prob_
 
double underline_continuation_prob_
 
PangoUnderline underline_style_
 
char * features_
 
bool drop_uncovered_chars_
 
bool strip_unrenderable_words_
 
bool add_ligatures_
 
bool output_word_boxes_
 
cairo_surface_t * surface_
 
cairo_t * cr_
 
PangoLayout * layout_
 
int start_box_
 
int page_
 
std::vector< BoxChar * > boxchars_
 
int box_padding_
 
Boxa * page_boxes_
 
std::unordered_map< char32, inT64char_map_
 
int total_chars_
 
int font_index_
 
int last_offset_
 

Detailed Description

Definition at line 48 of file stringrenderer.h.

Constructor & Destructor Documentation

◆ StringRenderer()

tesseract::StringRenderer::StringRenderer ( const string &  font_desc,
int  page_width,
int  page_height 
)

Definition at line 98 of file stringrenderer.cpp.

100  : page_width_(page_width),
101  page_height_(page_height),
102  h_margin_(50),
103  v_margin_(50),
104  char_spacing_(0),
105  leading_(0),
106  vertical_text_(false),
107  gravity_hint_strong_(false),
111  underline_style_(PANGO_UNDERLINE_SINGLE),
112  features_(nullptr),
113  drop_uncovered_chars_(true),
115  add_ligatures_(false),
116  output_word_boxes_(false),
117  surface_(nullptr),
118  cr_(nullptr),
119  layout_(nullptr),
120  start_box_(0),
121  page_(0),
122  box_padding_(0),
123  total_chars_(0),
124  font_index_(0),
125  last_offset_(0) {
126  pen_color_[0] = 0.0;
127  pen_color_[1] = 0.0;
128  pen_color_[2] = 0.0;
129  set_font(font_desc);
130  set_resolution(kDefaultOutputResolution);
131  page_boxes_ = nullptr;
132 }
PangoUnderline underline_style_
bool set_font(const string &desc)
void set_resolution(const int resolution)
cairo_surface_t * surface_

◆ ~StringRenderer()

tesseract::StringRenderer::~StringRenderer ( )

Definition at line 153 of file stringrenderer.cpp.

153  {
154  free(features_);
155  ClearBoxes();
156  FreePangoCairo();
157 }

Member Function Documentation

◆ ClearBoxes()

void tesseract::StringRenderer::ClearBoxes ( )

Definition at line 344 of file stringrenderer.cpp.

344  {
345  for (size_t i = 0; i < boxchars_.size(); ++i)
346  delete boxchars_[i];
347  boxchars_.clear();
348  boxaDestroy(&page_boxes_);
349 }
std::vector< BoxChar * > boxchars_

◆ ComputeClusterBoxes()

void tesseract::StringRenderer::ComputeClusterBoxes ( )
protected

Definition at line 468 of file stringrenderer.cpp.

468  {
469  const char* text = pango_layout_get_text(layout_);
470  PangoLayoutIter* cluster_iter = pango_layout_get_iter(layout_);
471 
472  // Do a first pass to store cluster start indexes.
473  std::vector<int> cluster_start_indices;
474  do {
475  cluster_start_indices.push_back(pango_layout_iter_get_index(cluster_iter));
476  tlog(3, "Added %d\n", cluster_start_indices.back());
477  } while (pango_layout_iter_next_cluster(cluster_iter));
478  pango_layout_iter_free(cluster_iter);
479  cluster_start_indices.push_back(strlen(text));
480  tlog(3, "Added last index %d\n", cluster_start_indices.back());
481  // Sort the indices and create a map from start to end indices.
482  std::sort(cluster_start_indices.begin(), cluster_start_indices.end());
483  std::map<int, int> cluster_start_to_end_index;
484  for (size_t i = 0; i + 1 < cluster_start_indices.size(); ++i) {
485  cluster_start_to_end_index[cluster_start_indices[i]]
486  = cluster_start_indices[i + 1];
487  }
488 
489  // Iterate again to compute cluster boxes and their text with the obtained
490  // cluster extent information.
491  cluster_iter = pango_layout_get_iter(layout_);
492  // Store BoxChars* sorted by their byte start positions
493  std::map<int, BoxChar*> start_byte_to_box;
494  do {
495  PangoRectangle cluster_rect;
496  pango_layout_iter_get_cluster_extents(cluster_iter, &cluster_rect, nullptr);
497  pango_extents_to_pixels(&cluster_rect, nullptr);
498  const int start_byte_index = pango_layout_iter_get_index(cluster_iter);
499  const int end_byte_index = cluster_start_to_end_index[start_byte_index];
500  string cluster_text = string(text + start_byte_index,
501  end_byte_index - start_byte_index);
502  if (!cluster_text.empty() && cluster_text[0] == '\n') {
503  tlog(2, "Skipping newlines at start of text.\n");
504  continue;
505  }
506  if (!cluster_rect.width || !cluster_rect.height ||
507  IsUTF8Whitespace(cluster_text.c_str())) {
508  tlog(2, "Skipping whitespace with boxdim (%d,%d) '%s'\n",
509  cluster_rect.width, cluster_rect.height, cluster_text.c_str());
510  BoxChar* boxchar = new BoxChar(" ", 1);
511  boxchar->set_page(page_);
512  start_byte_to_box[start_byte_index] = boxchar;
513  continue;
514  }
515  // Prepare a boxchar for addition at this byte position.
516  tlog(2, "[%d %d], %d, %d : start_byte=%d end_byte=%d : '%s'\n",
517  cluster_rect.x, cluster_rect.y,
518  cluster_rect.width, cluster_rect.height,
519  start_byte_index, end_byte_index,
520  cluster_text.c_str());
521  ASSERT_HOST_MSG(cluster_rect.width,
522  "cluster_text:%s start_byte_index:%d\n",
523  cluster_text.c_str(), start_byte_index);
524  ASSERT_HOST_MSG(cluster_rect.height,
525  "cluster_text:%s start_byte_index:%d\n",
526  cluster_text.c_str(), start_byte_index);
527  if (box_padding_) {
528  cluster_rect.x = max(0, cluster_rect.x - box_padding_);
529  cluster_rect.width += 2 * box_padding_;
530  cluster_rect.y = max(0, cluster_rect.y - box_padding_);
531  cluster_rect.height += 2 * box_padding_;
532  }
533  if (add_ligatures_) {
534  // Make sure the output box files have ligatured text in case the font
535  // decided to use an unmapped glyph.
536  cluster_text = LigatureTable::Get()->AddLigatures(cluster_text, nullptr);
537  }
538  BoxChar* boxchar = new BoxChar(cluster_text.c_str(), cluster_text.size());
539  boxchar->set_page(page_);
540  boxchar->AddBox(cluster_rect.x, cluster_rect.y,
541  cluster_rect.width, cluster_rect.height);
542  start_byte_to_box[start_byte_index] = boxchar;
543  } while (pango_layout_iter_next_cluster(cluster_iter));
544  pango_layout_iter_free(cluster_iter);
545 
546  // There is a subtle bug in the cluster text reported by the PangoLayoutIter
547  // on ligatured characters (eg. The word "Lam-Aliph" in arabic). To work
548  // around this, we use text reported using the PangoGlyphIter which is
549  // accurate.
550  // TODO(ranjith): Revisit whether this is still needed in newer versions of
551  // pango.
552  std::vector<string> cluster_text;
553  if (GetClusterStrings(&cluster_text)) {
554  ASSERT_HOST(cluster_text.size() == start_byte_to_box.size());
555  int ind = 0;
556  for (std::map<int, BoxChar*>::iterator it = start_byte_to_box.begin();
557  it != start_byte_to_box.end(); ++it, ++ind) {
558  it->second->mutable_ch()->swap(cluster_text[ind]);
559  }
560  }
561 
562  // Append to the boxchars list in byte order.
563  std::vector<BoxChar*> page_boxchars;
564  page_boxchars.reserve(start_byte_to_box.size());
565  string last_ch;
566  for (std::map<int, BoxChar*>::const_iterator it = start_byte_to_box.begin();
567  it != start_byte_to_box.end(); ++it) {
568  if (it->second->ch() == kWordJoinerUTF8) {
569  // Skip zero-width joiner characters (ZWJs) here.
570  delete it->second;
571  } else {
572  page_boxchars.push_back(it->second);
573  }
574  }
575  CorrectBoxPositionsToLayout(&page_boxchars);
576 
578  for (std::map<int, BoxChar*>::iterator it = start_byte_to_box.begin();
579  it != start_byte_to_box.end(); ++it) {
580  // Convert fullwidth Latin characters to their halfwidth forms.
581  string half(ConvertFullwidthLatinToBasicLatin(it->second->ch()));
582  it->second->mutable_ch()->swap(half);
583  }
584  }
585 
586  // Merge the character boxes into word boxes if we are rendering n-grams.
587  if (output_word_boxes_) {
588  MergeBoxCharsToWords(&page_boxchars);
589  }
590 
591  boxchars_.insert(boxchars_.end(), page_boxchars.begin(), page_boxchars.end());
592 
593  // Compute the page bounding box
594  Box* page_box = nullptr;
595  Boxa* all_boxes = nullptr;
596  for (size_t i = 0; i < page_boxchars.size(); ++i) {
597  if (page_boxchars[i]->box() == nullptr) continue;
598  if (all_boxes == nullptr) all_boxes = boxaCreate(0);
599  boxaAddBox(all_boxes, page_boxchars[i]->mutable_box(), L_CLONE);
600  }
601  if (all_boxes != nullptr) {
602  boxaGetExtent(all_boxes, nullptr, nullptr, &page_box);
603  boxaDestroy(&all_boxes);
604  if (page_boxes_ == nullptr) page_boxes_ = boxaCreate(0);
605  boxaAddBox(page_boxes_, page_box, L_INSERT);
606  }
607 }
bool GetClusterStrings(std::vector< string > *cluster_text)
std::vector< BoxChar * > boxchars_
#define tlog(level,...)
Definition: tlog.h:33
#define ASSERT_HOST_MSG(x,...)
Definition: errcode.h:90
string AddLigatures(const string &str, const PangoFontInfo *font) const
#define ASSERT_HOST(x)
Definition: errcode.h:84
static LigatureTable * Get()
static string ConvertFullwidthLatinToBasicLatin(const string &text)
const int max
bool IsUTF8Whitespace(const char *text)
Definition: normstrngs.cpp:184
void CorrectBoxPositionsToLayout(std::vector< BoxChar *> *boxchars)

◆ ConvertBasicLatinToFullwidthLatin()

string tesseract::StringRenderer::ConvertBasicLatinToFullwidthLatin ( const string &  text)
static

Definition at line 702 of file stringrenderer.cpp.

702  {
703  string full_str;
704  const UNICHAR::const_iterator it_end = UNICHAR::end(str.c_str(),
705  str.length());
706  for (UNICHAR::const_iterator it = UNICHAR::begin(str.c_str(), str.length());
707  it != it_end; ++it) {
708  // Convert printable and non-space 7-bit ASCII characters to
709  // their fullwidth forms.
710  if (IsInterchangeValid7BitAscii(*it) && isprint(*it) && !isspace(*it)) {
711  // Convert by adding 0xFEE0 to the codepoint of 7-bit ASCII.
712  char32 full_char = *it + 0xFEE0;
713  full_str.append(EncodeAsUTF8(full_char));
714  } else {
715  full_str.append(it.utf8_data(), it.utf8_len());
716  }
717  }
718  return full_str;
719 }
static const_iterator begin(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:200
bool IsInterchangeValid7BitAscii(const char32 ch)
Definition: normstrngs.cpp:240
static const_iterator end(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:204
signed int char32
Definition: normstrngs.h:27

◆ ConvertFullwidthLatinToBasicLatin()

string tesseract::StringRenderer::ConvertFullwidthLatinToBasicLatin ( const string &  text)
static

Definition at line 722 of file stringrenderer.cpp.

722  {
723  string half_str;
724  UNICHAR::const_iterator it_end = UNICHAR::end(str.c_str(), str.length());
725  for (UNICHAR::const_iterator it = UNICHAR::begin(str.c_str(), str.length());
726  it != it_end; ++it) {
727  char32 half_char = FullwidthToHalfwidth(*it);
728  // Convert fullwidth Latin characters to their halfwidth forms
729  // only if halfwidth forms are printable and non-space 7-bit ASCII.
730  if (IsInterchangeValid7BitAscii(half_char) &&
731  isprint(half_char) && !isspace(half_char)) {
732  half_str.append(EncodeAsUTF8(half_char));
733  } else {
734  half_str.append(it.utf8_data(), it.utf8_len());
735  }
736  }
737  return half_str;
738 }
static const_iterator begin(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:200
bool IsInterchangeValid7BitAscii(const char32 ch)
Definition: normstrngs.cpp:240
static const_iterator end(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:204
signed int char32
Definition: normstrngs.h:27
char32 FullwidthToHalfwidth(const char32 ch)
Definition: normstrngs.cpp:247

◆ CorrectBoxPositionsToLayout()

void tesseract::StringRenderer::CorrectBoxPositionsToLayout ( std::vector< BoxChar *> *  boxchars)
protected

Definition at line 610 of file stringrenderer.cpp.

611  {
612  if (vertical_text_) {
613  const double rotation = - pango_gravity_to_rotation(
614  pango_context_get_base_gravity(pango_layout_get_context(layout_)));
617  0, boxchars->size(), boxchars);
618  } else {
620  }
621 }
static void TranslateBoxes(int xshift, int yshift, std::vector< BoxChar *> *boxes)
Definition: boxchar.cpp:52
static void RotateBoxes(float rotation, int xcenter, int ycenter, int start_box, int end_box, std::vector< BoxChar *> *boxes)
Definition: boxchar.cpp:273

◆ FindFirstPageBreakOffset()

int tesseract::StringRenderer::FindFirstPageBreakOffset ( const char *  text,
int  text_length 
)
protected

Definition at line 286 of file stringrenderer.cpp.

287  {
288  if (!text_length) return 0;
289  const int max_height = (page_height_ - 2 * v_margin_);
290  const int max_width = (page_width_ - 2 * h_margin_);
291  const int max_layout_height = vertical_text_ ? max_width : max_height;
292 
293  UNICHAR::const_iterator it = UNICHAR::begin(text, text_length);
294  const UNICHAR::const_iterator it_end = UNICHAR::end(text, text_length);
295  const int kMaxUnicodeBufLength = 15000;
296  for (int i = 0; i < kMaxUnicodeBufLength && it != it_end; ++it, ++i);
297  int buf_length = it.utf8_data() - text;
298  tlog(1, "len = %d buf_len = %d\n", text_length, buf_length);
299  pango_layout_set_text(layout_, text, buf_length);
300 
301  PangoLayoutIter* line_iter = nullptr;
302  { // Fontconfig caches some info here that is not freed before exit.
304  line_iter = pango_layout_get_iter(layout_);
305  }
306  bool first_page = true;
307  int page_top = 0;
308  int offset = buf_length;
309  do {
310  // Get bounding box of the current line
311  PangoRectangle line_ink_rect;
312  pango_layout_iter_get_line_extents(line_iter, &line_ink_rect, nullptr);
313  pango_extents_to_pixels(&line_ink_rect, nullptr);
314  PangoLayoutLine* line = pango_layout_iter_get_line_readonly(line_iter);
315  if (first_page) {
316  page_top = line_ink_rect.y;
317  first_page = false;
318  }
319  int line_bottom = line_ink_rect.y + line_ink_rect.height;
320  if (line_bottom - page_top > max_layout_height) {
321  offset = line->start_index;
322  tlog(1, "Found offset = %d\n", offset);
323  break;
324  }
325  } while (pango_layout_iter_next_line(line_iter));
326  pango_layout_iter_free(line_iter);
327  return offset;
328 }
static const_iterator begin(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:200
#define tlog(level,...)
Definition: tlog.h:33
static const_iterator end(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:204
voidpf uLong offset
Definition: ioapi.h:42
#define DISABLE_HEAP_LEAK_CHECK
Definition: util.h:63
const char * utf8_data() const
Definition: unichar.h:130

◆ font()

const PangoFontInfo& tesseract::StringRenderer::font ( ) const
inline

Definition at line 130 of file stringrenderer.h.

130  {
131  return font_;
132  }

◆ FreePangoCairo()

void tesseract::StringRenderer::FreePangoCairo ( )
protected

Definition at line 225 of file stringrenderer.cpp.

225  {
226  if (layout_) {
227  g_object_unref(layout_);
228  layout_ = nullptr;
229  }
230  if (cr_) {
231  cairo_destroy(cr_);
232  cr_ = nullptr;
233  }
234  if (surface_) {
235  cairo_surface_destroy(surface_);
236  surface_ = nullptr;
237  }
238 }
cairo_surface_t * surface_

◆ GetBoxes()

const std::vector< BoxChar * > & tesseract::StringRenderer::GetBoxes ( ) const

Definition at line 330 of file stringrenderer.cpp.

330  {
331  return boxchars_;
332 }
std::vector< BoxChar * > boxchars_

◆ GetBoxesStr()

string tesseract::StringRenderer::GetBoxesStr ( )

Definition at line 351 of file stringrenderer.cpp.

351  {
354 }
std::vector< BoxChar * > boxchars_
static string GetTesseractBoxStr(int height, const std::vector< BoxChar *> &boxes)
Definition: boxchar.cpp:301
static void PrepareToWrite(std::vector< BoxChar *> *boxes)
Definition: boxchar.cpp:66

◆ GetClusterStrings()

bool tesseract::StringRenderer::GetClusterStrings ( std::vector< string > *  cluster_text)
protected

Definition at line 362 of file stringrenderer.cpp.

362  {
363  std::map<int, string> start_byte_to_text;
364  PangoLayoutIter* run_iter = pango_layout_get_iter(layout_);
365  const char* full_text = pango_layout_get_text(layout_);
366  do {
367  PangoLayoutRun* run = pango_layout_iter_get_run_readonly(run_iter);
368  if (!run) {
369  // End of line nullptr run marker
370  tlog(2, "Found end of line marker\n");
371  continue;
372  }
373  PangoGlyphItemIter cluster_iter;
374  gboolean have_cluster;
375  for (have_cluster = pango_glyph_item_iter_init_start(&cluster_iter,
376  run, full_text);
377  have_cluster;
378  have_cluster = pango_glyph_item_iter_next_cluster(&cluster_iter)) {
379  const int start_byte_index = cluster_iter.start_index;
380  const int end_byte_index = cluster_iter.end_index;
381  string text = string(full_text + start_byte_index,
382  end_byte_index - start_byte_index);
383  if (IsUTF8Whitespace(text.c_str())) {
384  tlog(2, "Found whitespace\n");
385  text = " ";
386  }
387  tlog(2, "start_byte=%d end_byte=%d : '%s'\n", start_byte_index,
388  end_byte_index, text.c_str());
389  if (add_ligatures_) {
390  // Make sure the output box files have ligatured text in case the font
391  // decided to use an unmapped glyph.
392  text = LigatureTable::Get()->AddLigatures(text, nullptr);
393  }
394  start_byte_to_text[start_byte_index] = text;
395  }
396  } while (pango_layout_iter_next_run(run_iter));
397  pango_layout_iter_free(run_iter);
398 
399  cluster_text->clear();
400  for (std::map<int, string>::const_iterator it = start_byte_to_text.begin();
401  it != start_byte_to_text.end(); ++it) {
402  cluster_text->push_back(it->second);
403  }
404  return !cluster_text->empty();
405 }
#define tlog(level,...)
Definition: tlog.h:33
string AddLigatures(const string &str, const PangoFontInfo *font) const
static LigatureTable * Get()
bool IsUTF8Whitespace(const char *text)
Definition: normstrngs.cpp:184

◆ GetPageBoxes()

Boxa * tesseract::StringRenderer::GetPageBoxes ( ) const

Definition at line 334 of file stringrenderer.cpp.

334  {
335  return page_boxes_;
336 }

◆ h_margin()

int tesseract::StringRenderer::h_margin ( ) const
inline

Definition at line 133 of file stringrenderer.h.

133 { return h_margin_; }

◆ InitPangoCairo()

void tesseract::StringRenderer::InitPangoCairo ( )
protected

Definition at line 159 of file stringrenderer.cpp.

159  {
160  FreePangoCairo();
161  surface_ = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, page_width_,
162  page_height_);
163  cr_ = cairo_create(surface_);
164  {
166  layout_ = pango_cairo_create_layout(cr_);
167  }
168 
169  if (vertical_text_) {
170  PangoContext* context = pango_layout_get_context(layout_);
171  pango_context_set_base_gravity(context, PANGO_GRAVITY_EAST);
172  if (gravity_hint_strong_) {
173  pango_context_set_gravity_hint(context, PANGO_GRAVITY_HINT_STRONG);
174  }
175  pango_layout_context_changed(layout_);
176  }
177 
179 }
#define DISABLE_HEAP_LEAK_CHECK
Definition: util.h:63
cairo_surface_t * surface_

◆ InsertWordJoiners()

string tesseract::StringRenderer::InsertWordJoiners ( const string &  text)
static

Definition at line 679 of file stringrenderer.cpp.

679  {
680  string out_str;
681  const UNICHAR::const_iterator it_end = UNICHAR::end(text.c_str(),
682  text.length());
683  for (UNICHAR::const_iterator it = UNICHAR::begin(text.c_str(), text.length());
684  it != it_end; ++it) {
685  // Add the symbol to the output string.
686  out_str.append(it.utf8_data(), it.utf8_len());
687  // Check the next symbol.
688  UNICHAR::const_iterator next_it = it;
689  ++next_it;
690  bool next_char_is_boundary = (next_it == it_end || *next_it == ' ');
691  bool next_char_is_combiner = (next_it == it_end) ?
692  false : IsCombiner(*next_it);
693  if (*it != ' ' && *it != '\n' && !next_char_is_boundary &&
694  !next_char_is_combiner) {
695  out_str += kWordJoinerUTF8;
696  }
697  }
698  return out_str;
699 }
static const_iterator begin(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:200
static const_iterator end(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:204

◆ RenderAllFontsToImage()

int tesseract::StringRenderer::RenderAllFontsToImage ( double  min_coverage,
const char *  text,
int  text_length,
string *  font_used,
Pix **  pix 
)

Definition at line 842 of file stringrenderer.cpp.

844  {
845  *image = nullptr;
846  // Select a suitable font to render the title with.
847  const char kTitleTemplate[] = "%s : %d hits = %.2f%%, raw = %d = %.2f%%";
848  string title_font;
849  if (!FontUtils::SelectFont(kTitleTemplate, strlen(kTitleTemplate),
850  &title_font, nullptr)) {
851  tprintf("WARNING: Could not find a font to render image title with!\n");
852  title_font = "Arial";
853  }
854  title_font += " 8";
855  tlog(1, "Selected title font: %s\n", title_font.c_str());
856  if (font_used) font_used->clear();
857 
858  string orig_font = font_.DescriptionName();
859  if (char_map_.empty()) {
860  total_chars_ = 0;
861  // Fill the hash table and use that for computing which fonts to use.
862  for (UNICHAR::const_iterator it = UNICHAR::begin(text, text_length);
863  it != UNICHAR::end(text, text_length); ++it) {
864  ++total_chars_;
865  ++char_map_[*it];
866  }
867  tprintf("Total chars = %d\n", total_chars_);
868  }
869  const std::vector<string>& all_fonts = FontUtils::ListAvailableFonts();
870  assert(0 <= font_index_);
871  for (unsigned int i = static_cast<unsigned int>(font_index_); i < all_fonts.size(); ++i) {
872  ++font_index_;
873  int raw_score = 0;
874  int ok_chars =
875  FontUtils::FontScore(char_map_, all_fonts[i], &raw_score, nullptr);
876  if (ok_chars > 0 && ok_chars >= total_chars_ * min_coverage) {
877  set_font(all_fonts[i]);
878  int offset = RenderToBinaryImage(text, text_length, 128, image);
879  ClearBoxes(); // Get rid of them as they are garbage.
880  const int kMaxTitleLength = 1024;
881  char title[kMaxTitleLength];
882  snprintf(title, kMaxTitleLength, kTitleTemplate,
883  all_fonts[i].c_str(), ok_chars,
884  100.0 * ok_chars / total_chars_, raw_score,
885  100.0 * raw_score / char_map_.size());
886  tprintf("%s\n", title);
887  // This is a good font! Store the offset to return once we've tried all
888  // the fonts.
889  if (offset) {
891  if (font_used) *font_used = all_fonts[i];
892  }
893  // Add the font to the image.
894  set_font(title_font);
895  v_margin_ /= 8;
896  Pix* title_image = nullptr;
897  RenderToBinaryImage(title, strlen(title), 128, &title_image);
898  pixOr(*image, *image, title_image);
899  pixDestroy(&title_image);
900 
901  v_margin_ *= 8;
902  set_font(orig_font);
903  // We return the real offset only after cycling through the list of fonts.
904  return 0;
905  } else {
906  tprintf("Font %s failed with %d hits = %.2f%%\n",
907  all_fonts[i].c_str(), ok_chars, 100.0 * ok_chars / total_chars_);
908  }
909  }
910  font_index_ = 0;
911  char_map_.clear();
912  return last_offset_ == 0 ? -1 : last_offset_;
913 }
static const_iterator begin(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:200
#define tlog(level,...)
Definition: tlog.h:33
bool set_font(const string &desc)
static const std::vector< string > & ListAvailableFonts()
static int FontScore(const std::unordered_map< char32, inT64 > &ch_map, const string &fontname, int *raw_score, std::vector< bool > *ch_flags)
static const_iterator end(const char *utf8_str, const int byte_length)
Definition: unichar.cpp:204
#define tprintf(...)
Definition: tprintf.h:31
voidpf uLong offset
Definition: ioapi.h:42
static bool SelectFont(const char *utf8_word, const int utf8_len, string *font_name, std::vector< string > *graphemes)
int RenderToBinaryImage(const char *text, int text_length, int threshold, Pix **pix)
std::unordered_map< char32, inT64 > char_map_

◆ RenderToBinaryImage()

int tesseract::StringRenderer::RenderToBinaryImage ( const char *  text,
int  text_length,
int  threshold,
Pix **  pix 
)

Definition at line 661 of file stringrenderer.cpp.

662  {
663  Pix* orig_pix = nullptr;
664  int offset = RenderToImage(text, text_length, &orig_pix);
665  if (orig_pix) {
666  Pix* gray_pix = pixConvertTo8(orig_pix, false);
667  pixDestroy(&orig_pix);
668  *pix = pixThresholdToBinary(gray_pix, threshold);
669  pixDestroy(&gray_pix);
670  } else {
671  *pix = orig_pix;
672  }
673  return offset;
674 }
voidpf uLong offset
Definition: ioapi.h:42
int RenderToImage(const char *text, int text_length, Pix **pix)

◆ RenderToGrayscaleImage()

int tesseract::StringRenderer::RenderToGrayscaleImage ( const char *  text,
int  text_length,
Pix **  pix 
)

Definition at line 650 of file stringrenderer.cpp.

651  {
652  Pix* orig_pix = nullptr;
653  int offset = RenderToImage(text, text_length, &orig_pix);
654  if (orig_pix) {
655  *pix = pixConvertTo8(orig_pix, false);
656  pixDestroy(&orig_pix);
657  }
658  return offset;
659 }
voidpf uLong offset
Definition: ioapi.h:42
int RenderToImage(const char *text, int text_length, Pix **pix)

◆ RenderToImage()

int tesseract::StringRenderer::RenderToImage ( const char *  text,
int  text_length,
Pix **  pix 
)

Definition at line 741 of file stringrenderer.cpp.

742  {
743  if (pix && *pix) pixDestroy(pix);
744  InitPangoCairo();
745 
746  const int page_offset = FindFirstPageBreakOffset(text, text_length);
747  if (!page_offset) {
748  return 0;
749  }
750  start_box_ = boxchars_.size();
751 
752  if (!vertical_text_) {
753  // Translate by the specified margin
754  cairo_translate(cr_, h_margin_, v_margin_);
755  } else {
756  // Vertical text rendering is achieved by a two-step process of first
757  // performing regular horizontal layout with character orientation set to
758  // EAST, and then translating and rotating the layout before rendering onto
759  // the desired image surface. The settings required for the former step are
760  // done within InitPangoCairo().
761  //
762  // Translate to the top-right margin of page
763  cairo_translate(cr_, page_width_ - h_margin_, v_margin_);
764  // Rotate the layout
765  double rotation = - pango_gravity_to_rotation(
766  pango_context_get_base_gravity(pango_layout_get_context(layout_)));
767  tlog(2, "Rotating by %f radians\n", rotation);
768  cairo_rotate(cr_, rotation);
769  pango_cairo_update_layout(cr_, layout_);
770  }
771  string page_text(text, page_offset);
773  // Convert Basic Latin to their fullwidth forms.
774  page_text = ConvertBasicLatinToFullwidthLatin(page_text);
775  }
777  StripUnrenderableWords(&page_text);
778  }
779  if (drop_uncovered_chars_ &&
780  !font_.CoversUTF8Text(page_text.c_str(), page_text.length())) {
781  int num_dropped = font_.DropUncoveredChars(&page_text);
782  if (num_dropped) {
783  tprintf("WARNING: Dropped %d uncovered characters\n", num_dropped);
784  }
785  }
786  if (add_ligatures_) {
787  // Add ligatures wherever possible, including custom ligatures.
788  page_text = LigatureTable::Get()->AddLigatures(page_text, &font_);
789  }
790  if (underline_start_prob_ > 0) {
791  SetWordUnderlineAttributes(page_text);
792  }
793 
794  pango_layout_set_text(layout_, page_text.c_str(), page_text.length());
795 
796  if (pix) {
797  // Set a white background for the target image surface.
798  cairo_set_source_rgb(cr_, 1.0, 1.0, 1.0); // sets drawing colour to white
799  // Fill the surface with the active colour (if you don't do this, you will
800  // be given a surface with a transparent background to draw on)
801  cairo_paint(cr_);
802  // Set the ink color to black
803  cairo_set_source_rgb(cr_, pen_color_[0], pen_color_[1], pen_color_[2]);
804  // If the target surface or transformation properties of the cairo instance
805  // have changed, update the pango layout to reflect this
806  pango_cairo_update_layout(cr_, layout_);
807  {
808  DISABLE_HEAP_LEAK_CHECK; // for Fontconfig
809  // Draw the pango layout onto the cairo surface
810  pango_cairo_show_layout(cr_, layout_);
811  }
813  }
815  FreePangoCairo();
816  // Update internal state variables.
817  ++page_;
818  return page_offset;
819 }
std::vector< BoxChar * > boxchars_
#define tlog(level,...)
Definition: tlog.h:33
int DropUncoveredChars(string *utf8_text) const
Pix * CairoARGB32ToPixFormat(cairo_surface_t *surface)
static string ConvertBasicLatinToFullwidthLatin(const string &text)
#define tprintf(...)
Definition: tprintf.h:31
#define DISABLE_HEAP_LEAK_CHECK
Definition: util.h:63
string AddLigatures(const string &str, const PangoFontInfo *font) const
bool CoversUTF8Text(const char *utf8_text, int byte_length) const
int StripUnrenderableWords(string *utf8_text) const
int FindFirstPageBreakOffset(const char *text, int text_length)
static LigatureTable * Get()
void SetWordUnderlineAttributes(const string &page_text)
cairo_surface_t * surface_

◆ RotatePageBoxes()

void tesseract::StringRenderer::RotatePageBoxes ( float  rotation)

Definition at line 338 of file stringrenderer.cpp.

338  {
339  BoxChar::RotateBoxes(rotation, page_width_ / 2, page_height_ / 2,
340  start_box_, boxchars_.size(), &boxchars_);
341 }
std::vector< BoxChar * > boxchars_
static void RotateBoxes(float rotation, int xcenter, int ycenter, int start_box, int end_box, std::vector< BoxChar *> *boxes)
Definition: boxchar.cpp:273

◆ set_add_ligatures()

void tesseract::StringRenderer::set_add_ligatures ( bool  add_ligatures)
inline

Definition at line 115 of file stringrenderer.h.

115  {
116  add_ligatures_ = add_ligatures;
117  }

◆ set_box_padding()

void tesseract::StringRenderer::set_box_padding ( int  val)
inline

Definition at line 100 of file stringrenderer.h.

100  {
101  box_padding_ = val;
102  }

◆ set_char_spacing()

void tesseract::StringRenderer::set_char_spacing ( double  char_spacing)
inline

Definition at line 67 of file stringrenderer.h.

67  {
68  char_spacing_ = char_spacing;
69  }

◆ set_drop_uncovered_chars()

void tesseract::StringRenderer::set_drop_uncovered_chars ( bool  val)
inline

Definition at line 103 of file stringrenderer.h.

103  {
104  drop_uncovered_chars_ = val;
105  }

◆ set_features()

void tesseract::StringRenderer::set_features ( const char *  features)
inline

Definition at line 93 of file stringrenderer.h.

93  {
94  free(features_);
95  features_ = strdup(features);
96  }
const char features[]
Definition: feature_tests.c:2

◆ set_font()

bool tesseract::StringRenderer::set_font ( const string &  desc)

Definition at line 134 of file stringrenderer.cpp.

134  {
135  bool success = font_.ParseFontDescriptionName(desc);
137  return success;
138 }
void set_resolution(const int resolution)
bool ParseFontDescriptionName(const string &name)

◆ set_gravity_hint_strong()

void tesseract::StringRenderer::set_gravity_hint_strong ( bool  gravity_hint_strong)
inline

Definition at line 77 of file stringrenderer.h.

77  {
78  gravity_hint_strong_ = gravity_hint_strong;
79  }

◆ set_h_margin()

void tesseract::StringRenderer::set_h_margin ( const int  h_margin)
inline

Definition at line 124 of file stringrenderer.h.

124  {
126  }

◆ set_leading()

void tesseract::StringRenderer::set_leading ( int  leading)
inline

Definition at line 70 of file stringrenderer.h.

70  {
71  leading_ = leading;
72  }

◆ set_output_word_boxes()

void tesseract::StringRenderer::set_output_word_boxes ( bool  val)
inline

Definition at line 109 of file stringrenderer.h.

109  {
110  output_word_boxes_ = val;
111  }

◆ set_page()

void tesseract::StringRenderer::set_page ( int  page)
inline

Definition at line 97 of file stringrenderer.h.

97  {
98  page_ = page;
99  }

◆ set_pen_color()

void tesseract::StringRenderer::set_pen_color ( double  r,
double  g,
double  b 
)
inline

Definition at line 119 of file stringrenderer.h.

119  {
120  pen_color_[0] = r;
121  pen_color_[1] = g;
122  pen_color_[2] = b;
123  }

◆ set_render_fullwidth_latin()

void tesseract::StringRenderer::set_render_fullwidth_latin ( bool  render_fullwidth_latin)
inline

Definition at line 80 of file stringrenderer.h.

80  {
81  render_fullwidth_latin_ = render_fullwidth_latin;
82  }

◆ set_resolution()

void tesseract::StringRenderer::set_resolution ( const int  resolution)

Definition at line 140 of file stringrenderer.cpp.

140  {
141  resolution_ = resolution;
142  font_.set_resolution(resolution);
143 }
void set_resolution(const int resolution)

◆ set_strip_unrenderable_words()

void tesseract::StringRenderer::set_strip_unrenderable_words ( bool  val)
inline

Definition at line 106 of file stringrenderer.h.

106  {
108  }

◆ set_underline_continuation_prob()

void tesseract::StringRenderer::set_underline_continuation_prob ( const double  frac)

Definition at line 149 of file stringrenderer.cpp.

149  {
150  underline_continuation_prob_ = min(max(frac, 0.0), 1.0);
151 }
const int max

◆ set_underline_start_prob()

void tesseract::StringRenderer::set_underline_start_prob ( const double  frac)

Definition at line 145 of file stringrenderer.cpp.

145  {
146  underline_start_prob_ = min(max(frac, 0.0), 1.0);
147 }
const int max

◆ set_underline_style()

void tesseract::StringRenderer::set_underline_style ( const PangoUnderline  style)
inline

Definition at line 90 of file stringrenderer.h.

90  {
91  underline_style_ = style;
92  }
PangoUnderline underline_style_

◆ set_v_margin()

void tesseract::StringRenderer::set_v_margin ( const int  v_margin)
inline

Definition at line 127 of file stringrenderer.h.

127  {
129  }

◆ set_vertical_text()

void tesseract::StringRenderer::set_vertical_text ( bool  vertical_text)
inline

Definition at line 74 of file stringrenderer.h.

74  {
75  vertical_text_ = vertical_text;
76  }

◆ SetLayoutProperties()

void tesseract::StringRenderer::SetLayoutProperties ( )
protected

Definition at line 181 of file stringrenderer.cpp.

181  {
182  string font_desc = font_.DescriptionName();
183  // Specify the font via a description name
184  PangoFontDescription *desc =
185  pango_font_description_from_string(font_desc.c_str());
186  // Assign the font description to the layout
187  pango_layout_set_font_description(layout_, desc);
188  pango_font_description_free(desc); // free the description
189  pango_cairo_context_set_resolution(pango_layout_get_context(layout_),
190  resolution_);
191 
192  int max_width = page_width_ - 2 * h_margin_;
193  int max_height = page_height_ - 2 * v_margin_;
194  tlog(3, "max_width = %d, max_height = %d\n", max_width, max_height);
195  if (vertical_text_) {
196  swap(max_width, max_height);
197  }
198  pango_layout_set_width(layout_, max_width * PANGO_SCALE);
199  pango_layout_set_wrap(layout_, PANGO_WRAP_WORD);
200 
201  // Adjust character spacing
202  PangoAttrList* attr_list = pango_attr_list_new();
203  if (char_spacing_) {
204  PangoAttribute* spacing_attr = pango_attr_letter_spacing_new(
205  static_cast<int>(char_spacing_ * PANGO_SCALE + 0.5));
206  spacing_attr->start_index = 0;
207  spacing_attr->end_index = static_cast<guint>(-1);
208  pango_attr_list_change(attr_list, spacing_attr);
209  }
210 #if (PANGO_VERSION_MAJOR == 1 && PANGO_VERSION_MINOR >= 38)
211  if (add_ligatures_) {
212  set_features("liga, clig, dlig, hlig");
213  PangoAttribute* feature_attr = pango_attr_font_features_new(features_);
214  pango_attr_list_change(attr_list, feature_attr);
215  }
216 #endif
217  pango_layout_set_attributes(layout_, attr_list);
218  pango_attr_list_unref(attr_list);
219  // Adjust line spacing
220  if (leading_) {
221  pango_layout_set_spacing(layout_, leading_ * PANGO_SCALE);
222  }
223 }
#define tlog(level,...)
Definition: tlog.h:33
void set_features(const char *features)

◆ SetWordUnderlineAttributes()

void tesseract::StringRenderer::SetWordUnderlineAttributes ( const string &  page_text)
protected

Definition at line 240 of file stringrenderer.cpp.

240  {
241  if (underline_start_prob_ == 0) return;
242  PangoAttrList* attr_list = pango_layout_get_attributes(layout_);
243 
244  const char* text = page_text.c_str();
245  size_t offset = 0;
246  TRand rand;
247  bool started_underline = false;
248  PangoAttribute* und_attr = nullptr;
249 
250  while (offset < page_text.length()) {
251  offset += SpanUTF8Whitespace(text + offset);
252  if (offset == page_text.length()) break;
253 
254  int word_start = offset;
255  int word_len = SpanUTF8NotWhitespace(text + offset);
256  offset += word_len;
257  if (started_underline) {
258  // Should we continue the underline to the next word?
259  if (RandBool(underline_continuation_prob_, &rand)) {
260  // Continue the current underline to this word.
261  und_attr->end_index = word_start + word_len;
262  } else {
263  // Otherwise end the current underline attribute at the end of the
264  // previous word.
265  pango_attr_list_insert(attr_list, und_attr);
266  started_underline = false;
267  und_attr = nullptr;
268  }
269  }
270  if (!started_underline && RandBool(underline_start_prob_, &rand)) {
271  // Start a new underline attribute
272  und_attr = pango_attr_underline_new(underline_style_);
273  und_attr->start_index = word_start;
274  und_attr->end_index = word_start + word_len;
275  started_underline = true;
276  }
277  }
278  // Finish the current underline attribute at the end of the page.
279  if (started_underline) {
280  und_attr->end_index = page_text.length();
281  pango_attr_list_insert(attr_list, und_attr);
282  }
283 }
int SpanUTF8NotWhitespace(const char *text)
Definition: normstrngs.cpp:205
PangoUnderline underline_style_
voidpf uLong offset
Definition: ioapi.h:42
int SpanUTF8Whitespace(const char *text)
Definition: normstrngs.cpp:194

◆ StripUnrenderableWords()

int tesseract::StringRenderer::StripUnrenderableWords ( string *  utf8_text) const

Definition at line 623 of file stringrenderer.cpp.

623  {
624  string output_text;
625  const char* text = utf8_text->c_str();
626  size_t offset = 0;
627  int num_dropped = 0;
628  while (offset < utf8_text->length()) {
629  int space_len = SpanUTF8Whitespace(text + offset);
630  output_text.append(text + offset, space_len);
631  offset += space_len;
632  if (offset == utf8_text->length()) break;
633 
634  int word_len = SpanUTF8NotWhitespace(text + offset);
635  if (font_.CanRenderString(text + offset, word_len)) {
636  output_text.append(text + offset, word_len);
637  } else {
638  ++num_dropped;
639  }
640  offset += word_len;
641  }
642  utf8_text->swap(output_text);
643 
644  if (num_dropped > 0) {
645  tprintf("Stripped %d unrenderable words\n", num_dropped);
646  }
647  return num_dropped;
648 }
int SpanUTF8NotWhitespace(const char *text)
Definition: normstrngs.cpp:205
bool CanRenderString(const char *utf8_word, int len, std::vector< string > *graphemes) const
#define tprintf(...)
Definition: tprintf.h:31
voidpf uLong offset
Definition: ioapi.h:42
int SpanUTF8Whitespace(const char *text)
Definition: normstrngs.cpp:194

◆ v_margin()

int tesseract::StringRenderer::v_margin ( ) const
inline

Definition at line 134 of file stringrenderer.h.

134 { return v_margin_; }

◆ WriteAllBoxes()

void tesseract::StringRenderer::WriteAllBoxes ( const string &  filename)

Definition at line 356 of file stringrenderer.cpp.

356  {
359 }
std::vector< BoxChar * > boxchars_
static void WriteTesseractBoxFile(const string &name, int height, const std::vector< BoxChar *> &boxes)
Definition: boxchar.cpp:294
const char * filename
Definition: ioapi.h:38
static void PrepareToWrite(std::vector< BoxChar *> *boxes)
Definition: boxchar.cpp:66

Member Data Documentation

◆ add_ligatures_

bool tesseract::StringRenderer::add_ligatures_
protected

Definition at line 195 of file stringrenderer.h.

◆ box_padding_

int tesseract::StringRenderer::box_padding_
protected

Definition at line 208 of file stringrenderer.h.

◆ boxchars_

std::vector<BoxChar*> tesseract::StringRenderer::boxchars_
protected

Definition at line 207 of file stringrenderer.h.

◆ char_map_

std::unordered_map<char32, inT64> tesseract::StringRenderer::char_map_
protected

Definition at line 213 of file stringrenderer.h.

◆ char_spacing_

double tesseract::StringRenderer::char_spacing_
protected

Definition at line 183 of file stringrenderer.h.

◆ cr_

cairo_t* tesseract::StringRenderer::cr_
protected

Definition at line 199 of file stringrenderer.h.

◆ drop_uncovered_chars_

bool tesseract::StringRenderer::drop_uncovered_chars_
protected

Definition at line 193 of file stringrenderer.h.

◆ features_

char* tesseract::StringRenderer::features_
protected

Definition at line 191 of file stringrenderer.h.

◆ font_

PangoFontInfo tesseract::StringRenderer::font_
protected

Definition at line 178 of file stringrenderer.h.

◆ font_index_

int tesseract::StringRenderer::font_index_
protected

Definition at line 215 of file stringrenderer.h.

◆ gravity_hint_strong_

bool tesseract::StringRenderer::gravity_hint_strong_
protected

Definition at line 186 of file stringrenderer.h.

◆ h_margin_

int tesseract::StringRenderer::h_margin_
protected

Definition at line 180 of file stringrenderer.h.

◆ last_offset_

int tesseract::StringRenderer::last_offset_
protected

Definition at line 216 of file stringrenderer.h.

◆ layout_

PangoLayout* tesseract::StringRenderer::layout_
protected

Definition at line 200 of file stringrenderer.h.

◆ leading_

int tesseract::StringRenderer::leading_
protected

Definition at line 184 of file stringrenderer.h.

◆ output_word_boxes_

bool tesseract::StringRenderer::output_word_boxes_
protected

Definition at line 196 of file stringrenderer.h.

◆ page_

int tesseract::StringRenderer::page_
protected

Definition at line 204 of file stringrenderer.h.

◆ page_boxes_

Boxa* tesseract::StringRenderer::page_boxes_
protected

Definition at line 210 of file stringrenderer.h.

◆ page_height_

int tesseract::StringRenderer::page_height_
protected

Definition at line 180 of file stringrenderer.h.

◆ page_width_

int tesseract::StringRenderer::page_width_
protected

Definition at line 180 of file stringrenderer.h.

◆ pen_color_

int tesseract::StringRenderer::pen_color_[3]
protected

Definition at line 182 of file stringrenderer.h.

◆ render_fullwidth_latin_

bool tesseract::StringRenderer::render_fullwidth_latin_
protected

Definition at line 187 of file stringrenderer.h.

◆ resolution_

int tesseract::StringRenderer::resolution_
protected

Definition at line 184 of file stringrenderer.h.

◆ start_box_

int tesseract::StringRenderer::start_box_
protected

Definition at line 203 of file stringrenderer.h.

◆ strip_unrenderable_words_

bool tesseract::StringRenderer::strip_unrenderable_words_
protected

Definition at line 194 of file stringrenderer.h.

◆ surface_

cairo_surface_t* tesseract::StringRenderer::surface_
protected

Definition at line 198 of file stringrenderer.h.

◆ total_chars_

int tesseract::StringRenderer::total_chars_
protected

Definition at line 214 of file stringrenderer.h.

◆ underline_continuation_prob_

double tesseract::StringRenderer::underline_continuation_prob_
protected

Definition at line 189 of file stringrenderer.h.

◆ underline_start_prob_

double tesseract::StringRenderer::underline_start_prob_
protected

Definition at line 188 of file stringrenderer.h.

◆ underline_style_

PangoUnderline tesseract::StringRenderer::underline_style_
protected

Definition at line 190 of file stringrenderer.h.

◆ v_margin_

int tesseract::StringRenderer::v_margin_
protected

Definition at line 180 of file stringrenderer.h.

◆ vertical_text_

bool tesseract::StringRenderer::vertical_text_
protected

Definition at line 185 of file stringrenderer.h.


The documentation for this class was generated from the following files: