core-text

How to draw an NSString with an specific height on to an perfectly matching bitmap?

I have an NSString like @"Hello World" and want to convert that into an bitmap with exactly 20 pixels height. The width of the bitmap should match the width of the text. I know there are some NSString UIKit additions that can draw text, but I don't know how to draw the text with an bounding box of exactly 20 pixels height (text fits per...

How do I import a particular custom font weight for the iPad?

Hi, I'm having trouble importing a specific font weight into my iPad project. I've managed to get custom fonts embedded using the info.plist file and referring to them using CTFontCreateWithName, but I'm having trouble now it comes to using a specific font weight. The file is called "UniveConBol.ttf" but in the installed font is just na...

iPhone CoreText: Find the pixel coordinates of a substring

Here's a screenshot of the twitter app for reference: http://screencast.com/t/YmFmYmI4M What I want to do is place a floating pop-over on top of a substring in an NSAttributedString that could span multiple lines. NSAttributedString is a requirement for the project. In the screenshot supplied, you can see that links are background-hig...

How to split long NSString into pages

I have a long NSString I want to display over a couple of pages. But to do this, I need to find out how much text will actually fit on the page. [NSString sizeWithFont: ...] Is not enough, it will just tell me if the text fits in the rectangle or not, if its does not, it will silently truncate the string, but it won't tell me where it ...

How do I find the plain version of a font in Core Text?

I'm using 'CTFontCreateCopyWithSymbolicTraits' to create a 'CTFontRef' with an italic version ('kCTFontItalicTrait'). Is there a way of taking the same italic font and using 'CTFontCreateCopyWithSymbolicTraits' to set it back to the plain version again? Thanks! ...

How can I fake superscript and subscript with Core Text and an Attributed String?

I'm using an NSMutableAttribtuedString in order to build a string with formatting, which I then pass to Core Text to render into a frame. The problem is, that I need to use superscript and subscript. Unless these characters are available in the font (most fonts don't support it), then setting the property kCTSuperscriptAttributeName does...

How to draw images among rich-text with CoreText? (iOS)

I can draw rich-text with Core Text, the problem is placing images flowing with the text. (iOS SDK 4.1) I'm try to drawing some kind of rich-text. Problem is designer placed many icons among text. So the text what I have to draw is something like this: Here is a word <an icon image>, and another words. The image(<another icon>) should...

CTRunDelegateCallbacks and getAscent/getDescent problem. (iOS)

I'm trying to draw rich-text with images in iOS. I succeed, but there is a serious problem. I used CTRunDelegate to initiate space for each images, but the space only defined in horizontal. I could not specify vertical space size. Because getAscent/getDescent callback functions are not working. (getWidth is working.) I used code like de...

Aligning multiple sized text vertical center instead of baseline with Core Text in iOS.

Is it possible to align multiple sized text by bounding center (of each size) instead of baseline? I tried CTRunDelegate feature, but it doesn't work. It was possible with CTRunDelegateCallbacks.getAscent and CTRunDelegateCallbacks.getDescent, but the feature doesn't work. Only CTRunDelegateCallbacks.getWidth worked. I succeed to laying...

How to draw Truncated text with ATSUI.

Hi, How do i draw truncated text with ATSUI?? I have a legacy app which uses QuickDraw API. it uses StringWidth , TruncString and DrawString functions. I could replace the StringWidth and DrawString with ATSUI's ATSUMeasureTextImage and ATSUDrawText. However i could not find a way to truncate a string so that it fits into a rect. I use...

Core text exactly same as UITextView text format?

Hi, I'm trying to set up a CTFrame that exactly matches my UITextView's text format in iPad. First of all, I converted UITextView's text to an attributed string. Then I set up a width and a height of drawing box in which Core Text will draw text. I succeeded to draw text using Core Text, but UITextView and Core Text show slightly differe...

Creating formatted Lines of Text

I need to be able to read text that has been tagged using XML for formatting and display it on the iPad formatted. The one trick is that I need to support footnotes. I need to be able to read source, parse source, create attributed string for source, create lines. Then I need to write lines to either the text or footnotes until the scre...

CoreText: Invalid 'kern' Subtable In CTFont

I am using a custom font applied to a CATextLayer. I am using the tutorial and sample code found here. http://www.freetimestudios.com/2010/09/13/custom-fonts-on-the-ipad-and-ios-4/ However, every so often, I get the following error. Nothing in particular seems to trigger it. Can someone shed some light as to what this means? What to che...