From 93e1de1417457f2dbf6262cdd5452dd8767e9b27 Mon Sep 17 00:00:00 2001 From: Liu Date: Sat, 10 Feb 2024 19:16:56 +0800 Subject: [PATCH] fixup! feat(pandagl): calculate baseline position based on Ascender and BBox --- lib/pandagl/src/font/bitmap.c | 12 ++++++++++++ lib/pandagl/src/font/inconsolata.c | 1 + tests/run_tests.c | 2 +- xmake.lua | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/pandagl/src/font/bitmap.c b/lib/pandagl/src/font/bitmap.c index 746cbf202..4a447a278 100644 --- a/lib/pandagl/src/font/bitmap.c +++ b/lib/pandagl/src/font/bitmap.c @@ -94,6 +94,18 @@ int pd_canvas_mix_font_bitmap(pd_canvas_t *graph, pd_pos_t pos, pd_canvas_t write_slot; pd_rect_t r_rect, w_rect; + if (pos.x > 0) { + printf("pos.x\n"); + } + if (pos.y > 0) { + printf("pos.y=%d\n", pos.y); + } + if (pos.x > (int)graph->width) { + printf("width\n"); + } + if (pos.y > (int)graph->height) { + printf("height=%u\n", graph->height); + } if (pos.x > (int)graph->width || pos.y > (int)graph->height) { return -2; } diff --git a/lib/pandagl/src/font/inconsolata.c b/lib/pandagl/src/font/inconsolata.c index 155dc41b4..dc3cc6bae 100644 --- a/lib/pandagl/src/font/inconsolata.c +++ b/lib/pandagl/src/font/inconsolata.c @@ -7599,6 +7599,7 @@ int pd_render_inconsolata_font_bitmap(pd_font_bitmap_t *bmp, unsigned ch, int si bmp->metrics.vert_advance = size; bmp->metrics.bbox_height = size; bmp->metrics.bbox_width = bmp->metrics.hori_advance; + bmp->metrics.ascender = size * 4 / 5; bmp->rows = size; bmp->width = bmp->metrics.hori_advance; bmp->buffer = calloc(bmp->rows * bmp->width, 1); diff --git a/tests/run_tests.c b/tests/run_tests.c index eb40d5c84..55e723ebb 100644 --- a/tests/run_tests.c +++ b/tests/run_tests.c @@ -18,7 +18,7 @@ int main(int argc, char **argv) { - logger_set_level(LOGGER_LEVEL_ERROR); + logger_set_level(LOGGER_LEVEL_ALL); ctest_describe("test settings", test_settings); ctest_describe("test thread", test_thread); ctest_describe("test font load", test_font_load); diff --git a/xmake.lua b/xmake.lua index 5c5b65c27..3bbf3b44d 100644 --- a/xmake.lua +++ b/xmake.lua @@ -63,6 +63,7 @@ target("lcui_tests") table.insert(argv, "valgrind") table.insert(argv, "--leak-check=full") table.insert(argv, "--error-exitcode=42") + table.insert(argv, "--num-callers=20") table.insert(argv, target:targetfile()) os.execv("sudo", argv) end