aboutsummaryrefslogtreecommitdiff
path: root/demos/platform/graphics
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-09-27 00:24:43 +0800
committerYuqian Yang <crupest@crupest.life>2025-09-27 00:24:43 +0800
commit30910505a7a8e36e6642cbe17134c520000bd583 (patch)
tree035cd76e691560fd6c59b3dd49aef2c09a5042cb /demos/platform/graphics
parent38aca5bc750b0679dd7f2b7bb5e5a0b6f983dd8b (diff)
downloadcru-30910505a7a8e36e6642cbe17134c520000bd583.tar.gz
cru-30910505a7a8e36e6642cbe17134c520000bd583.tar.bz2
cru-30910505a7a8e36e6642cbe17134c520000bd583.zip
Fix pango font rendering.
Diffstat (limited to 'demos/platform/graphics')
-rw-r--r--demos/platform/graphics/CMakeLists.txt3
-rw-r--r--demos/platform/graphics/DrawText.cpp21
2 files changed, 24 insertions, 0 deletions
diff --git a/demos/platform/graphics/CMakeLists.txt b/demos/platform/graphics/CMakeLists.txt
index ff5f64a5..07758ee6 100644
--- a/demos/platform/graphics/CMakeLists.txt
+++ b/demos/platform/graphics/CMakeLists.txt
@@ -5,5 +5,8 @@ target_sources(CruDemoPlatformGraphicsBase INTERFACE Base.cpp)
add_executable(CruDemoPlatformGraphicsDrawCircle DrawCircle.cpp)
target_link_libraries(CruDemoPlatformGraphicsDrawCircle PRIVATE CruDemoPlatformGraphicsBase)
+add_executable(CruDemoPlatformGraphicsDrawText DrawText.cpp)
+target_link_libraries(CruDemoPlatformGraphicsDrawText PRIVATE CruDemoPlatformGraphicsBase)
+
add_executable(CruDemoPlatformGraphicsSvgPath SvgPath.cpp)
target_link_libraries(CruDemoPlatformGraphicsSvgPath PRIVATE CruDemoPlatformGraphicsBase)
diff --git a/demos/platform/graphics/DrawText.cpp b/demos/platform/graphics/DrawText.cpp
new file mode 100644
index 00000000..5de5e127
--- /dev/null
+++ b/demos/platform/graphics/DrawText.cpp
@@ -0,0 +1,21 @@
+#include "Base.h"
+#include "cru/platform/Color.h"
+#include "cru/platform/graphics/Factory.h"
+#include "cru/platform/graphics/Font.h"
+#include "cru/platform/graphics/Painter.h"
+
+#include <memory>
+
+int main() {
+ CruPlatformGraphicsDemo demo("draw-text-demo.png", 500, 200);
+
+ auto brush =
+ demo.GetFactory()->CreateSolidColorBrush(cru::platform::colors::skyblue);
+
+ std::shared_ptr<cru::platform::graphics::IFont> font(
+ demo.GetFactory()->CreateFont(u"", 24));
+ auto text_layout = demo.GetFactory()->CreateTextLayout(font, u"Hello world!");
+ demo.GetPainter()->DrawText({0, 0}, text_layout.get(), brush.get());
+
+ return 0;
+}