Core Text

RSS for tag

Create text layouts, optimize font handling, and access font metrics and glyph data using Core Text.

Core Text Documentation

Posts under Core Text tag

27 Posts
Sort by:
Post not yet marked as solved
1 Replies
29 Views
Hi, I am wondering if the section a) Mac OS encodings for script code 0, smRoman miss Japanese at: http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt Same thing here: https://developer.apple.com/documentation/coreservices/1399980-afp_text_encodings There is no mention about Shift-JIS when the platformID is 1, platEncID is 0 and the langage is 11 :  I am asking the question because I have this font (I do not own the font. It is purely a demonstration): https://mega.nz/file/S9ERDRpQ#bcPhS06kv-D5jt64aTNDbZVd6gZr6ZfJDYT91yYsoWk The font has this sfnt name:     <namerecord nameID="1" platformID="1" platEncID="0" langID="0xb">       FjÉCÅ[É}310     </namerecord> If I use mac_roman to decode this font name (which seems to be the choice when by default), I will not get the right result, but if I use the encoding mac Shift-JIS, I get Fjイーマ310. If my question is not clear, don't hesitate to get back to me PS: Sorry, I did not know what I should wrote in the tags section
Posted
by
Post not yet marked as solved
0 Replies
55 Views
CoreText TBMPDataCache::GetDataForCharacter(unsigned int) const + 64 1 CoreText TBMPDataCache::GetDataForCharacter(unsigned int) const + 24 2 CoreText TUnicodeEncoder::Encode(__CTFont const*, TCharStreamIterator&, CFRange, unsigned short*, double*, unsigned int*, double*, bool) + 612 3 CoreText TGlyphEncoder::RunUnicodeEncoderRecursively(unsigned int, TCFRef<CTRun*>&&, __CTFont const*, CFRange, TInlineVector<long, 30ul>&, TGlyphEncoder::Fallbacks, TFontCascade const*, __CFString const*, TGlyphEncoder::ClusterMatching, bool) + 484 4 CoreText TGlyphEncoder::EncodeChars(CFRange, TAttributes const&, TGlyphEncoder::Fallbacks) + 1152 5 CoreText TTypesetterAttrString::Initialize(__CFAttributedString const*) + 388 6 CoreText TTypesetterAttrString::TTypesetterAttrString(__CFAttributedString const*, __CFDictionary const*) + 160 7 CoreText _CTLineCreateWithAttributedString + 132 8 UIFoundation ___NSCoreTypesetterCreateBaseLineFromAttributedString + 344 9 UIFoundation -[NSCoreTypesetter _stringDrawingCoreTextEngineWithOriginalString:rect:padding:graphicsContext:forceClipping:attributes:stringDrawingOptions:drawingContext:stringDrawingInterface:] + 2164
Posted
by
Post not yet marked as solved
0 Replies
99 Views
Is there a simple way to create an NSFontCollection based on NSFontDescriptor querying to gather all installed/available fonts with a MATH table? It doesn't look like there's an attribute for that, but I don't know how else to search other than correlating with features like ssty, dtls, and flac.
Posted
by
Post marked as solved
1 Replies
219 Views
It's a simple question. I'm just trying to understand how these things fit together. Core Text doesn't seem to get updated much, but maybe that's because it's low level and doesn't need it. I assume it's still the recommended way to do low-level text things not handled by TextKit. ?
Posted
by
Post not yet marked as solved
2 Replies
179 Views
Hi, I would like to know if it would be possible to share me the algorithm how CoreText pick the the family name, full name, etc in the naming table https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids for TrueType and OpenType Font. If this can help you understand what kind of information I am looking for, here is FontConfig algorithm: Sort naming table in ASC in this platformID, nameID, platEncID, isEnglish(), langID isEnglish() is a method that return True if the name = {platformID: 1, langID: 0} or {platformID: 3, langID: 0x409} Split the naming table in table that only contain one type of platformID. Finally, search nameID the user want in that order: MICROSOFT, APPLE, MACINTOSH, ISO and that the first match. Or, if you prefer code example, here is FontConfig algorithm in python: https://github.com/moi15moi/fonttools/blob/add-strategy-naming-table/Lib/fontTools/ttLib/tables/sortNamesStrategy/FontConfigStrategy.py Why do I want to know that? I would like to implement the way the way CoreText picks up the name in fonttools. Here is where I discuss about it: https://github.com/fonttools/fonttools/pull/2636 Thank you
Posted
by
Post not yet marked as solved
1 Replies
169 Views
Hi, The following code allow to build an image from an UILabel: let label = UILabel() label.text = "test content" label.backgroundColor = .white label.layer.cornerRadius = 10 label.layer.masksToBounds = true label.sizeToFit() let format = UIGraphicsImageRendererFormat() format.scale = 5 let renderer = UIGraphicsImageRenderer(bounds: label.bounds, format:format) let image: UIImage? = renderer.image { rendererContext in label.layer.render(in: rendererContext.cgContext) } This works perfectly on iOS but on Mac Catalyst the label text is very blurry as you can see in the image below. Both images are created with the same exact code and have the exact same resolution of 460x103. On top the iOS version and on bottom the Mac Catalyst version. Note that not all of the image is blurry, but only the text. In the code I set a corner radius of 10 and you can see that the corner is rendered with an high resolution, like the iOS version. It's just the text that for some reason is blurry. It's like if the label text is rendered with a scale of 1 and then scaled up. Someone know why? There is something I can do to improve the rendering of the text? Thank you
Posted
by
Post not yet marked as solved
0 Replies
132 Views
Hi, I am setting the attributed string to NSTextStorage and replacing it with another attributed string if need changes. I am getting crash with this stack trace: CoreFoundation CFCharacterSetIsLongCharacterMember + 0x28 UIFoundation -[NSMutableAttributedString(NSMutableAttributedStringKitAdditions) fixFontAttributeInRange:] + 0x15fc UIFoundation -[NSMutableAttributedString(NSMutableAttributedStringKitAdditions) fixAttributesInRange:] + 0x70 UIFoundation -[NSTextStorage processEditing] + 0xe0 UIFoundation -[NSTextStorage edited:range:changeInLength:] + 0x14c Foundation -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 0x158 UIFoundation __71-[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:]_block_invoke + 0x28 UIFoundation __NSConcreteTextStorageLockedForwarding + 0x34 UIFoundation -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 0x44 \ Please help with what could be the issue. I have checked that the attributed string is not nil and the font is UIFont *.
Posted
by
Post not yet marked as solved
0 Replies
132 Views
When I attempt to highlight text within an SVG on an iPhone, the blue selection bar is in the wrong position. Please see attached screenshots. You can see in my screenshots that the text magnifier is in the correct spot but not the blue selection bar. Has anyone run into this issue?
Posted
by
Post not yet marked as solved
0 Replies
318 Views
We found that text rendering takes a lot of time as of iOS 15.2. We measured how much time it takes to assign values to text and attributedText of UILabel in iOS 14.5 simulator and iOS 15.2 simulator, respectively, using long enough and short enough text data. As a result, regardless of the text or attributedText, it was confirmed that iOS 15.2 takes about 4 times more time for a short enough text and 15 times more for a long enough text. And this is causing scrolling freezing. Anyone experiencing this issue? or how can I resolve it?
Posted
by
Post not yet marked as solved
1 Replies
378 Views
I'm trying to render text with Metal for my (2D) game. I'm using the system fonts, e.g. the SF Pro family for English texts. I render the glyphs onto an atlas texture, and then sample from this texture. My questions: I assume that, for copyright reasons, I'm not allowed to include a pre-rendered font atlas in my app. Is my assumption correct? I can, however, have the app generate the atlas when it's first opened, and then use it within the app, right? If 2. is true, then can the app save the atlas somewhere in the app's private storage, so that it would not need to re-generate the atlas the next time? Thanks!
Posted
by
Post not yet marked as solved
0 Replies
326 Views
My language learning app needs to support a lot of languages and text paragraphs containing 2 different languages are not uncommon. (e.g. German grammar explained in Arabic) Now, I want to integrate a custom font to make the design unique and consistent across multiple platforms (iOS, Android, Web), but there is basically no single Font that supports all languages. The question is: What is the recommended way of implementing that on the code level in SwiftUI? If I just hardcode: .font(Font.custom("myFont", size: 16)) then I guess it is not gonna work if the text contains a language not supported by my custom font. The Apple's default font seems to handle all languages perfectly, even if they are mixed together and I'd like to have something like that, but with a custom font. Specifically, I'd like to integrate FF Din font: https://www.myfonts.com/fonts/fontfont/ff-din/ with supported Languages: Western Europe, Vietnamese, Central/Eastern Europe, Baltic, Turkish, Romanian, Cyrillic, Greek So I am wondering what I would do about Chinese, Arabic, etc. Thanks
Posted
by
Post not yet marked as solved
1 Replies
227 Views
The recent upgrade of the Mac OS seems to have removed some of the inspector bar tools from the NSTextView that formerly appears after setting usesInspectorBar to true. I see nothing in the documentation for any API for making these tools reappear. I notice that the TextEdit app's inspector bar is not missing them. Please tell me how to get my app's text view's inspector bar to look and behave like TextEdit.
Posted
by
Post not yet marked as solved
0 Replies
282 Views
Hi, I'm currently looking for a way to render WebVTT subtitles while using AVSampleBufferDisplayLayer. A little background on the issue. In order to comply with some client rules (for play/pause/seek) and support picture in picture, I had to abandon the AVPlayerLayer (switching to AVSampleBufferDisplayLayer) which made me lose the native subtitles support but let me tap into the play/pause/seek calls and enforce the needed rules. This way I was able to use the AVPictureInPictureController with a content source and delegate (the latter did the trick to tapping into the PiP calls). But with this, I lost the subtitles. The first thing that came to my mind was to implement support for the rendering of subtitles. Adding an AVPlayerItemLegibleOutput to the AVPlayerItem allowed me to get access to the subtitles, just to find out they were annotated with CoreMedia CMTextMark which don't seem to be automatically rendered by a CATextLayer. Thought of converting the NSAttributedString "styles" from Core Media to "normal" styles but then I would also need to add support for laying the subs correctly. Certainly, one way to do it but not sure it's easier. Couldn't find anything on the Core Media documentation that helped either. Then while digging around the AVPlayerItemOutput I saw the suppressesPlayerRendering and trying to use AVPlayerLayer and AVSampleBufferDisplayLayer together. The first one would render the subtitles while the other would do the video rendering. Made a sample and it sure works on the simulator, but when running on the device I get two layers of video playing and it seems that the suppressesPlayerRendering flag doesn't do anything. How can I tackle this problem?
Posted
by
Post not yet marked as solved
0 Replies
269 Views
Here's a simple demo. I run it on macOS 12.1, compiled with Xcode 13.2. struct ContentView: View {     var body: some View {         VStack {             Text("ee")             Text("eé") Text("e\u{E9}") // "e with acute"             Text("ee\u{301}") // "combining acute"         }.font(.custom("Avenir", fixedSize: 18))          .padding(20)     } } In the 4rd one, the "e" is rendered in the wrong size/font. Screenshot: Other fonts do not have the problem. For example, "Avenir Next" and "Helvetica". Is there a way (in code) to tell which fonts can handle combining chars? Is this a bug? I notice the same thing happens when I use Core Text to draw the strings at a low level. So it's not just SwiftUI. In TextEdit, if have Avenir font, type "option-e" + "e" I get a nice letter. Maybe TextEdit is doing what Xcode did in the second line, and using the "e with acute" unicode character.
Posted
by
Post not yet marked as solved
0 Replies
293 Views
In our app we are working with different kinds of documents. When working with text files we can add text attachments, by drag-and-dropping images into UITextView. Those files are saved using NSAttributedString's fileWrapper and proper document type (RTFD for attributed text with attachments) Everything worked fine before updating to macOS Monterey 12.1 But after update fileWrapper function returns the error: "image destination must have at least one image" and results in unknown file icon after saving and loading the file. The issue is caused only when dropping or pasting images (png and jpeg). When working with original RTFD files, created with TextEdit, everything is fine. Seems like it occurs because iOS UIImages cant have tiff representation and RTFD file packages contain tiff images as attachments. Anybody faced this kind of issue? Is this an Apple bug or smth else?
Posted
by
Post not yet marked as solved
0 Replies
343 Views
I have made a Scan to Text app with the help of sources from the internet, but I can’t figure out a way to get my output text to be editable. Here’s my code private func makeScannerView()-> ScannerView {         ScannerView(completion: {             textPerPage in             if let outputText = textPerPage?.joined(separator: "\n").trimmingCharacters(in: .whitespacesAndNewlines){                 let newScanData = ScanData(content: outputText)                 self.texts.append(newScanData)             }             self.showScannerSheet = false                      })     }
Posted
by
Post not yet marked as solved
0 Replies
251 Views
Dear Support, My query is that I can't install the below fonts in my I-Mac 2020 M1 Chip. please suggest how I can install these below fonts so I complete my tasks timely. IOS in my iMac is Big Sur. Font Name: Ameri BT - family Helvetica - Family Univers - Family
Posted
by
Post not yet marked as solved
0 Replies
375 Views
Is there a way to import custom font into Reality composer on iPad? I can see them properly on desktop but I'm trying to figure out how to do the same on Ipad so that when I export my project on the remote device there is visual parity. Thanks
Posted
by
Post marked as solved
1 Replies
437 Views
I'm investigating some font/typography issues in a creative application. I am hoping for some information from Apple developers who know how font activation works in Core Text, and how/whether auto-activation is still supported. I'm running on Big Sur in an Obj-C Cocoa app. In applicationDidFinishLaunching the app calls CTFontManagerSetAutoActivationSetting(NULL, kCTFontManagerAutoActivationEnabled); After this, what is the correct API to request auto-activation of a font that may not be active but could be activated, e.g. by a third-party font manager? I have tried using CTFontCreateWithNameAndOptions. For options, I see there is an CTFontOption value kCTFontOptionsPreventAutoActivation - I assume that as long as I don't set this option, the call will attempt auto-activation. However, I don't see any auto-activation resulting, either from the third-party font manager or the OS. Instead CTFontCreateWithNameAndOptions always returns a substitute font (Helvetica). The font I am attempting to auto-activate is an OTF. It is stored in a third-party font manager, and I also have copies of it on the desktop. I have also tried having it present / disabled in FontBook, which also does not auto-activate it in this case. I've also cleaned font caches after making changes. How is the kCTFontManagerAutoActivationEnabled supposed to work in Big Sur? Is there a different Core Text call used to auto-activate a font, or is this behavior no longer supported? Thanks!
Posted
by
Post not yet marked as solved
1 Replies
883 Views
I want to use the "SF Pro Text" font in my app. It works fine when I build my app on my main computer running macOS11 Big Sur, but I have a 2nd partition to run macOS Monterey, and it doesn't seem to be available there at all, whether through Interface Builder or through code (using NSFontManager). Using this returns nil on my Monterey partition: NSFont* regularFont = [[NSFontManager sharedFontManager] fontWithFamily:@"SF Pro Text" traits:NSFontWeightRegular weight:5 size: 16.0]; Maybe I'm missing something here ... should I have to install the font manually? I thought the SF Font is a 'system font', so it would be available on all Macs?
Posted
by