aboutsummaryrefslogtreecommitdiff
path: root/src/platform/graphics/quartz/Font.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-05-15 14:08:06 +0800
committercrupest <crupest@outlook.com>2022-05-15 14:08:06 +0800
commit8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (patch)
tree77e41cc14264060517c0f7ed95837012afb8342e /src/platform/graphics/quartz/Font.cpp
parent9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752 (diff)
downloadcru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.gz
cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.bz2
cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.zip
...
Diffstat (limited to 'src/platform/graphics/quartz/Font.cpp')
-rw-r--r--src/platform/graphics/quartz/Font.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/platform/graphics/quartz/Font.cpp b/src/platform/graphics/quartz/Font.cpp
new file mode 100644
index 00000000..62052b0a
--- /dev/null
+++ b/src/platform/graphics/quartz/Font.cpp
@@ -0,0 +1,30 @@
+#include "cru/platform/graphics/quartz/Font.h"
+
+#include "cru/platform/osx/Convert.h"
+#include "cru/platform/graphics/quartz/Convert.h"
+#include "cru/platform/graphics/quartz/Resource.h"
+
+namespace cru::platform::graphics::quartz {
+using cru::platform::osx::Convert;
+
+OsxCTFont::OsxCTFont(IGraphicsFactory* graphics_factory, const String& name,
+ float size)
+ : OsxQuartzResource(graphics_factory), name_(name) {
+ CFStringRef n = Convert(name);
+
+ if (name.empty()) {
+ ct_font_ =
+ CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, size, nullptr);
+ } else {
+ ct_font_ = CTFontCreateWithName(n, size, nullptr);
+ }
+ Ensures(ct_font_);
+
+ CFRelease(n);
+}
+
+OsxCTFont::~OsxCTFont() { CFRelease(ct_font_); }
+
+String OsxCTFont::GetFontName() { return name_; }
+float OsxCTFont::GetFontSize() { return CTFontGetSize(ct_font_); }
+} // namespace cru::platform::graphics::quartz