I'm using Core Text to layout text in an UIView but am having troubles with
getting the correct size that the text needs, so I can set the contentSize of
the UIScrollView that it is embedded in. I know it is the wrong size, because
the last line is not showing.
I've done some spitting around,
On 17 May 2013, at 8:38 AM, Koen van der Drift koenvanderdr...@gmail.com
wrote:
CTFramesetterSuggestFrameSizeWithConstraints
I ran into this problem and had to resort to an ad-hoc kludge (though I guess
all kludges are ad-hoc:
lineHeight = CTFontGetSize(self.ctDefaultFont)*1.2;
...
frameSize
Also, I had another app that didn't need the kludge. I don't have time to
experiment, but I think the operative line was:
// boundingRect.size was {columwidth, CGFLOAT_MAX}
suggestion = CTFramesetterSuggestFrameSizeWithConstraints(setter,
Thanks Fritz,
After trying out various values, this worked for me:
CGSize frameSize =
CTFramesetterSuggestFrameSizeWithConstraints(framesetter,
CFRangeMake(0, 0),
On May 17, 2013, at 06:38 , Koen van der Drift koenvanderdr...@gmail.com
wrote:
CGSize frameSize =
CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0,
stringLength), NULL, CGSizeMake(self.bounds.size.width, CGFLOAT_MAX),
fitRange);
self.frame = CGRectMake(0, 0,
I ran into this few years ago and didn't find correct solution. Correct means
nice clean. Ended with adding 1/2 of line height, which causes another issues
like wrong vertical alignment of elements. It was pre NSAttributedString era on
iOS. Height was wrong even if returned width = constrained
On May 17, 2013, at 11:20 , Robert Vojta rob...@tapmates.com wrote:
Height was wrong even if returned width = constrained width.
Once I took proper account of the returned width, I got no more wrong heights.
However, IIRC, there was a separate issue that fractional line heights didn't
work
Thanks all for the insightful responses. In my case I am using a monospaced
font, and everything looks pretty square. The thing I did wrong as it
turned out was that I had a little padding on the top, making my CTView to
slightly shift down, and therefore making the final string disappear.
My
Yep, I saw it as well. But IIRC it was in rare occasions. Rare in my point of
view, because we do use normal alphabet. the problem was in special
characters, emoji, symbols, ... In these times I tried every possible
combination/available method/property/calculation/... without success. Also
On 17/05/2013, at 11:38 PM, Koen van der Drift koenvanderdr...@gmail.com
wrote:
// calculate the size it occupies
CTFramesetterRef framesetter =
CTFramesetterCreateWithAttributedString(attrString);
[]
// draw the string:
[]
CTFramesetterRef framesetter =
10 matches
Mail list logo