core-text

Most performant way to draw text on a curve, and animate it?

北慕城南 提交于 2019-11-30 07:29:42
I'm guessing that it's to make a string out of individual CATextLayers and then position them as required along the curve, then animate. Because that's what's I've got working now, but it loses Kerning. Here's how: Why isn't my curved text centering itself? But is Core Text more performant and able to avoid the whole "drawing into a context" nonsense that slows everything down compared to the lean, mean Core Animation way of doing things, and respect kerning? i.e. avoiding drawRect: and all other aspects that greatly slow things down, as in this manner of drawing to the screen: https://github

Inverse UIlabel text color when its frame intersects an UIView

你离开我真会死。 提交于 2019-11-30 07:13:25
Hi Im trying to change the text color of a UILabel in the case when the labels rect intersects an UIView, i was thinking maybe there is a property or something i can use. Like in the image below: Did someone meet this issue before, or what should i read to start doing this thing ? Thanks in advance Good puzzle! Here's what I would do: Two UIViews. Let's call one the background and the other the progressBar. progressBar is stacked on top of background with the same origin on their common superview . They both have a UILabel as subview, and both labels at the same origin relative to their parent

Drop cap with NSAttributedString

为君一笑 提交于 2019-11-30 05:50:28
问题 I would like to do a drop cap first character in a UILabel using the attributedText NSAttributedString property only. Like this: (source: interpretationbydesign.com) I have experimented with adjusting the base line for the range of the first character to a negative value, and it works for aligning the top of the first char with the top of the rest of the first line. But I have not found any way to make the other lines flow to the right of the drop capped character. Can this be solved using

Problems of CTLineGetTypographicBounds

喜夏-厌秋 提交于 2019-11-30 04:58:19
问题 The code is extracted from SimpleTextInput sampe code, with a bit modification. Create the frame: self.font = [UIFont systemFontOfSize:18.f]; CTFontRef ctFont = CTFontCreateWithName((CFStringRef) self.font.fontName, self.font.pointSize, NULL); self.attributes = [[NSDictionary dictionaryWithObject:(id)ctFont forKey:(NSString *)kCTFontAttributeName] retain]; NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:self.text attributes:self.attributes]; _framesetter =

CoreText. How Do I Calculate the Bounding Box of an Attributed String?

穿精又带淫゛_ 提交于 2019-11-30 03:40:25
In CoreText it is easy ask: "for a given rectangle how much of this attributed string will fit?". CTFrameGetVisibleStringRange(rect).length Will return where in the string the next run of text should begin. My question is: "given an attributed string and a width, what rect height do I need to completely bound the attributed string?". Does the CoreText framework provide tools to do this? Thanks, Doug Joshua What you need is CTFramesetterSuggestFrameSizeWithConstraints() , you can use it like so: CTFramesetterRef frameSetter = CTFramesetterCreateWithAttributedString((__bridge

How to stop a time UILabel from resizing at every time increment?

前提是你 提交于 2019-11-30 02:40:41
问题 I have a stopwatch feature in my app that uses a centered attributed UILabel with a proportionally spaced font to render time. At every time increment the width of the label changes, creating a bouncing effect that looks especially bad at fast speeds. Here is an example. How can I fix this? iOS 9 UPDATE It is now a one-liner: UIFont.monospacedDigitSystemFontOfSize(17, weight: UIFontWeightRegular) Also, last time I tried, the solution below did not work for iOS 9. Wasted quite a bit of time

Text/font rendering in OpenGLES 2 (iOS - CoreText?) - options and best practice?

你说的曾经没有我的故事 提交于 2019-11-30 01:53:02
There are many questions on OpenGL font rendering, many of them are satisfied by texture atlases (fast, but wrong), or string-textures (fixed-text only). However, those approaches are poor and appear to be years out of date (what about using shaders to do this better/faster?). For OpenGL 4.1 there's this excellent question looking at "what should you use today ?": What is state-of-the-art for text rendering in OpenGL as of version 4.1? So, what should we be using on iOS GL ES 2 today? I'm disappointed that there appears to be no open-source (or even commercial solution). I know a lot of teams

NSAttributedString highlight/background color shows between lines (ugly)

点点圈 提交于 2019-11-30 01:37:05
问题 I'm trying to nicely display paragraphs of highlighted in a NSTextView. Right now, I'm doing this by creating a NSAttributedString with a background color. Here's some simplified code: NSDictionary *attributes = @{NSBackgroundColorAttributeName:NSColor.greenColor}; NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"Here is a single line of text with single spacing" attributes:attributes]; [textView.textStorage setAttributedString:attrString]; This approach basically

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

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 00:00:00
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. Rob Keniger You can get a CTFontRef from a font file by going via a CGFontRef : CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/path/to/font"), kCFURLPOSIXPathStyle, false); CGDataProviderRef dataProvider = CGDataProviderCreateWithURL(url); CGFontRef theCGFont = CGFontCreateWithDataProvider(dataProvider); CTFontRef theCTFont = CTFontCreateWithGraphicsFont(theCGFont); CFRelease

CTFramesetterSuggestFrameSizeWithConstraints with clipping attributes returning zero height

隐身守侯 提交于 2019-11-29 23:45:29
问题 H! I'm writing a textview with subviews clipping features. The idea is to make all text draw around all subviews. The problem is to get it's content height. Due to the lack of documentation, I decided that the attributes dictionary for CTFramesetterSuggestFrameSizeWithConstraints is the same as for the CTFramesetterCreateFrame. Here is my clipping paths code: -(CFDictionaryRef)clippingPathsDictionary{ if(self.subviews.count==0)return NULL; NSMutableArray *pathsArray = [[NSMutableArray alloc]