Commit 4032a2e6124313fdef1c44b3d9d0721cacd6e4c3
1 parent
4ccf5c18
Exists in
master
and in
1 other branch
Working on bug related with windows fonts resize.
Showing
1 changed file
with
43 additions
and
5 deletions
Show diff stats
src/terminal/font.c
... | ... | @@ -81,7 +81,6 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, unsigned int width, |
81 | 81 | |
82 | 82 | cairo_select_font_face(cr,terminal->font.family, CAIRO_FONT_SLANT_NORMAL,terminal->font.weight); |
83 | 83 | |
84 | - /* | |
85 | 84 | if(terminal->font.scaled) |
86 | 85 | { |
87 | 86 | |
... | ... | @@ -89,7 +88,36 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, unsigned int width, |
89 | 88 | // double h = ((double) height) / ((double) ((rows + OIA_TOP_MARGIN + 3))); |
90 | 89 | // double s = (w < h) ? w : h; |
91 | 90 | |
92 | - double s = 0.1; | |
91 | + double s = 0; | |
92 | + double selected = 0; | |
93 | + | |
94 | + do | |
95 | + { | |
96 | + selected = s; | |
97 | + | |
98 | + s += 0.5; | |
99 | + cairo_set_font_size(cr,s); | |
100 | + cairo_font_extents(cr,&extents); | |
101 | + | |
102 | + debug("font_size=%lf x_advance=%lf y_advance=%lf font_extents=%u+%u font_height=%u view_height=%u view_width=%u", | |
103 | + s, | |
104 | + extents.max_x_advance, | |
105 | + extents.max_y_advance, | |
106 | + (unsigned int) extents.height, (unsigned int) extents.descent, | |
107 | + VIEW_HEIGTH_FROM_FONT( (unsigned int) (extents.height + extents.descent) ), | |
108 | + height, | |
109 | + VIEW_WIDTH_FROM_FONT(extents.max_x_advance) | |
110 | + ); | |
111 | + | |
112 | + } while( (VIEW_HEIGTH_FROM_FONT( (extents.height+extents.descent) ) < height) && (VIEW_WIDTH_FROM_FONT(extents.max_x_advance) < width) ); | |
113 | + | |
114 | + debug("Selected size=%lf",selected); | |
115 | + | |
116 | + cairo_set_font_size(cr,selected); | |
117 | + cairo_font_extents(cr,&extents); | |
118 | + | |
119 | + | |
120 | + /* | |
93 | 121 | |
94 | 122 | cairo_set_font_size(cr,s); |
95 | 123 | cairo_font_extents(cr,&extents); |
... | ... | @@ -99,15 +127,25 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, unsigned int width, |
99 | 127 | s += 0.5; |
100 | 128 | cairo_set_font_size(cr,s); |
101 | 129 | cairo_font_extents(cr,&extents); |
130 | + | |
131 | + debug("font_size=%lf x_advance=%lf y_advance=%lf font_extents=%u+%u font_height=%u view_height=%u view_width=%u", | |
132 | + s, | |
133 | + extents.max_x_advance, | |
134 | + extents.max_y_advance, | |
135 | + (unsigned int) extents.height, (unsigned int) extents.descent, | |
136 | + VIEW_HEIGTH_FROM_FONT( (unsigned int) (extents.height + extents.descent) ), | |
137 | + height, | |
138 | + VIEW_WIDTH_FROM_FONT(extents.max_x_advance) | |
139 | + ); | |
140 | + | |
102 | 141 | } |
103 | 142 | |
104 | 143 | s -= 0.5; |
144 | + */ | |
105 | 145 | |
106 | - cairo_set_font_size(cr,s < 1.0 ? 1.0 : s); | |
107 | - cairo_font_extents(cr,&extents); | |
108 | 146 | |
109 | 147 | } |
110 | - else */ | |
148 | + else | |
111 | 149 | { |
112 | 150 | static const unsigned int font_size[] = { 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 48, 56, 64, 72 }; |
113 | 151 | size_t f; | ... | ... |