From e60318f9c0f4ae4c3aa4cb67c893da0bd3b27aa4 Mon Sep 17 00:00:00 2001 From: zdenop Date: Tue, 23 Oct 2018 13:22:38 +0200 Subject: [PATCH] set PANGOCAIRO_BACKEND=fc to avoid crash; fixes #736 --- src/training/text2image.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/training/text2image.cpp b/src/training/text2image.cpp index 1142bb68f6..f1f308d30e 100644 --- a/src/training/text2image.cpp +++ b/src/training/text2image.cpp @@ -50,6 +50,9 @@ #include "tlog.h" #include "unicharset.h" #include "util.h" +#ifdef _MSC_VER +# define putenv(s) _putenv(s) +#endif // A number with which to initialize the random number generator. const int kRandomSeed = 0x18273645; @@ -681,6 +684,18 @@ static int Main() { } int main(int argc, char** argv) { + // Respect enviroment variable. could be: + // fc (fontconfig), win32, and coretext + // If not set force fontconfig for Mac OS. + // See https://github.com/tesseract-ocr/tesseract/issues/736 + char* backend; + backend = getenv("PANGOCAIRO_BACKEND"); + if (backend == NULL) { + putenv("PANGOCAIRO_BACKEND=fc"); + } else { + printf("Using '%s' as pango cairo backend based on enviroment " + "variable.\n", backend); + } tesseract::CheckSharedLibraryVersion(); if (argc > 1) { if ((strcmp(argv[1], "-v") == 0) ||