core-text

How to reverse the point order of a CGPath

只谈情不闲聊 提交于 2019-12-10 18:38:19
问题 I want to draw a Circle with Letter punched out of it. to do this, I need to stroke the circle clockwise and the letter counterclockwise. That is all good and well, but when I get the letter path using Core Text I can't figure out how to essentially reverse the path. NOT MIRROR or ROTATE or anything...that is straightforward enough. I want the point stroke order to be counterclockwise. it is actually hilariously difficult. I've had entirely too many visual 'off by one' errors. 回答1: About all

Adding hyphens with CFStringGetHyphenationLocationBeforeIndex

北慕城南 提交于 2019-12-10 16:47:23
问题 I'm making a magazine with Core Text and I'm trying to automatically add hyphens to the text. I think I can do this with the function CFStringGetHyphenationLocationBeforeIndex But it's not working and I can't find any examples online. What I'm trying to do is setting up the text and if I find any hyphen position I put a "-" there and replace the text via the accessor so it calls setNeedsDisplay and draws again from scratch. - (void) setTexto:(NSAttributedString *)texto { _texto = texto; if

CoreText font smoothing on a transparent background

空扰寡人 提交于 2019-12-10 15:07:50
问题 I'm trying to render using CoreText (appkit version) on a (semi-) transparent background, and as a result the edges aren't smooth. Searching the web suggests that there's no solution to this problem, however I don't believe it because of one simple observation: if I create a CATextLayer containing the same string then the font is lovely and smooth. I've tried setting the various 'allowed' settings to true and then working through the 16 possibilities that they offer. Some are better than

CGContextShowTextAtPoint and white space

徘徊边缘 提交于 2019-12-10 14:59:34
问题 Why is it that the following code ignores the white-space? UIColor *textColor = [UIColor colorWithRed:153.0/255.0 green:102.0/255.0 blue:51.0/255.0 alpha:1.0]; CGContextSetFillColorWithColor(ctx, [textColor CGColor]); CGContextSelectFont(ctx, "Helvetica Neue Bold" , 14, kCGEncodingMacRoman); CGContextSetTextMatrix(ctx, CGAffineTransformMakeScale(1, -1)); CGContextSetShadowWithColor(ctx, CGSizeMake(0.0, 1.0), 1.0, [[UIColor whiteColor] CGColor]); //CGContextSetAllowsAntialiasing(ctx, YES);

Finding text's bounding rect in Core Text

我怕爱的太早我们不能终老 提交于 2019-12-10 04:08:12
问题 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 (Unicode: 0x1D451) or math italic q (Unicode: 0x1D45E), the width is a bit short. I tried using CTLineGetTypographicBounds() or

NSAttributedString - get font attributes

Deadly 提交于 2019-12-10 01:44:23
问题 I need to get info about my attributed string but can't figure out how. I'm getting this dictionary: 2013-11-04 18:06:10.628 App[1895:60b] { NSColor = "UIDeviceWhiteColorSpace 0.3 1"; NSFont = "<UICTFont: 0x17d8d4c0> font-family: \".HelveticaNeueInterface-MediumP4\"; font-weight: bold; font-style: normal; font-size: 17.00pt"; NSUnderline = 0; } It is easy to check the underline with: [attrs objectForKey:@"NSUnderline"] But how to get info about font like the font-style, font-weight etc.

Accessing OpenType Features in UIKit or CoreText

北战南征 提交于 2019-12-09 17:35:12
问题 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

What is CG Raster Data?

痴心易碎 提交于 2019-12-09 07:41:34
问题 I'm trying to find another memory leak in my code, and I can't seem to figure out what CG Raster Data is. While going through the VM Tracker with automatic snapshots enabled, the CG Raster Data seems to be the only part that increases. These also increase steadily without the allocations increasing. I'm not entirely sure what the CG Raster Data is, nor how I would fix it, but at this point the increasing footprint eventually causes a memory error and crash, so it's not good! I do my own text

Core Text: Render to an Odd Shape

主宰稳场 提交于 2019-12-09 00:57:26
问题 I am trying to render text to a shape that isn't a rectangle. The following code works when I add a rectangular path but not when I add an elliptical path. Ultimately, I'd like to draw to any path (L shape, etc), has anyone had any luck with this? -(void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetTextMatrix(context, CGAffineTransformIdentity); CGMutablePathRef path = CGPathCreateMutable(); float w = 200.0; float h = 300.0; CGRect bounds =

CoreText with multicolumn with image?

瘦欲@ 提交于 2019-12-08 16:39:22
问题 I want to design like below: I am using core text to draw a multicolumn , i can show it up, thats not problem, need to show image as static like image, First three column need to show, the fourth column will show by scrolling horizontal. 1.Need to add hyper link to video url. 2.Need to design like above.. Sample tried with two ways: https://github.com/karthisiva/CoreTextWithImage The content will be html text . 回答1: Instead of using third party, why doesn't you go with these below tutorials: