Commit 21824db0f14e9f081615ff39ca3ad4c85a3da678
1 parent
4aa1a1f9
Exists in
master
and in
1 other branch
Melhorando aproximacao na escala de fontes
Showing
1 changed file
with
16 additions
and
2 deletions
Show diff stats
widget.c
| ... | ... | @@ -533,10 +533,24 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig |
| 533 | 533 | |
| 534 | 534 | if(terminal->scaled_fonts) |
| 535 | 535 | { |
| 536 | - double w = ((double)width) / ((double)cols); | |
| 536 | + double w = ((double) width) / ((double)cols); | |
| 537 | 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 | 555 | else |
| 542 | 556 | { | ... | ... |