core-text

Draw underlined / strikethrough text ( MULTILINE STRING ) ?

Hi, I have to draw underlined-multiline text with all types of text alignment. I have searched on forums and got some results like: http://davidjhinson.wordpress.com/2009/11/26/underline-text-on-the-iphone/ http://forums.macrumors.com/showthread.php?t=561572 But all draw text for single line only. while i have multi-line text. The si...

How can you load a font (TTF) from a file using Core Text?

Prior to OSX 10.6, ATSFontActivateFromFileSpecification/ATSFontActivateFromFileReference were available and could be used to load a font from a file. I can't find anything similar in Core Text. ...

Core Text's CTFramesetterSuggestFrameSizeWithConstraints() returns incorrect size everytime

According to the docs, CTFramesetterSuggestFrameSizeWithConstraints () "determines the frame size needed for a string range". Unfortunately the size returned by this function is never accurate. Here is what I am doing: NSAttributedString *string = [[[NSAttributedString alloc] initWithString:@"lorem ipsum" attributes:nil] autorele...

Core Text tutorial

Hi, is there any nice CoreText tutorial for iPad out there? ... I found just few exampes in SDK documentation ... thanks ...

Finding text's bounding rect in Core Text

I'm trying to find the boundaries of a line of text in Core Text. For simplicity, assume it has a single character. At the moment I'm using the following method: line = CTLineCreateWithAttributedString(attrString); rect = CTLineGetImageBounds(line, context); It works most of the times, but for some characters, like math italic d (Unic...

CoreText: Space between lines

Hi, How I can know what is the size between two lines? I'm using CoreText API. ...

OpenType Font Parsing for Pleasure and Profit (anyone understand these damn tables?)

So, this is mainly for fun, I'm poking around and trying to find my way inside a few fonts and i have a few questions i'd reeally appreciate some help on if anyone has done this kind of stuff. cmap table The fonts i am testing with contain several cmap subtables of different formats. I can read them, but i don't understand which i shou...

Rendering a Long Document on iPad

I'm implementing a document viewer with highlighting/annotation capabilities for a custom document format on iPad. The documents are kind of long (100 to 200 pages, if printed on paper) and I've had a hard time finding the right approach. Here are the requirments: 1) Basic rich-text styling: control of left/right margins. Control of fon...

Core Text: counting pages in background thread

Let's say I'm writing text viewer for the iPhone using Core Text. Every time user changes base font size I need to count how many pages (fixed size CGRects) are needed to display the whole NSAttributedString with given font sizes. And I would like to do this in separate NSOperation, so that user does not experience unnecessary UI lags....

How to make a CTRunRef object? (iPhone SDK 4)

There is several CTLineCreate* functions, but I can't find a function which make CTRunRef. ...

Core Text - CFAttributedStringRef - increasing font size

How can i make a new CFAttributedStringRef with increased font-size based on a CFAttributedStringRef i got? In my specific project i would like to dynamically increase the size. If i call CFAttributedStringSetAttribute(...) on the whole string using CTFontRef the string will lose it's formatting and the new will replace all the others ...

Why is this an over-release of CTFrame

Working with some CoreText code on iOS and I am confused as to why this is an overrelease of the CTFrame. I have confirmed it is an over-release but I am baffled because it is created with a create method. for (NSValue *value in [self frameArray]) { CGRect column = [value CGRectValue]; CGMutablePathRef path = CGPathCreateMutable();...

CTFramesetterSuggestFrameSizeWithConstraints sometimes returns incorrect size?

In the code below, CTFramesetterSuggestFrameSizeWithConstraints sometimes returns a CGSize with a height that is not big enough to contain all the text that is being passed into it. I did look at this answer. But in my case the width of the text box needs to be constant. Is there any other/better way to figure out the correct height for ...

How does one interact with a string drawn using UIStringDrawing/CoreText

I am attempting to work on an app that highlights certain key words. For this reason, I am looking at using either CoreText or UIStringDrawing to highlight these words (As in bold/underline/italicize/color) since UITextView doesn't seem to have these facilities (And I haven't had any luck with CATextLayer). In either case I am able to s...

Properly using CoreText

Hey there, I'm having difficulties with adopting the UIKeyInput Protocol with Core Text. I currently have most of it done as posted in the source code, however for some reason it glitches as it types, with incorrect font height for the first letter of each new line, which doesn't really make much sense since it's just drawing whatever is...

CoreText: In any one line is it possible to mix alignment?

Is it possible to mix alignment in Core Text e.g., both kCTRightTextAlignment and kCTLeftTextAlignment I would assume the RightAligned text gets drawn from the right, and the left aligned from the left, but it seems to use whatever alignment is defined first on the line. ...

Configuring conditional code in a subproject

I have a project that has a library subproject that gets imported. I have access to the source code of both the main project and the subproject. The subproject uses Core Text. Because the subproject must be used on pre and post 3.2 applications, Core Text is weak linked and all of the Core Text related code is wrapped in the logic: #...

Core Text availability

Hello. What platforms is Core Text available on from my understanding it is: iPad 3.2 & iPhone 4.0+ Is this correct and it is not available in 3.2+ for iPhone? Thanks James ...

Can I use NSAttributedString in Core Text in iOS?

Hi, I'm trying to work out how to take an NSAttributedString and use it in Core Text on the iPad. I watched one of the WWDC videos (110) which has slides (but no source code) and it describes how to create an NSAttributedString, then just put it into a CTFramesetterRef: CTFontRef helveticaBold = CTFontCreateWithName( CFSTR("Helvetica-B...

How can I render different paragraph styles in Core Text?

Hi, I'm having a difficult time trying to work out how to build a page using Core Text, where I have multiple paragraphs which follow one another, but in different styles. In other words, I would like to have a title paragraph, followed by a subtitle paragraph, followed by several body paragraphs. In HTML terms, this would be: <h1>Som...