diff options
-rw-r--r-- | include/cru/base/Osx.h | 7 | ||||
-rw-r--r-- | include/cru/base/Range.h | 12 | ||||
-rw-r--r-- | src/base/Osx.cpp | 8 | ||||
-rw-r--r-- | src/platform/graphics/quartz/TextLayout.cpp | 2 |
4 files changed, 16 insertions, 13 deletions
diff --git a/include/cru/base/Osx.h b/include/cru/base/Osx.h index 057302c2..6c6d5109 100644 --- a/include/cru/base/Osx.h +++ b/include/cru/base/Osx.h @@ -1,9 +1,12 @@ #pragma once +// TODO: Move This file to platform dir. + #ifndef __APPLE__ #error "This header can only be included on OSX platforms." #endif +#include "Range.h" #include "String.h" #include <CoreFoundation/CoreFoundation.h> @@ -26,6 +29,10 @@ class CFWrapper { } }; +// TODO: Remove "Ref" in name. CFWrapper<CFStringRef> ToCFStringRef(StringView string); String FromCFStringRef(CFStringRef string); + +CFRange ToCFRange(const Range& range); +Range FromCFRange(const CFRange& range); } // namespace cru diff --git a/include/cru/base/Range.h b/include/cru/base/Range.h index ade1979a..edc2ec55 100644 --- a/include/cru/base/Range.h +++ b/include/cru/base/Range.h @@ -1,10 +1,6 @@ #pragma once #include "Base.h" -#ifdef CRU_PLATFORM_OSX -#include <CoreFoundation/CoreFoundation.h> -#endif - namespace cru { struct Range final { constexpr static Range FromTwoSides(Index start, Index end) { @@ -40,14 +36,6 @@ struct Range final { return Range::FromTwoSides(coerce(GetStart()), coerce(GetEnd())); } -#ifdef CRU_PLATFORM_OSX - CFRange ToCFRange() const { return CFRangeMake(this->position, this->count); } - - static Range FromCFRange(const CFRange& range) { - return Range(range.location, range.length); - } -#endif - Index position = 0; Index count = 0; }; diff --git a/src/base/Osx.cpp b/src/base/Osx.cpp index 6b8d0bd9..8dc70598 100644 --- a/src/base/Osx.cpp +++ b/src/base/Osx.cpp @@ -18,4 +18,12 @@ String FromCFStringRef(CFStringRef string) { return result; } + +CFRange ToCFRange(const Range& range) { + return CFRangeMake(range.position, range.count); +} + +Range FromCFRange(const CFRange& range) { + return Range(range.location, range.length); +} } // namespace cru diff --git a/src/platform/graphics/quartz/TextLayout.cpp b/src/platform/graphics/quartz/TextLayout.cpp index 7b3e6da8..1be52c48 100644 --- a/src/platform/graphics/quartz/TextLayout.cpp +++ b/src/platform/graphics/quartz/TextLayout.cpp @@ -406,7 +406,7 @@ std::vector<CGRect> OsxCTTextLayout::DoTextRangeRect( auto line = lines_[i]; auto line_origin = line_origins_[i]; - Range range = Range::FromCFRange(CTLineGetStringRange(line)); + Range range = FromCFRange(CTLineGetStringRange(line)); range = range.CoerceInto(r.GetStart(), r.GetEnd()); if (range.count) { |