Questions tagged [textkit]

Text Kit is, collectively, a set of classes and protocols in iOS 7's UIKit framework that provide high-quality typographical services.

Text Kit, introduced in iOS 7, is a set of classes and protocols providing high quality typographical services including text layout, storage and display. It also enables direct control of typographical features such as kerning, ligatures, line break behaviour and justification. Text-related UIKit classes in iOS 7 - namely UITextView, UITextField and UILabel - are based on the Text Kit layout engine.

Allowing fine-grained control of fonts and styles through a mechanism Apple calls "Dynamic Type", Text Kit brings a much more refined an detailed system for text-handling to iOS.

272 questions
3
votes
2 answers

NSLayoutManager with an NSTextContainer per paragraph

How do I make an NSLayoutManager that assigns each paragraph in its text to a different NSTextContainer? This would be similar to the multiple page/column usage that is common in TextKit, but each page corresponds to a different paragraph of…
Richard Venable
  • 8,310
  • 3
  • 49
  • 52
3
votes
2 answers

Adding exclusion paths to multiple text views

I'm trying to add multiple exclusion paths to a series of UITextViews laid out successively in a UIScrollView, like so: while (lastRenderedGlyph < self.manager.numberOfGlyphs) { CGRect textViewFrame = CGRectMake(currentXOffset, 10, …
user2709279
  • 353
  • 1
  • 3
  • 15
3
votes
1 answer

How to justify text perfectly on iOS 7

I'm trying to horizontally align text bits with different size and fonts. Here is the result I'd like (made with scribus): You can see that text is horizontally align perfectly (to the pixel). I tried implementing this with a basic UITextView, and…
Raphaël Mor
  • 356
  • 2
  • 14
3
votes
1 answer

change the default font of UIFontTextStyleHeadline

While using Interface builder & iOS7 UIFontTextStyleHeadline I set my headline label to UIFontTextStyleHeadline (I guess it can be done also with the following code:) myHeadlineTextLabel.font = [UIFont…
chewy
  • 8,207
  • 6
  • 42
  • 70
3
votes
2 answers

Letterpress effect for UILabel in iOS 7 SDK

In the WWDC 2013 videos they show that a developer can use a letterpress effect on text. Does anyone have any example code of how to do this/how to do this with a UILabel?
OscarTheGrouch
  • 2,374
  • 4
  • 28
  • 39
2
votes
0 answers

⌥ + ⌦ behaves strangely in a custom UITextInput implementation

I'm working on a crossplatform note taking application, and part of our effort includes building a text editor from the ground up that we can bring to our various platforms. For us, on iOS this means conforming to the UITextInput protocol. The…
Parth Mehrotra
  • 2,712
  • 1
  • 23
  • 31
2
votes
1 answer

Get Glyphs of a character without using fallback font

I'm trying to get CGPath from glyphs for all the fonts available on my iPad, in a few cases the Glyphs are not available for fonts such as "AcademyEngravedLetPlain" which looks like below: My code: let attributes = text.attributes(at: 0,…
Raj Kiran
  • 152
  • 1
  • 9
2
votes
1 answer

UITextView iOS16 - Crash on access to layoutManager property of a textview

The code has been working for serval years. now I am getting crashes when running on iOS 16 and on the layoutManager = textView.layoutManager. It seems the TextKit 1 compatibility mode became active, but it still crashes on some of the textView if…
Amirca
  • 143
  • 1
  • 8
2
votes
2 answers

tracksTextAttachmentViewBounds not working

I want to have a UIView inside of a UITextView. For that I use the new NSTextAttachmentViewProvider class introduced in iOS 15. The views width should always be equal to the width of the UITextView this width should update when, for example, the…
2
votes
1 answer

How to toggle Bold and Italic of UIFont

I'm trying to apply Bold and Italic to selected text in UITextView using textKit in swift. This is the code: let isBold = false if !isActive(modification: .swapBoldWithItalic) || isBold{ storage.setAttributes(attributes, range: range) } else { …
akku
  • 25
  • 7
2
votes
1 answer

(AppKit) Tab insertion inside of NSTextBlock

I'm working on a markdown editor for macOS using AppKit, and have all the basics down and working. I'm using NSTextBlock for the code blocks. One issue I'm encountering however, is that typing a Tab inside of an NSTextBlock, causes the caret to move…
MQumairi
  • 115
  • 2
  • 5
2
votes
1 answer

NSTextBlock backgroundColor is not drawn

I have an NSTextBlock subclass that has a specific backgroundColor set. Now when I add a custom paragraph style to a range of text like this let block = MyTextBlock() block.backgroundColor = myBackgroundColor let pstyle =…
user187676
2
votes
1 answer

Insertion point blink interval in macOS

I am working on an NSTextView subclass and now need to draw text insertion points by myself during the formal NSTextView's insertion point timer stops. I succeed to draw my own, but could not find the way to obtain the time interval for the text…
1024jp
  • 2,058
  • 1
  • 16
  • 25
2
votes
0 answers

TextKit - UILabel with background and spacing

I've been working on something like this. Everything was working fine until I've found out a string input that causes an issue The input string is "This is a long titlessss \n Withssssssss" Basically, it seems like the "long" word fits the space…
ndPPPhz
  • 315
  • 1
  • 15
2
votes
0 answers

How to improve NSTextStorage addAttribute performance

I have a long text (probably usual book like >200 pages) in NSTextStorage. I'm distributing this text for textContainers this way: let textStorageLength = defaultTextStorage?.length ?? 0 while layoutManager!.textContainer(forGlyphAt:…
Vlad Pulichev
  • 3,162
  • 2
  • 20
  • 34