Fix failing test

This commit is contained in:
Kovid Goyal 2025-02-18 18:44:57 +05:30
parent 45d931f61c
commit 6f57537f30
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 4 deletions

View file

@ -179,7 +179,7 @@ ensure_canvas_can_fit(FontGroup *fg, unsigned cells, unsigned scale) {
size_in_bytes = (sizeof(fg->canvas.alpha_mask[0]) * SUPERSAMPLE_FACTOR * SUPERSAMPLE_FACTOR * 2 * fg->fcm.cell_width * fg->fcm.cell_height * scale * scale);
if (size_in_bytes > fg->canvas.alpha_mask_sz_in_bytes) {
fg->canvas.alpha_mask_sz_in_bytes = size_in_bytes;
fg->canvas.alpha_mask = malloc(fg->canvas.alpha_mask_sz_in_bytes * sizeof(fg->canvas.alpha_mask[0]));
fg->canvas.alpha_mask = malloc(fg->canvas.alpha_mask_sz_in_bytes);
if (!fg->canvas.alpha_mask) fatal("Out of memory allocating canvas");
}
}
@ -837,7 +837,7 @@ effective_scale(RunFont rf) {
static float
scaled_cell_dimensions(RunFont rf, unsigned *width, unsigned *height) {
float frac = MAX(effective_scale(rf), 4.0f / *width);
float frac = MAX(effective_scale(rf), MIN(4.f, (float)*width) / *width);
*width = (unsigned)ceilf(frac * *width);
*height = (unsigned)ceilf(frac * *height);
return frac;
@ -1053,11 +1053,12 @@ render_box_cell(FontGroup *fg, RunFont rf, CPUCell *cpu_cell, GPUCell *gpu_cell,
return;
}
float scale = apply_scale_to_font_group(fg, &rf);
ensure_canvas_can_fit(fg, num_glyphs + 1, rf.scale);
FontCellMetrics scaled_metrics = fg->fcm;
unsigned width = fg->fcm.cell_width, height = fg->fcm.cell_height;
if (scale != 1) apply_scale_to_font_group(fg, NULL);
uint8_t *alpha_mask = NULL;
ensure_canvas_can_fit(fg, num_glyphs + 1, rf.scale);
ensure_canvas_can_fit(fg, num_glyphs + 1, rf.scale); // in case size is larger scale is larger
if (num_glyphs == 1) {
render_box_char(ch, fg->canvas.alpha_mask, width, height, fg->logical_dpi_x, fg->logical_dpi_y, scale);
alpha_mask = fg->canvas.alpha_mask;

View file

@ -251,7 +251,7 @@ def block_helpers(s, sprites, cell_width, cell_height):
class FontBaseTest(BaseTest):
font_size = 5.0
font_size = 16.0
dpi = 72.
font_name = 'FiraCode-Medium.otf'