Commit 51054c3a9e4e57d457e659b0b2c929605a257245

Authored by perry.werneck@gmail.com
1 parent c72d7204

Melhorando aproximacao na escala de fontes

Showing 1 changed file with 16 additions and 2 deletions   Show diff stats
src/pw3270/v3270/widget.c
@@ -533,10 +533,24 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig @@ -533,10 +533,24 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig
533 533
534 if(terminal->scaled_fonts) 534 if(terminal->scaled_fonts)
535 { 535 {
536 - double w = ((double)width) / ((double)cols); 536 + double w = ((double) width) / ((double)cols);
537 double h = ((double) height) / ((double) (rows+2)); 537 double h = ((double) height) / ((double) (rows+2));
  538 + double s = w < h ? w : h;
538 539
539 - cairo_set_font_size(cr,w < h ? w : h); 540 + cairo_set_font_size(cr,s);
  541 + cairo_font_extents(cr,&extents);
  542 +
  543 + while( HEIGHT_IN_PIXELS(terminal,(extents.height+extents.descent)) < height && WIDTH_IN_PIXELS(terminal,extents.max_x_advance) < width )
  544 + {
  545 + s += 1.0;
  546 + cairo_set_font_size(cr,s);
  547 + cairo_font_extents(cr,&extents);
  548 + }
  549 +
  550 + s -= 1.0;
  551 +
  552 + cairo_set_font_size(cr,s < 1.0 ? 1.0 : s);
  553 + cairo_font_extents(cr,&extents);
540 } 554 }
541 else 555 else
542 { 556 {