From 16007714fc0ad365c6da52dc58201ba4bc6aa964 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 6 Sep 2021 11:52:21 +0800 Subject: ... --- include/cru/osx/graphics/quartz/TextLayout.hpp | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 include/cru/osx/graphics/quartz/TextLayout.hpp (limited to 'include') diff --git a/include/cru/osx/graphics/quartz/TextLayout.hpp b/include/cru/osx/graphics/quartz/TextLayout.hpp new file mode 100644 index 00000000..bfa2aee3 --- /dev/null +++ b/include/cru/osx/graphics/quartz/TextLayout.hpp @@ -0,0 +1,42 @@ +#pragma once +#include +#include "Resource.hpp" + +#include "Font.hpp" +#include "cru/common/Base.hpp" +#include "cru/platform/graphics/TextLayout.hpp" + +namespace cru::platform::graphics::osx::quartz { +class OsxCTTextLayout : public OsxQuartzResource, public virtual ITextLayout { + public: + OsxCTTextLayout(IGraphFactory* graphics_factory, + std::shared_ptr font, const String& str); + + CRU_DELETE_COPY(OsxCTTextLayout) + CRU_DELETE_MOVE(OsxCTTextLayout) + + ~OsxCTTextLayout() override; + + public: + std::u16string GetText() override; + std::u16string_view GetTextView() override; + void SetText(std::u16string new_text) override; + + std::shared_ptr GetFont() override; + void SetFont(std::shared_ptr font) override; + + void SetMaxWidth(float max_width) override; + void SetMaxHeight(float max_height) override; + + Rect GetTextBounds(bool includingTrailingSpace = false) override; + std::vector TextRangeRect(const TextRange& text_range) override; + Point TextSinglePoint(Index position, bool trailing) override; + TextHitTestResult HitTest(const Point& point) override; + + private: + std::shared_ptr font_; + + CTFramesetterRef ct_framesetter_; + CTFrameRef ct_frame_; +}; +} // namespace cru::platform::graphics::osx::quartz -- cgit v1.2.3