core-text

Cannot convert value of type 'CFString' to expected argument type 'UnsafePointer<Void>' (aka 'UnsafePointer<()>')

霸气de小男生 提交于 2019-12-24 00:59:40
问题 I am getting a build error, when I define the line let runFont : CTFontRef = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName) And the error is: Cannot convert value of type 'CFString' to expected argument type 'UnsafePointer' (aka 'UnsafePointer<()>') 回答1: Try let runFont = unsafeBitCast(CFDictionaryGetValue(CTRunGetAttributes(run), unsafeBitCast(kCTFontAttributeName, UnsafePointer<Void>.self)), CTFontRef.self) 回答2: Swift 3 version of @vadian answer: let runFont =

NSAttributedString initWithData:options:documentAttributes:error: painfully slow

孤街浪徒 提交于 2019-12-23 20:46:28
问题 I'm using those line of codes to create an attributed string from a simple HTML string: NSDictionary *importParams = @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding) }; NSError *error = nil; NSData *stringData = [HTML dataUsingEncoding:NSUTF8StringEncoding] ; NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:stringData options:importParams documentAttributes:NULL error:&error]; The issue is

emoji not being displayed, weird characters instead

本小妞迷上赌 提交于 2019-12-23 20:19:08
问题 I'm trying to display an emoji (ascii #55357) in CoreText and this is what I'm getting: It displays two of these characters and inserts the cursor in the middle. I'm not going to include my CoreText code because it's such a mess and I have no idea where the bug is originating from, but what I was just curious has anyone else seen the same problem before in any facet of iOS and what is the meaning of these sort of A in a black and white box characters that got displayed? Does it mean invalid

Adding outline/stroke to UITextView

北城以北 提交于 2019-12-23 10:06:10
问题 I want to add an outline or stroke to an editable UITextView text as the user types. Exactly like memes : http://t.qkme.me/3oi5rs.jpg I have to use a UITextView since I need multi line support. I have tried all the approaches and reached the conclusion that I must use CoreText . I got almost all of the solution working but got stuck at a point where the text in textview wraps. My drawRect routine in the subview of UITextView correctly draws the outline text until the text wraps. Even when the

Get bounding rectangle for CGGlyphs of Characters other then letters or numbers

二次信任 提交于 2019-12-23 08:16:29
问题 I am looking for a way to equire character's glyph descent as indicated on the picture: The method needs to work for any given character (or at least all common unicode characters). Here is my actual approach (in Swift, inspired by this and this question): let char = "a" let ctFont = CTFontCreateWithNameAndOptions("HelveticaNeue", 12, nil, nil) var ctGlyph = CTFontGetGlyphWithName(ctFont, char) let boundingBox = withUnsafePointer(&ctGlyph) { pointer -> CGRect in return

Selection of text in core text like ibook

人走茶凉 提交于 2019-12-23 06:05:30
问题 i done a bible application which uses core text for showing verses in a view...the txt came from locally stored sqlite db,,,i am using this core text wrapper for rendering my text,,,becz it support multi column view ,,core text warpper,,,but i need the selection of verse functionality...if the user tap the verse it need to select that particular verse,,if i have this verse 1 The God create Heave and earth . 2 etc etc,,, . 3 etc etc,,,, . when the user tap the first verse it need to select

Core Text paragraph inside a UIScrollView is blurry

旧巷老猫 提交于 2019-12-23 03:22:16
问题 I tried drawing a long paragraph as an NSAttributedString in a view inside a UIScrollView. Weird thing is, the top of the paragraph is not blurry, but the more I scroll to the bottom the blurrier it gets ! I am well aware of the small issues you can have with Quartz and floats, therefore I tried to set the frame of the view 0.5 points below. Now the top of my paragraph is blurry, and the bottom is OK (!) I really don't know how to fix this, and would appreciate any help ! Thank you ! 回答1:

How to change color of a word in UITextView?

此生再无相见时 提交于 2019-12-23 03:11:23
问题 Is it possible to change UITextView`s color in particular range or particular word? If a word appear more than once in a view then change the color of that word. 回答1: You'll need to use NSAttributedString . I recommend checking out AliSoftware's OHAttributedLabel which extends UILabel and adds support for setting text via NSAttributedString among other helpers. I'm using it in a current project and it's pretty fantastic. 回答2: I solve the problem. I created subclass of UILable and UITextView

Draw a border around a part of NSAttributedString

回眸只為那壹抹淺笑 提交于 2019-12-23 01:52:28
问题 I'm developing a MacOs application and have to implement my own search functional due to custom interface. So the question is - how can a draw a border around a part of NSAttributedString in NSTextView to display search result (just how it's done in TextEdit app). Please check the desired look on the attached image: http://d.pr/i/w8wP [UPDATE] Due to custom interface requirements I can't use NSTextViews's setUsesFindBar: and setUsesFindPanel: . The interface has a custom NSSearchField, which

kCGTextStroke's Fill and Stroke aren't positioned correctly

被刻印的时光 ゝ 提交于 2019-12-22 11:37:34
问题 So I'm using the code below to apply a stroke (and fill) to text in a UILabel , and it's coming out like the image below. The stroke is heavier on one side than the other (look at the top of the letters compared to the bottom, and the right compared to the left. The period at the end makes it very noticeable, too, looks like a googly eye). I've not got any shadowing turned on at all, so I don't think it's the shadow interfering with the stroke. What could be causing this? - (void)