diff --git a/src/training/pango_font_info.cpp b/src/training/pango_font_info.cpp index acc47538..ddc0c6ee 100644 --- a/src/training/pango_font_info.cpp +++ b/src/training/pango_font_info.cpp @@ -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( + font_map)) == CAIRO_FONT_TYPE_TOY) { + printf("Using CAIRO_FONT_TYPE_TOY.\n"); + } else if (pango_cairo_font_map_get_font_type( + reinterpret_cast(font_map)) == + CAIRO_FONT_TYPE_FT) { + printf("Using CAIRO_FONT_TYPE_FT.\n"); + } else if (pango_cairo_font_map_get_font_type( + reinterpret_cast(font_map)) == + CAIRO_FONT_TYPE_WIN32) { + printf("Using CAIRO_FONT_TYPE_WIN32.\n"); + } else if (pango_cairo_font_map_get_font_type( + reinterpret_cast(font_map)) == + CAIRO_FONT_TYPE_QUARTZ) { + printf("Using CAIRO_FONT_TYPE_QUARTZ.\n"); + } else if (pango_cairo_font_map_get_font_type( + reinterpret_cast(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 diff --git a/src/training/pango_font_info.h b/src/training/pango_font_info.h index 5ee585cd..a7a7e0dc 100644 --- a/src/training/pango_font_info.h +++ b/src/training/pango_font_info.h @@ -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 available_fonts_; // cache list diff --git a/src/training/text2image.cpp b/src/training/text2image.cpp index 4c10b47b..1142bb68 100644 --- a/src/training/text2image.cpp +++ b/src/training/text2image.cpp @@ -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(); }