■ ■ ■ ■ ■ ■
alacritty/src/renderer/text/builtin_font.rs
| skipped 417 lines |
418 | 418 | | |
419 | 419 | | // Ensure that resulted glyph will be visible and also round sizes instead of straight |
420 | 420 | | // flooring them. |
421 | | - | rect_width = cmp::max(rect_width.round() as i32, 1) as f32; |
422 | | - | rect_height = cmp::max(rect_height.round() as i32, 1) as f32; |
| 421 | + | rect_width = rect_width.round().max(1.); |
| 422 | + | rect_height = rect_height.round().max(1.); |
423 | 423 | | |
424 | 424 | | let x = match character { |
425 | 425 | | '\u{2590}' => canvas.x_center(), |
| skipped 16 lines |
442 | 442 | | }, |
443 | 443 | | // Quadrants: '▖', '▗', '▘', '▙', '▚', '▛', '▜', '▝', '▞', '▟'. |
444 | 444 | | '\u{2596}'..='\u{259F}' => { |
| 445 | + | let x_center = canvas.x_center().round().max(1.); |
| 446 | + | let y_center = canvas.y_center().round().max(1.); |
| 447 | + | |
445 | 448 | | let (w_second, h_second) = match character { |
446 | 449 | | '\u{2598}' | '\u{2599}' | '\u{259a}' | '\u{259b}' | '\u{259c}' => { |
447 | | - | (canvas.x_center(), canvas.y_center()) |
| 450 | + | (x_center, y_center) |
448 | 451 | | }, |
449 | 452 | | _ => (0., 0.), |
450 | 453 | | }; |
451 | 454 | | let (w_first, h_first) = match character { |
452 | 455 | | '\u{259b}' | '\u{259c}' | '\u{259d}' | '\u{259e}' | '\u{259f}' => { |
453 | | - | (canvas.x_center(), canvas.y_center()) |
| 456 | + | (x_center, y_center) |
454 | 457 | | }, |
455 | 458 | | _ => (0., 0.), |
456 | 459 | | }; |
457 | 460 | | let (w_third, h_third) = match character { |
458 | 461 | | '\u{2596}' | '\u{2599}' | '\u{259b}' | '\u{259e}' | '\u{259f}' => { |
459 | | - | (canvas.x_center(), canvas.y_center()) |
| 462 | + | (x_center, y_center) |
460 | 463 | | }, |
461 | 464 | | _ => (0., 0.), |
462 | 465 | | }; |
463 | 466 | | let (w_fourth, h_fourth) = match character { |
464 | 467 | | '\u{2597}' | '\u{2599}' | '\u{259a}' | '\u{259c}' | '\u{259f}' => { |
465 | | - | (canvas.x_center(), canvas.y_center()) |
| 468 | + | (x_center, y_center) |
466 | 469 | | }, |
467 | 470 | | _ => (0., 0.), |
468 | 471 | | }; |
| skipped 1 lines |
470 | 473 | | // Second quadrant. |
471 | 474 | | canvas.draw_rect(0., 0., w_second, h_second, COLOR_FILL); |
472 | 475 | | // First quadrant. |
473 | | - | canvas.draw_rect(canvas.x_center(), 0., w_first, h_first, COLOR_FILL); |
| 476 | + | canvas.draw_rect(x_center, 0., w_first, h_first, COLOR_FILL); |
474 | 477 | | // Third quadrant. |
475 | | - | canvas.draw_rect(0., canvas.y_center(), w_third, h_third, COLOR_FILL); |
| 478 | + | canvas.draw_rect(0., y_center, w_third, h_third, COLOR_FILL); |
476 | 479 | | // Fourth quadrant. |
477 | | - | canvas.draw_rect(canvas.x_center(), canvas.y_center(), w_fourth, h_fourth, COLOR_FILL); |
| 480 | + | canvas.draw_rect(x_center, y_center, w_fourth, h_fourth, COLOR_FILL); |
478 | 481 | | }, |
479 | 482 | | _ => unreachable!(), |
480 | 483 | | } |
| skipped 354 lines |