Skip to content

Commit

Permalink
Remove Foundation usage for CTline and CTFrame associated code in CTT…
Browse files Browse the repository at this point in the history
…ypesetter
  • Loading branch information
msft-Jeyaram committed Apr 12, 2017
1 parent 17f98d2 commit 564655d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Frameworks/CoreText/CTFramesetter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ CTFrameRef CTFramesetterCreateFrame(CTFramesetterRef framesetter, CFRange range,
}

woc::StrongCF<__CTFrame*> ret;
ret =
const_cast<__CTFrame*>(_DWriteGetFrame(static_cast<CFAttributedStringRef>(typesetter->_attributedString.get()), range, frameRect));
ret = const_cast<__CTFrame*>(_DWriteGetFrame(attributedString, range, frameRect));
ret->_path = path;
ret->_frameRect.origin = frameRect.origin;

Expand Down
18 changes: 10 additions & 8 deletions Frameworks/CoreText/CTTypesetter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,20 @@ CTLineRef CTTypesetterCreateLine(CTTypesetterRef typesetter, CFRange stringRange
@Status Interoperable
*/
CTLineRef CTTypesetterCreateLineWithOffset(CTTypesetterRef ts, CFRange range, double offset) {
_CTFrame* frame = _DWriteGetFrame(ts->AttributedString(), range, CGRectMake(offset, 0, FLT_MAX, FLT_MAX));

CTFrameRef frame = _DWriteGetFrame(ts->AttributedString(), range, CGRectMake(offset, 0, FLT_MAX, FLT_MAX));
RETURN_NULL_IF(!frame);
if ([frame->_lines count] != 1) {

CFIndex count = CFArrayGetCount(frame->_lines);
if (count != 1) {
TraceError(TAG,
L"CTTypesetterCreateLineWithOffset - range {%f, %f} did not fit on a single line, instead used %u.",
range.location,
range.length,
[frame->_lines count]);
count);
return nullptr;
}

return static_cast<CTLineRef>([[frame->_lines firstObject] retain]);
return static_cast<CTLineRef>(CFRetain(CFArrayGetValueAtIndex(frame->_lines, 0)));
}

/**
Expand All @@ -99,11 +100,12 @@ CFIndex CTTypesetterSuggestLineBreak(CTTypesetterRef typesetter, CFIndex startIn
@Status Interoperable
*/
CFIndex CTTypesetterSuggestLineBreakWithOffset(CTTypesetterRef typesetter, CFIndex index, double width, double offset) {
_CTFrame* frame = _DWriteGetFrame(typesetter->AttributedString(),
CTFrameRef frame = _DWriteGetFrame(typesetter->AttributedString(),
CFRangeMake(index, CFAttributedStringGetLength(typesetter->AttributedString()) - index),
CGRectMake(offset, 0, width, FLT_MAX));
if ([frame->_lines count] > 0) {
return static_cast<_CTLine*>([frame->_lines firstObject])->_strRange.length;

if (CFArrayGetCount(frame->_lines) > 0) {
return static_cast<_CTLine*>(CFArrayGetValueAtIndex(frame->_lines, 0))->_strRange.length;
}

return 0;
Expand Down

0 comments on commit 564655d

Please sign in to comment.