core-text

How to get text / String from nth line of UILabel?

天大地大妈咪最大 提交于 2019-12-27 12:20:54
问题 Is there an easy way to get (or simply display) the text from a given line in a UILabel? My UILabel is correctly displaying my text and laying it out beautifully but occasionally I need to be able to just show certain lines but obviously I need to know how UILabel has positioned everything to do this. I know this could easily be done with a substring but I'd need to know the start and end point of the line. Alternatively I could scroll the UILabel if there was some kind of offset to the

More time is taken to display NSAttributed string with custom fonts

三世轮回 提交于 2019-12-25 15:56:43
问题 I am displaying NSAttributed string column wise using Core Text. It is working fine. When using system font, it is displayed without any delay both in simulator and device. But when using custom font, more time is taken to display the content in device. But in the simulator, the result is quick. - (void)updateAttributedString { // Existing Code if (self.text != nil) { self.attributedString = [[NSMutableAttributedString alloc] initWithString:self.text]; NSRange range = NSMakeRange(0, [self

NSAttributedString height limited by width and numberOfLines

大兔子大兔子 提交于 2019-12-25 08:29:15
问题 I need to calculate text rect in my custom label not using UILabel's sizeThatFits method. Code below not working correctly. The main idea is find CTLine at index = numberOfLines - 1 and return its max y position. But as a result text height sometimes too large and sometimes not enough to draw last line. - (CGSize)fittingSizeWithSize:(CGSize)size numberOfLines:(NSInteger)numberOfLines { if (numberOfLines == 0) { return [self fittingSizeWithSize:size]; } CTFramesetterRef framesetter =

Am I missing something in Core Text that will let me see which line a certain point is in and how tall a line really is including paragraph styles?

蹲街弑〆低调 提交于 2019-12-25 05:32:53
问题 So I am trying to write a custom NSView with text in it but not using NSTextView (since it will be more than just text). I can use Core Text to draw text, but now I also need to be able to do hit-testing and drawing of the caret and selection rects. The naive way of drawing carets and selections, as shown by various Apple samples, is to get the typographic bounds of the various CTLines encompassing the desired string range (using CTLineGetBoundsWithOptions(0) instead of

CTFrameGetVisibleStringRange Incorrectly Counting Spaces at End of String?

痴心易碎 提交于 2019-12-25 00:30:07
问题 I'm working with CoreText and I notice that CTFrameGetVisibleStringRange incorrectly counts spaces at the end of the string which are NOT visible in the frame as being visible. FYI, I am adding the space as a string @" " using insertAttributedString to the end of my NSMutableAttributedString . Does anyone know how to fix this? UPDATE: Still haven't found a solution to this, is this the intended behavior? Or this just a bug? 回答1: This is a bug. To work around this replace the " " at the end of

Unable to Release Quartz 2D and Core Text created Images

若如初见. 提交于 2019-12-24 21:15:41
问题 I am having a problem deleting my OpenGL ES textures are created via Quartz 2D and Core Text as shown below : - (void)drawText:(CGContextRef)contextP startX:(float)x startY:(float) y withText:(NSString *)standString { CGContextTranslateCTM(contextP, 0, (bottom-top)*2); CGContextScaleCTM(contextP, 1.0, -1.0); CGRect frameText = CGRectMake(1, 0, (right-left)*2, (bottom-top)*2); NSMutableAttributedString * attrString = [[NSMutableAttributedString alloc] initWithString:standString]; [attrString

Core Text glyph placement and em values

ⅰ亾dé卋堺 提交于 2019-12-24 19:11:36
问题 I am trying to draw some musical notes using the Bravura font from http://blog.steinberg.net/2013/05/introducing-bravura-music-font/ using core text functions. A metadata json file accompanying this font has an "attach" coordinate in em unit fractions for where stems should be attached to certain musical notes. This attachment point is relative to a bounding box around the note glyph again with the dimensions in fractions of em unit. My crude ASCII picture shows the attach point of the stem

Using MonoTouch.CoreText to draw text fragments at specific coordinaates

╄→尐↘猪︶ㄣ 提交于 2019-12-24 17:16:51
问题 I am trying to get a grasp of CoreText, working from the example app at http://docs.xamarin.com/recipes/ios/graphics_and_drawing/core_text/draw_unicode_text_with_coretext/ As a test I want to write to write 'N', 'E', 'S' and 'W' on the view in the respective positions. But only the first one (the 'N') gets drawn. Here's my version of TextDrawingView.cs: using System; using System.Drawing; using MonoTouch.UIKit; using MonoTouch.Foundation; using MonoTouch.CoreText; using MonoTouch.CoreGraphics

Get font face from ttf file

醉酒当歌 提交于 2019-12-24 14:01:05
问题 In my iOS app I use custom fonts, dynamically loaded from files. To use them in code, I need to know loaded fonts' families. So, is there any way to do it? UPDATE: I can't somehow hardcode font families, cause my app loads it from server. Of course, there is a way to pass font families in server response, but for now I'm looking for a better version that doesn't influence the server (doesn't need to change it). 回答1: Font loading I did... NSData *fontData = [NSData dataWithContentsOfFile

How to release a CTFramesetter?

不问归期 提交于 2019-12-24 11:12:01
问题 I am using CoreText in my app and i have a really huge leak but i cant fnd out why it happens. so here is the snippet of my code: _framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)_mAttributedString); CFDictionaryRef frameOptionsDictionary = (CFDictionaryRef)[self frameOptionsDictionary]; _frame = CTFramesetterCreateFrame(_framesetter, CFRangeMake(0, _mAttributedString.length), path, frameOptionsDictionary); CFRelease(_framesetter), _framesetter = NULL; As you can