blob: 12a8aa7f9f9e773eeaaf9f4b508f47aeb3dc7772 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  | 
#include "cru/platform/graphics/quartz/Font.h"
#include "cru/base/Osx.h"
#include "cru/platform/graphics/quartz/Resource.h"
namespace cru::platform::graphics::quartz {
OsxCTFont::OsxCTFont(IGraphicsFactory* graphics_factory,
                     const std::string& name, float size)
    : OsxQuartzResource(graphics_factory), name_(name) {
  auto n = ToCFString(name);
  if (name.empty()) {
    ct_font_ =
        CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, size, nullptr);
  } else {
    ct_font_ = CTFontCreateWithName(n.ref, size, nullptr);
  }
  Ensures(ct_font_);
}
OsxCTFont::~OsxCTFont() { CFRelease(ct_font_); }
std::string OsxCTFont::GetFontName() { return name_; }
float OsxCTFont::GetFontSize() { return CTFontGetSize(ct_font_); }
}  // namespace cru::platform::graphics::quartz
 
  |