20 #ifndef TESSERACT_TRAINING_PANGO_FONT_INFO_H_ 21 #define TESSERACT_TRAINING_PANGO_FONT_INFO_H_ 24 #include <unordered_map> 28 #include "commandlineflags.h" 30 #include "pango/pango-font.h" 31 #include "pango/pango.h" 32 #include "pango/pangocairo.h" 35 DECLARE_STRING_PARAM_FLAG(fonts_dir);
36 DECLARE_STRING_PARAM_FLAG(fontconfig_tmpdir);
38 using char32 =
signed int;
83 std::vector<std::string>* graphemes)
const;
91 int* x_bearing,
int* x_advance)
const;
100 const std::string& cache_dir);
155 return IsAvailableFont(font_desc,
nullptr);
160 static bool IsAvailableFont(
const char* font_desc, std::string* best_match);
162 static const std::vector<std::string>& ListAvailableFonts();
167 static bool SelectFont(
const char* utf8_word,
const int utf8_len,
168 std::string* font_name, std::vector<std::string>* graphemes);
173 static bool SelectFont(
const char* utf8_word,
const int utf8_len,
174 const std::vector<std::string>& all_fonts,
175 std::string* font_name, std::vector<std::string>* graphemes);
179 static void GetAllRenderableCharacters(std::vector<bool>* unichar_bitmap);
181 static void GetAllRenderableCharacters(
const std::vector<std::string>& font_names,
182 std::vector<bool>* unichar_bitmap);
183 static void GetAllRenderableCharacters(
const std::string& font_name,
184 std::vector<bool>* unichar_bitmap);
195 static std::string BestFonts(
196 const std::unordered_map<char32, int64_t>& ch_map,
197 std::vector<std::pair<
const char*, std::vector<bool> > >* font_flag);
204 static int FontScore(
const std::unordered_map<char32, int64_t>& ch_map,
205 const std::string& fontname,
int* raw_score,
206 std::vector<bool>* ch_flags);
209 static void ReInit();
210 static void PangoFontTypeInfo();
217 #endif // TESSERACT_TRAINING_PANGO_FONT_INFO_H_ int resolution_
Definition: pango_font_info.h:131
bool ParseFontDescription(const PangoFontDescription *desc)
Definition: pango_font_info.cpp:171
FontTypeEnum
Definition: pango_font_info.h:46
bool CoversUTF8Text(const char *utf8_text, int byte_length) const
Definition: pango_font_info.cpp:218
static std::vector< std::string > available_fonts_
Definition: pango_font_info.h:213
void set_resolution(const int resolution)
Definition: pango_font_info.h:111
int resolution() const
Definition: pango_font_info.h:110
const std::string & family_name() const
Definition: pango_font_info.h:105
PangoFont * ToPangoFont() const
Definition: pango_font_info.cpp:203
bool ParseFontDescriptionName(const std::string &name)
Definition: pango_font_info.cpp:193
static std::string fonts_dir_
Definition: pango_font_info.h:138
FontTypeEnum font_type() const
Definition: pango_font_info.h:108
static bool IsAvailableFont(const char *font_desc)
Definition: pango_font_info.h:154
static std::string cache_dir_
Definition: pango_font_info.h:141
static void HardInitFontConfig(const std::string &fonts_dir, const std::string &cache_dir)
Definition: pango_font_info.cpp:123
Definition: pango_font_info.h:47
int font_size_
Definition: pango_font_info.h:125
Definition: baseapi.cpp:94
static void SoftInitFontConfig()
Definition: pango_font_info.cpp:113
int DropUncoveredChars(std::string *utf8_text) const
Definition: pango_font_info.cpp:261
Definition: pango_font_info.h:48
Definition: pango_font_info.h:44
PangoFontInfo()
Definition: pango_font_info.cpp:76
Definition: pango_font_info.h:150
std::string family_name_
Definition: pango_font_info.h:124
PangoFontDescription * desc_
Definition: pango_font_info.h:128
Definition: pango_font_info.h:49
std::string DescriptionName() const
Definition: pango_font_info.cpp:101
void Clear()
Definition: pango_font_info.cpp:89
void operator=(const PangoFontInfo &)
bool CanRenderString(const char *utf8_word, int len, std::vector< std::string > *graphemes) const
Definition: pango_font_info.cpp:349
bool GetSpacingProperties(const std::string &utf8_char, int *x_bearing, int *x_advance) const
Definition: pango_font_info.cpp:304
Definition: pango_font_info.h:50
int font_size() const
Definition: pango_font_info.h:107
~PangoFontInfo()
Definition: pango_font_info.cpp:99
FontTypeEnum font_type_
Definition: pango_font_info.h:126