diff --git a/include/printer.cpp b/include/printer.cpp index 5eacafcbd..56d184b22 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -2204,25 +2204,30 @@ BOOLEAN XVT_CALLCONV1 calc_font_callback(long data) // Create pint window WINDOW win = xvt_print_create_win(printer().get_printrcd(), "Calcolo font"); - // Set print font - xvt_set_font(win, fd._name, XVT_FS_NONE, fd._size); + if (win != NULL_WIN) + { + long pw, ph, phr, pvr; // Printer width, height, horizontal and vertical resolution + xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, printer().get_printrcd(), &ph, &pw, &pvr, &phr); + + TString test(fd._columns); + test.fill('M', fd._columns); + for (int size = fd._size; size > 0; size--) + { + // Set print font + xvt_set_font(win, fd._name, XVT_FS_NONE, size); - long pw, ph, phr, pvr; // Printer width, height, horizontal and vertical resolution - xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, printer().get_printrcd(), &ph, &pw, &pvr, &phr); - - TString test(fd._columns); - test.fill('M', fd._columns); - for (int size = fd._size; size > 0; size--) - { - const int w = xvt_dwin_get_text_width(win, (char*)(const char*)test, fd._columns); - if (w <= phr) - break; - } - xvt_vobj_destroy(win); - if (size > 0) - fd._size = size; - - return FALSE; + const int w = xvt_dwin_get_text_width(win, (char*)(const char*)test, fd._columns); + if (w <= ph) + break; + } + + if (size > 0) + fd._size = size; + + xvt_vobj_destroy(win); + } + + return win != NULL_WIN; } int TPrinter::calc_font_size(int columns) const