add info about used backend in text2image

This commit is contained in:
zdenop 2018-10-20 21:41:09 +02:00
parent 4aa98ff0d9
commit a033261f63
3 changed files with 35 additions and 0 deletions

View File

@ -768,4 +768,32 @@ bool FontUtils::SelectFont(const char* utf8_word, const int utf8_len,
/* static */
void FontUtils::ReInit() { available_fonts_.clear(); }
// Print info about used font backend
/* static */
void FontUtils::PangoFontTypeInfo() {
PangoFontMap* font_map = pango_cairo_font_map_get_default();
if (pango_cairo_font_map_get_font_type(reinterpret_cast<PangoCairoFontMap*>(
font_map)) == CAIRO_FONT_TYPE_TOY) {
printf("Using CAIRO_FONT_TYPE_TOY.\n");
} else if (pango_cairo_font_map_get_font_type(
reinterpret_cast<PangoCairoFontMap*>(font_map)) ==
CAIRO_FONT_TYPE_FT) {
printf("Using CAIRO_FONT_TYPE_FT.\n");
} else if (pango_cairo_font_map_get_font_type(
reinterpret_cast<PangoCairoFontMap*>(font_map)) ==
CAIRO_FONT_TYPE_WIN32) {
printf("Using CAIRO_FONT_TYPE_WIN32.\n");
} else if (pango_cairo_font_map_get_font_type(
reinterpret_cast<PangoCairoFontMap*>(font_map)) ==
CAIRO_FONT_TYPE_QUARTZ) {
printf("Using CAIRO_FONT_TYPE_QUARTZ.\n");
} else if (pango_cairo_font_map_get_font_type(
reinterpret_cast<PangoCairoFontMap*>(font_map)) ==
CAIRO_FONT_TYPE_USER) {
printf("Using CAIRO_FONT_TYPE_USER.\n");
} else if (!font_map) {
printf("Can not create pango cairo font map!\n");
}
}
} // namespace tesseract

View File

@ -207,6 +207,7 @@ class FontUtils {
// PangoFontInfo is reinitialized, so clear the static list of fonts.
static void ReInit();
static void PangoFontTypeInfo();
private:
static std::vector<std::string> available_fonts_; // cache list

View File

@ -682,6 +682,12 @@ static int Main() {
int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion();
if (argc > 1) {
if ((strcmp(argv[1], "-v") == 0) ||
(strcmp(argv[1], "--version") == 0)) {
FontUtils::PangoFontTypeInfo();
}
}
tesseract::ParseCommandLineFlags(argv[0], &argc, &argv, true);
return Main();
}