29 #ifndef TESSERACT_TRAINING_STRINGRENDERER_H_ 30 #define TESSERACT_TRAINING_STRINGRENDERER_H_ 33 #include <unordered_map> 37 #include "pango_font_info.h" 38 #include "pango/pango-layout.h" 39 #include "pango/pangocairo.h" 45 # define strdup(s) _strdup(s) 54 StringRenderer(
const std::string& font_desc,
int page_width,
int page_height);
60 int RenderToImage(
const char* text,
int text_length, Pix** pix);
68 int text_length, std::string* font_used, Pix** pix);
70 bool set_font(
const std::string& desc);
141 const std::vector<BoxChar*>&
GetBoxes()
const;
227 #endif // THIRD_PARTY_TESSERACT_TRAINING_STRINGRENDERER_H_ ~StringRenderer()
Definition: stringrenderer.cpp:144
void set_resolution(const int resolution)
Definition: stringrenderer.cpp:131
int total_chars_
Definition: stringrenderer.h:217
double pen_color_[3]
Definition: stringrenderer.h:185
bool drop_uncovered_chars_
Definition: stringrenderer.h:196
PangoUnderline underline_style_
Definition: stringrenderer.h:193
void set_underline_start_prob(const double frac)
Definition: stringrenderer.cpp:136
int v_margin_
Definition: stringrenderer.h:183
int page_width_
Definition: stringrenderer.h:183
void SetLayoutProperties()
Definition: stringrenderer.cpp:172
void set_output_word_boxes(bool val)
Definition: stringrenderer.h:112
cairo_t * cr_
Definition: stringrenderer.h:202
void set_v_margin(const int v_margin)
Definition: stringrenderer.h:130
void set_gravity_hint_strong(bool gravity_hint_strong)
Definition: stringrenderer.h:80
void set_add_ligatures(bool add_ligatures)
Definition: stringrenderer.h:118
Boxa * page_boxes_
Definition: stringrenderer.h:213
bool set_font(const std::string &desc)
Definition: stringrenderer.cpp:125
cairo_surface_t * surface_
Definition: stringrenderer.h:201
void RotatePageBoxes(float rotation)
Definition: stringrenderer.cpp:331
bool output_word_boxes_
Definition: stringrenderer.h:199
int RenderToImage(const char *text, int text_length, Pix **pix)
Definition: stringrenderer.cpp:733
int leading_
Definition: stringrenderer.h:187
int box_padding_
Definition: stringrenderer.h:211
int last_offset_
Definition: stringrenderer.h:219
int StripUnrenderableWords(std::string *utf8_text) const
Definition: stringrenderer.cpp:615
static std::string ConvertBasicLatinToFullwidthLatin(const std::string &text)
Definition: stringrenderer.cpp:694
void InitPangoCairo()
Definition: stringrenderer.cpp:150
bool strip_unrenderable_words_
Definition: stringrenderer.h:197
int FindFirstPageBreakOffset(const char *text, int text_length)
Definition: stringrenderer.cpp:279
Definition: baseapi.cpp:94
int page_
Definition: stringrenderer.h:207
int start_box_
Definition: stringrenderer.h:206
void ClearBoxes()
Definition: stringrenderer.cpp:337
void set_pen_color(double r, double g, double b)
Definition: stringrenderer.h:122
void set_page(int page)
Definition: stringrenderer.h:100
void set_drop_uncovered_chars(bool val)
Definition: stringrenderer.h:106
void set_box_padding(int val)
Definition: stringrenderer.h:103
void set_underline_continuation_prob(const double frac)
Definition: stringrenderer.cpp:140
void operator=(const StringRenderer &)
static std::string ConvertFullwidthLatinToBasicLatin(const std::string &text)
Definition: stringrenderer.cpp:714
unsigned int font_index_
Definition: stringrenderer.h:218
void set_render_fullwidth_latin(bool render_fullwidth_latin)
Definition: stringrenderer.h:83
int RenderAllFontsToImage(double min_coverage, const char *text, int text_length, std::string *font_used, Pix **pix)
Definition: stringrenderer.cpp:834
std::string GetBoxesStr()
Definition: stringrenderer.cpp:343
Definition: pango_font_info.h:44
const PangoFontInfo & font() const
Definition: stringrenderer.h:133
void WriteAllBoxes(const std::string &filename)
Definition: stringrenderer.cpp:348
int v_margin() const
Definition: stringrenderer.h:137
void set_features(const char *features)
Definition: stringrenderer.h:96
Boxa * GetPageBoxes() const
Definition: stringrenderer.cpp:327
bool GetClusterStrings(std::vector< std::string > *cluster_text)
Definition: stringrenderer.cpp:354
int h_margin() const
Definition: stringrenderer.h:136
const std::vector< BoxChar * > & GetBoxes() const
Definition: stringrenderer.cpp:323
bool vertical_text_
Definition: stringrenderer.h:188
StringRenderer(const std::string &font_desc, int page_width, int page_height)
Definition: stringrenderer.cpp:90
int page_height_
Definition: stringrenderer.h:183
Definition: stringrenderer.h:52
int resolution_
Definition: stringrenderer.h:187
bool gravity_hint_strong_
Definition: stringrenderer.h:189
void set_char_spacing(int char_spacing)
Definition: stringrenderer.h:72
static std::string InsertWordJoiners(const std::string &text)
Definition: stringrenderer.cpp:671
void FreePangoCairo()
Definition: stringrenderer.cpp:218
void set_vertical_text(bool vertical_text)
Definition: stringrenderer.h:77
double underline_continuation_prob_
Definition: stringrenderer.h:192
int char_spacing_
Definition: stringrenderer.h:186
void set_leading(int leading)
Definition: stringrenderer.h:73
int RenderToGrayscaleImage(const char *text, int text_length, Pix **pix)
Definition: stringrenderer.cpp:642
PangoFontInfo font_
Definition: stringrenderer.h:181
void set_strip_unrenderable_words(bool val)
Definition: stringrenderer.h:109
char * features_
Definition: stringrenderer.h:194
void set_underline_style(const PangoUnderline style)
Definition: stringrenderer.h:93
int RenderToBinaryImage(const char *text, int text_length, int threshold, Pix **pix)
Definition: stringrenderer.cpp:653
void CorrectBoxPositionsToLayout(std::vector< BoxChar *> *boxchars)
Definition: stringrenderer.cpp:602
bool add_ligatures_
Definition: stringrenderer.h:198
bool render_fullwidth_latin_
Definition: stringrenderer.h:190
void set_h_margin(const int h_margin)
Definition: stringrenderer.h:127
std::vector< BoxChar * > boxchars_
Definition: stringrenderer.h:210
void SetWordUnderlineAttributes(const std::string &page_text)
Definition: stringrenderer.cpp:233
void ComputeClusterBoxes()
Definition: stringrenderer.cpp:460
std::unordered_map< char32, int64_t > char_map_
Definition: stringrenderer.h:216
PangoLayout * layout_
Definition: stringrenderer.h:203
double underline_start_prob_
Definition: stringrenderer.h:191
int h_margin_
Definition: stringrenderer.h:183