calcolo dimensione font (a partire da quella impostata) per stampa 132 col.

git-svn-id: svn://10.65.10.50/trunk@3989 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 1996-12-10 08:54:43 +00:00
parent aa008393bc
commit 41a79a4bb6
2 changed files with 893 additions and 836 deletions

View File

@ -2185,6 +2185,60 @@ const char* TPrinter::background_chars(int l) const
{
return _finker == NULL ? "" : _finker->get_chars(l);
}
///////////////////////////////////////////////////////////
// Calcolo dimensione font
///////////////////////////////////////////////////////////
struct font_data
{
TString _name;
int _size;
int _columns;
};
BOOLEAN XVT_CALLCONV1 calc_font_callback(long data)
{
font_data& fd = *(font_data*)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);
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;
}
if (size > 0)
fd._size = size;
return FALSE;
}
int TPrinter::calc_font_size(int columns) const
{
font_data fd;
fd._name = fontname();
fd._size = get_char_size();
fd._columns = columns;
xvt_print_open();
xvt_print_start_thread(calc_font_callback, (long)&fd);
xvt_print_close();
return fd._size;
}
///////////////////////////////////////////////////////////
// Gestione fax

File diff suppressed because it is too large Load Diff