Skip to content

Commit

Permalink
add info about used backend in text2image
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Oct 20, 2018
1 parent 4aa98ff commit a033261
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/training/pango_font_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/training/pango_font_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/training/text2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit a033261

Please sign in to comment.