core-text

Accessing OpenType Features in UIKit or CoreText

筅森魡賤 提交于 2019-12-04 06:13:54
I am using a custom font in OpenType(.otf) format and would like to use some of the OpenType Features of the font. How can I accomplish this with UIKit or CoreText? I would obviously prefer UIKit, but looking at UIFont , the options are extremely limited. There seems to be a complete absence of documentation regarding OpenType support on iOS, except that the font format can be used. Related reading: Microsoft's reference for OpenType features , and some info on how browsers are beginning to offer OpenType feature support . Though this question is for rendering fonts with OpenType features on

how to set attributes in NSAttributedString in iOS?

∥☆過路亽.° 提交于 2019-12-04 05:32:00
问题 I'm trying to set the infamous NSFontAttributeName property of an NSAttributedString in iOS but it just doesn't seem to work: first off, none of the NS constants seem defined for iOS I read somewhere that I could instead work around it by passing the CoreText consts instead. Fine... but still, The attribute expects an NSFont and I'm stuck with UIFont or CTFontRef, neither of which seems to work: this doesn't work: CTFontRef ctFont = CTFontCreateWithName((CFStringRef)[UIFont

CoreText: Invalid 'kern' Subtable In CTFont

风格不统一 提交于 2019-12-04 02:44:35
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 check for? CoreText: Invalid 'kern' Subtable In CTFont <name: Intellect, size: 20.000000, matrix: 0x0> CTFontDescriptor <attributes: <CFDictionary 0xac07a80 [0x38295d98]>{type = mutable, count = 1, capacity = 3, pairs = ( 0 : <CFString 0x3833f750 [0x38295d98]>

iOS Drawing text in the centre of shapes

断了今生、忘了曾经 提交于 2019-12-04 01:18:41
问题 I'm trying to draw text in the centre of shapes in iOS, an example would be Microsoft Office's insert shape see: https://www.dropbox.com/s/cgqyyuvy6hcv5g8/Screenshot%202014-01-21%2013.48.17.png I have an array of coordinates that are used to form the shape, which works fine for creating the actual shape. My first tactic was following this stackoverflow question: Core Text With Asymmetric Shape on iOS however I can only get it to draw the text at the bottom of the shape. Is there any way to

memory management for CTRunDelegateRef iPhone

你离开我真会死。 提交于 2019-12-03 21:28:51
I focus on a project to add image support based on OmniGroup's rtf editor.I met the problem when I use CTFramesetterCreateWithAttributedString , and it receives EXC_BAD_ACCESS which is caused by a zombie object. For simplicity, I get the NSAttributedString from a rtfd file which only has a photo. I add the method to parser the image tag on iOS based on the Omni's sample. And the part to create the NSAttributedString is followed by this tutorial from raywenderlich , and looks like: CTRunDelegateCallbacks callbacks; callbacks.version = kCTRunDelegateCurrentVersion; callbacks.getAscent =

How to get the real height of text drawn on a CTFrame

梦想与她 提交于 2019-12-03 16:06:06
I have a certain amount of text that fill some CTFrame (more than one). To create all frames (one for each page), I'm filling one frame, getting the text that didn't fitted the frame using CTFrameGetVisibleStringRange and repeating this process until all text is processed. On all frames, except the last, the text occupies the same height of page. On last frame I'd like to know the real height the text occupies, to know where I could start drawing more text. Is there any way to do this? UPDATE As requested on comments, here's my solution using @omz 's suggestion: I'm using ARC on my project:

How to highlight CoreText with changing highlight colors?

℡╲_俬逩灬. 提交于 2019-12-03 13:48:40
问题 I have a subclass of UIView that implements code to draw CoreText. In the application, that UIView is drawn inside a UIScrollView. Here is the code that I currently use in drawRect: to render an NSAttributedString: CGContextRef context = UIGraphicsGetCurrentContext(); float viewHeight = self.bounds.size.height; CGContextTranslateCTM(context, 0, viewHeight); CGContextScaleCTM(context, 1.0, -1.0); CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0, 1.0)); CGMutablePathRef path =

Display NSAttributedString using CoreText

房东的猫 提交于 2019-12-03 13:00:02
问题 I have heard that I can display a NSAttributedString using CoreText, can anyone say me how (The simplest way)? Please, don't answer with CATextLayer or OHAttributedLabel. I know that there are a lot of questions about this in this forum, but I haven't find the answer Thanks!! 回答1: I think that the simplest way (using Core Text) is: // Create the CTLine with the attributed string CTLineRef line = CTLineCreateWithAttributedString(attrString); // Set text position and draw the line into the

CTRunGetImageBounds returning inaccurate results

无人久伴 提交于 2019-12-03 10:16:59
问题 I am using Core Text to draw some text. I would like to get the various run bounds, but when I call CTRunGetImageBounds , the rect that is returned is the correct size, but in the wrong location. Specifically, the line origin is at the end of the text as a whole. - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); self.transform = CGAffineTransformMakeScale(1.0, -1.0); CGContextSetTextMatrix(context, CGAffineTransformIdentity); [[UIColor whiteColor] set];

CGPathRef from string

此生再无相见时 提交于 2019-12-03 10:16:57
问题 Please how can we get path of particular arabic of french letter ? I've just found out that CTFontCreatePathForGlyph will give CGPathRef like, but its will be the outline of text . I need this real text path for showing a text drawing animation.. any help please 回答1: You dont require ur path to be converted into NSString at all. You can create the path for text as follows: CTFontRef font = CTFontCreateWithName(CFSTR("Helvetica-Bold"), 72.0f, NULL); NSDictionary *attrs = [NSDictionary