20 #ifndef TESSERACT_TRAINING_PANGO_FONT_INFO_H_ 21 #define TESSERACT_TRAINING_PANGO_FONT_INFO_H_ 24 #include <unordered_map> 29 #include "pango/pango-font.h" 30 #include "pango/pango.h" 31 #include "pango/pangocairo.h" 79 std::vector<std::string>* graphemes)
const;
87 int* x_bearing,
int* x_advance)
const;
96 const std::string& cache_dir);
114 bool ParseFontDescription(
const PangoFontDescription* desc);
117 PangoFont* ToPangoFont()
const;
120 std::string family_name_;
124 PangoFontDescription* desc_;
134 static std::string fonts_dir_;
137 static std::string cache_dir_;
151 return IsAvailableFont(font_desc,
nullptr);
156 static bool IsAvailableFont(
const char* font_desc, std::string* best_match);
158 static const std::vector<std::string>& ListAvailableFonts();
163 static bool SelectFont(
const char* utf8_word,
const int utf8_len,
164 std::string* font_name, std::vector<std::string>* graphemes);
169 static bool SelectFont(
const char* utf8_word,
const int utf8_len,
170 const std::vector<std::string>& all_fonts,
171 std::string* font_name, std::vector<std::string>* graphemes);
175 static void GetAllRenderableCharacters(std::vector<bool>* unichar_bitmap);
177 static void GetAllRenderableCharacters(
const std::vector<std::string>& font_names,
178 std::vector<bool>* unichar_bitmap);
179 static void GetAllRenderableCharacters(
const std::string& font_name,
180 std::vector<bool>* unichar_bitmap);
191 static std::string BestFonts(
192 const std::unordered_map<char32, int64_t>& ch_map,
193 std::vector<std::pair<
const char*, std::vector<bool> > >* font_flag);
200 static int FontScore(
const std::unordered_map<char32, int64_t>& ch_map,
201 const std::string& fontname,
int* raw_score,
202 std::vector<bool>* ch_flags);
205 static void ReInit();
206 static void PangoFontTypeInfo();
209 static std::vector<std::string> available_fonts_;
213 #endif // TESSERACT_TRAINING_PANGO_FONT_INFO_H_ static bool IsAvailableFont(const char *font_desc)
static void HardInitFontConfig(const std::string &fonts_dir, const std::string &cache_dir)
void set_resolution(const int resolution)
int DropUncoveredChars(std::string *utf8_text) const
bool CanRenderString(const char *utf8_word, int len, std::vector< std::string > *graphemes) const
bool CoversUTF8Text(const char *utf8_text, int byte_length) const
static void SoftInitFontConfig()
bool ParseFontDescriptionName(const std::string &name)
const std::string & family_name() const
std::string DescriptionName() const
bool GetSpacingProperties(const std::string &utf8_char, int *x_bearing, int *x_advance) const
FontTypeEnum font_type() const