diff options
Diffstat (limited to 'tests/gdimagestringft')
-rw-r--r-- | tests/gdimagestringft/.gitignore | 1 | ||||
-rw-r--r-- | tests/gdimagestringft/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/gdimagestringft/Makemodule.am | 1 | ||||
-rw-r--r-- | tests/gdimagestringft/bug00615.c | 25 | ||||
-rw-r--r-- | tests/gdimagestringft/gdimagestringft_bbox.c | 37 |
5 files changed, 48 insertions, 17 deletions
diff --git a/tests/gdimagestringft/.gitignore b/tests/gdimagestringft/.gitignore index f9f01f0..efe5e61 100644 --- a/tests/gdimagestringft/.gitignore +++ b/tests/gdimagestringft/.gitignore @@ -1 +1,2 @@ +/bug00615 /gdimagestringft_bbox diff --git a/tests/gdimagestringft/CMakeLists.txt b/tests/gdimagestringft/CMakeLists.txt index f46b900..42868a2 100644 --- a/tests/gdimagestringft/CMakeLists.txt +++ b/tests/gdimagestringft/CMakeLists.txt @@ -1,5 +1,6 @@ IF(FREETYPE_FOUND) LIST(APPEND TESTS_FILES + bug00615 gdimagestringft_bbox ) ENDIF(FREETYPE_FOUND) diff --git a/tests/gdimagestringft/Makemodule.am b/tests/gdimagestringft/Makemodule.am index 0dfe26f..a62081f 100644 --- a/tests/gdimagestringft/Makemodule.am +++ b/tests/gdimagestringft/Makemodule.am @@ -1,5 +1,6 @@ if HAVE_LIBFREETYPE libgd_test_programs += \ + gdimagestringft/bug00615 \ gdimagestringft/gdimagestringft_bbox endif diff --git a/tests/gdimagestringft/bug00615.c b/tests/gdimagestringft/bug00615.c new file mode 100644 index 0000000..0da51da --- /dev/null +++ b/tests/gdimagestringft/bug00615.c @@ -0,0 +1,25 @@ +/** + * Test that rendering an empty string does not fail + * + * Rendering an empty string with gdImageStringFT() is not supposed to fail; + * it is just a no-op. + * + * See <https://github.com/libgd/libgd/issues/615> + */ + +#include "gd.h" +#include "gdtest.h" + +int main() +{ + gdImagePtr im = gdImageCreate(100, 100); + + int rect[8]; + int fg = gdImageColorAllocate(im, 255, 255, 255); + char *path = gdTestFilePath("freetype/DejaVuSans.ttf"); + char *res = gdImageStringFT(im, rect, fg, path, 12, 0, 10, 10, ""); + + gdTestAssert(res == NULL); + + return gdNumFailures(); +} diff --git a/tests/gdimagestringft/gdimagestringft_bbox.c b/tests/gdimagestringft/gdimagestringft_bbox.c index 0161ec8..e75248a 100644 --- a/tests/gdimagestringft/gdimagestringft_bbox.c +++ b/tests/gdimagestringft/gdimagestringft_bbox.c @@ -8,22 +8,22 @@ #define DELTA (PI/8) static int EXPECT[16][8] = { - {498, 401, 630, 401, 630, 374, 498, 374}, - {491, 364, 613, 313, 602, 288, 481, 338}, - {470, 332, 563, 239, 544, 219, 451, 312}, - {438, 310, 488, 189, 463, 178, 412, 300}, - {401, 303, 401, 171, 374, 171, 374, 303}, - {365, 310, 314, 188, 289, 199, 339, 320}, - {334, 331, 241, 238, 221, 257, 314, 350}, - {313, 362, 192, 312, 181, 337, 303, 388}, - {306, 398, 174, 398, 174, 425, 306, 425}, - {313, 433, 191, 484, 202, 509, 323, 459}, - {333, 463, 240, 556, 259, 576, 352, 483}, - {363, 484, 313, 605, 338, 616, 389, 494}, - {398, 490, 398, 622, 425, 622, 425, 490}, - {432, 483, 483, 605, 508, 594, 458, 473}, - {461, 464, 554, 557, 574, 538, 481, 445}, - {481, 435, 602, 485, 613, 460, 491, 409}, + {500, 400, 628, 400, 628, 376, 500, 376}, + {492, 362, 611, 312, 601, 290, 483, 339}, + {470, 330, 561, 239, 544, 221, 453, 312}, + {437, 308, 486, 189, 464, 180, 414, 299}, + {400, 301, 400, 173, 376, 173, 376, 301}, + {363, 309, 313, 190, 291, 200, 340, 318}, + {332, 331, 241, 240, 223, 257, 314, 348}, + {311, 363, 192, 314, 183, 336, 302, 386}, + {304, 399, 176, 399, 176, 423, 304, 423}, + {312, 435, 193, 485, 203, 507, 321, 458}, + {333, 465, 242, 556, 259, 574, 350, 483}, + {364, 486, 315, 605, 337, 614, 387, 495}, + {399, 492, 399, 620, 423, 620, 423, 492}, + {434, 484, 484, 603, 506, 593, 457, 475}, + {463, 464, 554, 555, 572, 538, 481, 447}, + {483, 434, 602, 483, 611, 461, 492, 411}, }; int main() @@ -38,6 +38,9 @@ int main() int error = 0; FILE *fp; + /* disable subpixel hinting */ + putenv("FREETYPE_PROPERTIES=truetype:interpreter-version=35"); + path = gdTestFilePath("freetype/DejaVuSans.ttf"); im = gdImageCreate(800, 800); gdImageColorAllocate(im, 0xFF, 0xFF, 0xFF); /* allocate white for background color */ @@ -52,7 +55,7 @@ int main() goto done; } for (j = 0; j < 8; j++) { - if (brect[j] != EXPECT[i][j]) { + if (brect[j] < EXPECT[i][j] - 1 || brect[j] > EXPECT[i][j] + 1) { gdTestErrorMsg("(%d, %d) (%d, %d) (%d, %d) (%d, %d) expected, but (%d, %d) (%d, %d) (%d, %d) (%d, %d)\n", EXPECT[i][0], EXPECT[i][1], EXPECT[i][2], EXPECT[i][3], EXPECT[i][4], EXPECT[i][5], EXPECT[i][6], EXPECT[i][7], |