Skip to content

Commit e60318f

Browse files
committed
set PANGOCAIRO_BACKEND=fc to avoid crash; fixes #736
1 parent 3d508a6 commit e60318f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/training/text2image.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
#include "tlog.h"
5151
#include "unicharset.h"
5252
#include "util.h"
53+
#ifdef _MSC_VER
54+
# define putenv(s) _putenv(s)
55+
#endif
5356

5457
// A number with which to initialize the random number generator.
5558
const int kRandomSeed = 0x18273645;
@@ -681,6 +684,18 @@ static int Main() {
681684
}
682685

683686
int main(int argc, char** argv) {
687+
// Respect enviroment variable. could be:
688+
// fc (fontconfig), win32, and coretext
689+
// If not set force fontconfig for Mac OS.
690+
// See https://github.com/tesseract-ocr/tesseract/issues/736
691+
char* backend;
692+
backend = getenv("PANGOCAIRO_BACKEND");
693+
if (backend == NULL) {
694+
putenv("PANGOCAIRO_BACKEND=fc");
695+
} else {
696+
printf("Using '%s' as pango cairo backend based on enviroment "
697+
"variable.\n", backend);
698+
}
684699
tesseract::CheckSharedLibraryVersion();
685700
if (argc > 1) {
686701
if ((strcmp(argv[1], "-v") == 0) ||

0 commit comments

Comments
 (0)