CTFramesetterCreateFrame and kCTParagraphStyleSpecifierFirstLineHeadIndent

21 views Asked by At

I have a receipt of say 200x200px. I want to write inside a text using CTFramesetterCreateFrame and kCTParagraphStyleSpecifierFirstLineHeadIndent. the big problem is that if I want for example to write this is the text with kCTParagraphStyleSpecifierFirstLineHeadIndent = 198 then I will have :

               t
his is the text

the CTFramesetterCreateFrame cut the word this ... i want instead to have

                .
this is the text

how do?

1

There are 1 answers

0
AudioBubble On

The concise change you need to make to your existing code:

CGFloat indent = 198.0; // Adjust this value as needed
// Adjust the rect width to accommodate for the indent
CGRect adjustedRect = CGRectMake(rect.origin.x + indent, rect.origin.y, rect.size.width - indent, rect.size.height);

This change ensures that the first line of text is not cut off when using CTFramesetterCreateFrame with a specified first-line head indent. Adjust the indent value as needed to achieve the desired result.