Commit cd3ec12e5f6020bf47197e645f9cb92b4ebcc92c
1 parent
1dd925cd
Exists in
master
and in
1 other branch
Adding subscript chars.
Showing
1 changed file
with
46 additions
and
22 deletions
Show diff stats
src/terminal/drawing/draw.c
@@ -205,32 +205,15 @@ void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, | @@ -205,32 +205,15 @@ void v3270_draw_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, | ||
205 | v3270_draw_text_at(cr,rect->x,rect->y,font,str); | 205 | v3270_draw_text_at(cr,rect->x,rect->y,font,str); |
206 | } | 206 | } |
207 | 207 | ||
208 | -static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, GdkRectangle *rect) | 208 | +static void draw_small_text(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *font, const char *str, int mode) |
209 | { | 209 | { |
210 | - static const struct CharList | ||
211 | - { | ||
212 | - unsigned char chr; | ||
213 | - const gchar * utf; | ||
214 | - } charlist[] = | ||
215 | - { | ||
216 | - { 0x8c, "≤" }, // CG 0xf7, less or equal "≤" | ||
217 | - { 0xae, "≥" }, // CG 0xd9, greater or equal "≥" | ||
218 | - { 0xbe, "≠" }, // CG 0x3e, not equal "≠" | ||
219 | - { 0xad, "[" }, // "[" | ||
220 | - { 0xbd, "]" }, // "]" | ||
221 | - }; | ||
222 | - | ||
223 | - size_t ix; | ||
224 | - | ||
225 | - if(chr >= 0xf0 && chr <= 0xf9) | ||
226 | - { | ||
227 | - char str[] = { '0' + (chr-0xF0), 0 }; | ||
228 | - | ||
229 | cairo_status_t status; | 210 | cairo_status_t status; |
230 | cairo_glyph_t * glyphs = NULL; | 211 | cairo_glyph_t * glyphs = NULL; |
231 | int num_glyphs = 0; | 212 | int num_glyphs = 0; |
232 | cairo_text_cluster_t * clusters = NULL; | 213 | cairo_text_cluster_t * clusters = NULL; |
233 | int num_clusters = 0; | 214 | int num_clusters = 0; |
215 | + double y = (double) rect->y; | ||
216 | + | ||
234 | cairo_text_cluster_flags_t cluster_flags; | 217 | cairo_text_cluster_flags_t cluster_flags; |
235 | cairo_scaled_font_t * scaled_font = cairo_get_scaled_font(cr); | 218 | cairo_scaled_font_t * scaled_font = cairo_get_scaled_font(cr); |
236 | cairo_font_extents_t extents; | 219 | cairo_font_extents_t extents; |
@@ -238,12 +221,21 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | @@ -238,12 +221,21 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | ||
238 | cairo_save(cr); | 221 | cairo_save(cr); |
239 | 222 | ||
240 | cairo_set_font_face(cr,font->face); | 223 | cairo_set_font_face(cr,font->face); |
241 | - cairo_set_font_size(cr,font->size/1.3); | 224 | + cairo_set_font_size(cr,font->size/ 1.6); |
242 | cairo_font_extents(cr,&extents); | 225 | cairo_font_extents(cr,&extents); |
243 | 226 | ||
227 | + if(mode == 0) | ||
228 | + { | ||
229 | + y += ((double) extents.height); | ||
230 | + } | ||
231 | + else | ||
232 | + { | ||
233 | + y += font->height; | ||
234 | + } | ||
235 | + | ||
244 | status = cairo_scaled_font_text_to_glyphs( | 236 | status = cairo_scaled_font_text_to_glyphs( |
245 | scaled_font, | 237 | scaled_font, |
246 | - (double) rect->x, (double) (rect->y+extents.height), | 238 | + (double) rect->x, y, |
247 | str, 1, | 239 | str, 1, |
248 | &glyphs, &num_glyphs, | 240 | &glyphs, &num_glyphs, |
249 | &clusters, &num_clusters, &cluster_flags ); | 241 | &clusters, &num_clusters, &cluster_flags ); |
@@ -260,6 +252,38 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | @@ -260,6 +252,38 @@ static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, Gdk | ||
260 | 252 | ||
261 | cairo_restore(cr); | 253 | cairo_restore(cr); |
262 | 254 | ||
255 | +} | ||
256 | + | ||
257 | +static gboolean draw_cg(cairo_t *cr, unsigned char chr, v3270FontInfo *font, GdkRectangle *rect) | ||
258 | +{ | ||
259 | + static const struct CharList | ||
260 | + { | ||
261 | + unsigned char chr; | ||
262 | + const gchar * utf; | ||
263 | + } charlist[] = | ||
264 | + { | ||
265 | + { 0x8c, "≤" }, // CG 0xf7, less or equal "≤" | ||
266 | + { 0xae, "≥" }, // CG 0xd9, greater or equal "≥" | ||
267 | + { 0xbe, "≠" }, // CG 0x3e, not equal "≠" | ||
268 | + { 0xad, "[" }, // "[" | ||
269 | + { 0xbd, "]" }, // "]" | ||
270 | + { 0xb8, "÷" }, // Division Sign ÷ | ||
271 | + | ||
272 | + }; | ||
273 | + | ||
274 | + size_t ix; | ||
275 | + | ||
276 | + if(chr >= 0xf0 && chr <= 0xf9) | ||
277 | + { | ||
278 | + char str[] = { '0' + (chr-0xF0), 0 }; | ||
279 | + draw_small_text(cr, rect, font, str, 0); | ||
280 | + return TRUE; | ||
281 | + } | ||
282 | + | ||
283 | + if(chr >= 0xe1 && chr <= 0xe3) | ||
284 | + { | ||
285 | + char str[] = { '1' + (chr-0xe1), 0 }; | ||
286 | + draw_small_text(cr, rect, font, str, 1); | ||
263 | return TRUE; | 287 | return TRUE; |
264 | } | 288 | } |
265 | 289 |