Add font ascent, descent, glyph by ID and new font info

This commit is contained in:
Lukas Dürrenberger committed 2026-10-04 22:10:41 +02:00
1 parent a4c9ecec57
commit 6d7cc360a1
8 files changed
+167 -9

No files matched your search

+1
View File
@@ -49,6 +49,7 @@ add_executable(test-csfml-graphics
Graphics/BlendMode.test.cpp
Graphics/Color.test.cpp
Graphics/CoordinateType.test.cpp
Graphics/Font.test.cpp
Graphics/Image.test.cpp
Graphics/PrimitiveType.test.cpp
Graphics/Rect.test.cpp
+27
View File
@@ -0,0 +1,27 @@
#include <CSFML/Graphics/Font.h>
#include <catch2/catch_test_macros.hpp>
#include <string>
TEST_CASE("[Graphics] sfFont")
{
SECTION("sfFont_createFromFile")
{
CHECK(sfFont_createFromFile("does/not/exist.ttf") == nullptr);
sfFont* font = sfFont_createFromFile("Graphics/tuffy.ttf");
REQUIRE(font != nullptr);
const sfFontInfo info = sfFont_getInfo(font);
CHECK(info.id != 0);
CHECK(std::string(info.family) == "Tuffy");
CHECK(!info.hasVerticalMetrics);
CHECK(sfFont_getAscent(font, 10) > 0);
CHECK(sfFont_getDescent(font, 10) < 0);
CHECK(sfFont_getAscent(font, 20) > sfFont_getAscent(font, 10));
sfFont_destroy(font);
}
}
Binary file not shown.