0
CoreText
TDecorationRun::CalculateGlyphIntersections(CGAffineTransform, TRun const&, double, double, std::__1::function<void (double, double)> const&) const + 1704
1
CoreText
TDecorationRun::CalculateGlyphIntersections(CGAffineTransform, TRun const&, double, double, std::__1::function<void (double, double)> const&) const + 1440
2
CoreText
void TDecorationRun::DrawDecorationRun<(anonymous namespace)::TRunAdapter>(CGContext*, (anonymous namespace)::TRunAdapter, (anonymous namespace)::TRunAdapter, double)::'lambda'(CGPoint, CGPoint)::operator()(CGPoint, CGPoint) const + 508
3
CoreText
TDecorator::DrawDecoration(TLineDrawContext const&, TLine const&, TInlineVector<DecorationOverride, 30ul> const*) + 2356
4
CoreText
TLine::DrawUnderlines(CGContext*) const + 104
5
CoreText
TLine::DrawGlyphs(CGContext*) const + 292
                    
                  
                Core Text
RSS for tagCreate text layouts, optimize font handling, and access font metrics and glyph data using Core Text.
Posts under Core Text tag
            
              
                24 Posts
              
            
            
              
                
              
            
          
          
  
    
    Selecting any option will automatically load the page
  
  
  
  
    
  
  
              Post
Replies
Boosts
Views
Activity
                    
                      When drawing multiline text using Core Text (by preparing a paragraph and issuing a call to CTDrawFrame):
if truncation is enabled via a paragraph setting (spec=kCTParagraphStyleSpecifierLineBreakMode and value=kCTLineBreakByTruncatingMiddle),
and if one of the lines to render contains a line with spaces only (codepoint=U+0020),
and if the available width for rendering is less than the natural width of the line containing only spaces,
then the rendering is incomplete, all content in the lines following the spaces is omitted.
Many other codepoints cause the same problem: tabs (U+0009), no-break spaces (U+00A0), control characters ...
The issue is quite severe because the rendering can break with a simple ASCII input ! Here is a recording with a yellow text background to help see the spaces :
To reproduce :
CGContextRef ctx = [[NSGraphicsContext currentContext] CGContext];
// String to display: 3 lines, the middle one contains only spaces (40)
CFStringRef str = CFSTR("Hello World!\n                                        \nThis is a multiline example with a long line.");
// Font used for rendering
CTFontRef font = CTFontCreateWithName(CFSTR("Helvetica"), 20, nullptr);
// Paragraph style with middle truncation
CTLineBreakMode lineBreak = kCTLineBreakByTruncatingMiddle;
CTParagraphStyleSetting settings[] = {
    { kCTParagraphStyleSpecifierLineBreakMode, sizeof(CTLineBreakMode), &lineBreak }
};
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, 1);
// Prepare text attributes
NSDictionary *attrs = @{
    (__bridge id)kCTFontAttributeName : (__bridge id)font,
    (__bridge id)kCTForegroundColorAttributeName : (__bridge id)[NSColor blackColor].CGColor,
    (__bridge id)kCTBackgroundColorAttributeName : (__bridge id)[NSColor yellowColor].CGColor,
    (__bridge id)kCTParagraphStyleAttributeName : (__bridge id)paragraphStyle,
};
NSAttributedString *attrStr =
        [[NSAttributedString alloc] initWithString:(__bridge NSString*)str attributes:attrs];
// Create framesetter
CTFramesetterRef fs = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attrStr);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, nullptr, self.bounds);
CTFrameRef frame = CTFramesetterCreateFrame(fs, CFRangeMake(0, 0), path, nullptr);
// Draw the paragraph
CTFrameDraw(frame, ctx);
This seems like a bug in Core Text, unless I was missing some additional parameter to specify before calling CTFrameDraw()?
                    
                  
                
                    
                      Hi! I am adding MacOS to a SwiftUI based multiplatform app in XCode, and have noticed an effect on the OTF font I am using. When started for a MacOSX target, the font looks a bit fuzzy, or too bold for the same display:
Above is the display running in an iPhone 13 mini simulator, below the macOS version running for the "My Mac" target.
The font is in both cases just fetched with
static let tkDisplayFont = Font.custom("Segment7Standard", size: 38)
Same applies in dark mode:
This makes the numbers and especially the decimal point a bit harder to read. The same happens with the system font, but it is not such a problem there:
I guess this is handled a bit differently between UIFont and NSFont underneath. Is there a way to tell the font to behave the same way as on iOS?
                    
                  
                
                    
                      Some character display on iOS 26 cause crash
String sample
Crash stack
                    
                  
                
                    
                      آلَحـ🇾🇪ᬼ⃝⃡Wٌـّاج
this string cause a crash on iOS 26 when sett label.text
      Crashed: com.apple.main-thread
0  CoreText                       0xf720c std::__1::__hash_table<std::__1::__hash_value_type<long, CGPoint>, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, CGPoint>, std::__1::hash, std::__1::equal_to, true>, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, CGPoint>, std::__1::equal_to, std::__1::hash, true>, std::__1::allocator<std::__1::__hash_value_type<long, CGPoint>>>::erase(std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<long, CGPoint>, void*>>) + 300
1  CoreText                       0xf63d4 TGlyphComposer::ComposeGlyphs(long, TInlineVector<unsigned short, 30ul> const&, TInlineVector<long, 30ul> const&) + 2896
2  CoreText                       0x8b018 TCombiningEngine::ResolveCombiningMarks(TCombiningEngine::CombiningFlag, bool, bool*) + 2232
3  CoreText                       0x4edf0 TKerningEngine::PositionGlyphs(TRunGlue&, TCharStream const&, signed char) + 1108
4  CoreText                       0x4eee8 TTypesetter::FinishLayout(std::__1::tuple<TLine const*, TCharStream const*, void const* ()(__CTRun const, __CFString const*, void*), void*, std::__1::shared_ptr, unsigned int, unsigned char, bool, long> const&, TRunGlue&, signed char, SyncState) + 64
5  CoreText                       0x34608 TTypesetterAttrString::Initialize(__CFAttributedString const*, bool) + 3300
6  CoreText                       0x34d88 TTypesetterAttrString::TTypesetterAttrString(__CFAttributedString const*, __CFDictionary const*, bool) + 160
7  CoreText                       0x34c38 CTLineCreateWithAttributedString + 84
8  UIFoundation                   0x6204 __NSCoreTypesetterCreateBaseLineFromAttributedString + 704
9  UIFoundation                   0xafd38 -[NSCoreTypesetter _stringDrawingCoreTextEngineWithOriginalString:rect:padding:graphicsContext:forceClipping:attributes:stringDrawingOptions:drawingContext:stringDrawingInterface:] + 2652
10 UIFoundation                   0x26bc __NSStringDrawingEngine + 1592
11 UIFoundation                   0xab308 -[NSString(NSExtendedStringDrawing) boundingRectWithSize:options:attributes:context:] + 164
12 UIKitCore                      0x186a978  + 132
13 UIKitCore                      0x48a7c  + 668
14 UIKitCore                      0x186b35c  + 444
15 UIKitCore                      0x186eb30  + 408
16 UIKitCore                      0x486d4  + 136
17 UIKitCore                      0x47c1c  + 80
18 UIKitCore                      0x1b68e4  + 80
19 UIKitCore                      0x1867c08  + 760
20 UIKitCore                      0x18678ec  + 72
21 UIKitCore                      0x186be30  + 104
.......
28 UIKitCore                      0xa894e0  + 52
29 UIKitCore                      0x19047fc  + 76
30 UIKitCore                      0xa88b0c  + 1196
31 UIKitCore                      0xa91ce0  + 524
32 UIKitCore                      0xa9222c  + 280
33 UIKitCore                      0xa90550  + 3036
34 UIKitCore                      0x1e1604  + 280
35 UIKitCore                      0x27078  + 912
36 UIKitCore                      0x27b38  + 40
37 UIKitCore                      0x190df68  + 2532
38 QuartzCore                     0xac8bc  + 116
39 QuartzCore                     0x8f2fc  + 600
40 QuartzCore                     0xadf84  + 200
41 QuartzCore                     0x6ef78  + 536
42 QuartzCore                     0x9bab0  + 644
43 QuartzCore                     0xa93c0  + 88
44 UIKitCore                      0x780f0  + 52
45 UIKitCore                      0x78024  + 352
46 UIKitCore                      0x85ee8  + 128
47 UIKitCore                      0x85378  + 60
48 UpdateCycle                    0x15f8 UC::DriverCore::continueProcessing() + 84
49 CoreFoundation                 0x6a230  + 28
50 CoreFoundation                 0x6a1a4  + 172
51 CoreFoundation                 0x47c6c  + 232
52 CoreFoundation                 0x1d8b0  + 820
53 CoreFoundation                 0x1cc44  + 532
54 GraphicsServices               0x1498 GSEventRunModal + 120
55 UIKitCore                      0xa9ddc  + 792
56 UIKitCore                      0x4eb0c UIApplicationMain + 336
57 UIKitCore                      0x18a860  + 588
59 ???                            0x18c7cae28 (缺少)
                    
                  
                
                    
                      Hi everyone, (you can answer in french)
I’m french-rookie in xcode, and I have a problem:
I’m trying to choice my custom font to add it in my Main.storyboard button, but it not works.
I have my « Font provided by application » line in my Info.plist, with the name of my font in [0]
(See images below)
When I’m on storyboard button, I chose « custom » in font selector, then display font list but my custom font doesn’t appear.
I already tried to install the font in my mac, but still stucked, nothing change 😭
Could you help me please?
Thanks a lot
(I specify that I scrupulously followed the way of doing explained on the Apple official page:
Adding a Custom Font to Your App )
                    
                  
                
                    
                      Hi,
I am developing an OpenType font with the following cursive feature.
feature curs {  
  lookup cursivejoinrtl;  # RIGHT_TO_LEFT flag set between Hah, Meem, Yeh and final Meem
  lookup rehwawcursive; # RIGHT_TO_LEFT flag clear between Waw and Hah
} curs;
Here is the rendering of the word وحميم in TextEdit.
Using HarfBuzz I got the following result.
The same rendering problem occurs when using Safari. It seems that is related to Core Text.
I reported the issue to Feedback Assistant over a year ago but haven't had a response yet. So I'm posting the problem on this forum.
Any support on this matter would be greatly appreciated.
                    
                  
                
                    
                      Hi, I wanted to know what is the best way to detect whether a part of string has an unavailable character, '□' (tofu box or last resort character). So far it seems to be that we will have to parse all the strings and individually check for each character and whether or not it is a part of the Unicode Scalar. And since we are a business application that deals with a lot of data as strings, this will be rather performance heavy. So wanted to know if there were any other better or more efficient ways to go about this?
                    
                  
                
                    
                      Hello everyone, I am having an issue where the attributed text that I have in my UITextView is not scaling dynamically with phone text size, whenever I remove the attributed text logic, it scales fine, however, with it, it stays at a set font size.
struct AutoDetectedClickableDataView: UIViewRepresentable {
    let text: String
    @Binding var height: CGFloat
    func makeUIView(context: Context) -> UITextView {
        let textView = UITextView()
        textView.dataDetectorTypes = [.phoneNumber, .address, .link]
        textView.isEditable = false
        textView.isScrollEnabled = false
        textView.backgroundColor = .clear
        textView.font = UIFont.preferredFont(forTextStyle: .body) /*UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0)) */
        textView.adjustsFontForContentSizeCategory = true
        textView.textContainer.lineBreakMode = .byWordWrapping
        textView.textContainerInset = .zero
        textView.textContainer.lineFragmentPadding = 0
        textView.translatesAutoresizingMaskIntoConstraints = false
        textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
        textView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
        return textView
    }
    func updateUIView(_ uiView: UITextView, context: Context) {
        let attributed = NSMutableAttributedString(string: text, attributes: [
            .font: UIFont.preferredFont(forTextStyle: .body)
        ])
        
        let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.address.rawValue |
                                           NSTextCheckingResult.CheckingType.link.rawValue |
                                           NSTextCheckingResult.CheckingType.phoneNumber.rawValue)
        detector?.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count)) { match, _, _ in
            guard let match = match else { return }
            
            attributed.addAttributes([
                .foregroundColor: UIColor.systemBlue,
                .underlineStyle: NSUnderlineStyle.single.rawValue,
            ], range: match.range)
        }
        
        uiView.attributedText = attributed
//        uiView.text = text
        DispatchQueue.main.async {
            uiView.layoutIfNeeded()
            let fittingSize = CGSize(width: uiView.bounds.width, height: .greatestFiniteMagnitude)
            let size = uiView.sizeThatFits(fittingSize)
            height = size.height
        }
    }
}
                    
                  
                
                    
                      Crash Stack:
thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x19ba3bb04)
frame #0: 0x000000019ba3bb04 CoreFoundation`forwarding.cold.2 + 92
frame #1: 0x000000019b8ab718 CoreFoundation`forwarding + 1288
frame #2: 0x000000019b8ab150 CoreFoundation`_CF_forwarding_prep_0 + 96
frame #3: 0x000000019df230b0 CoreText`TCFRef<CTRun*>::Retain(void const*) + 40
frame #4: 0x000000019e052050 CoreText`CreateFontWithFontURL(__CFURL const*, __CFString const*, __CFString const*) + 476
frame #5: 0x000000019e052874 CoreText`TCGFontCache::CopyFont(__CFURL const*, __CFString const*, __CFString const*) + 144
frame #6: 0x000000019df27dcc CoreText`TBaseFont::CopyNativeFont() const + 232
frame #7: 0x000000019df8ee64 CoreText`TBaseFont::GetInitializedGraphicsFont() const + 152
frame #8: 0x000000019df26d70 CoreText`TBaseFont::CopyVariationAxes() const + 296
frame #9: 0x000000019df2d148 CoreText`TDescriptor::InitBaseFont(unsigned long, double) + 768
frame #10: 0x000000019df21358 CoreText`TDescriptor::CreateMatchingDescriptor(__CFSet const*, double, unsigned long) const + 604
frame #11: 0x000000019df251f8 CoreText`CTFontCreateWithFontDescriptor + 68
frame #12: 0x00000001bff8dfb8 WebCore`WebCore::createCTFont(__CFDictionary const*, float, unsigned int, __CFString const*, __CFString const*) + 124
frame #13: 0x00000001bff8e8bc WebCore`WebCore::FontPlatformData::fromIPCData(float, WebCore::FontOrientation&&, WebCore::FontWidthVariant&&, WebCore::TextRenderingMode&&, bool, bool, std::__1::variant<WebCore::FontPlatformSerializedData, WebCore::FontPlatformSerializedCreationData>&&) + 228
frame #14: 0x00000001c128eef4 WebKit`IPC::ArgumentCoder<WebCore::Font, void>::decode(IPC::Decoder&) + 1352
frame #15: 0x00000001c1333ca4 WebKit`std::__1::optional<WTF::HashMap<WTF::String, WebCore::AttributedString::AttributeValue, WTF::DefaultHashWTF::String, WTF::HashTraitsWTF::String, WTF::HashTraitsWebCore::AttributedString::AttributeValue, WTF::HashTableTraits>> IPC::ArgumentCoder<WTF::HashMap<WTF::String, WebCore::AttributedString::AttributeValue, WTF::DefaultHashWTF::String, WTF::HashTraitsWTF::String, WTF::HashTraitsWebCore::AttributedString::AttributeValue, WTF::HashTableTraits>, void>::decodeIPC::Decoder(IPC::Decoder&) + 480
frame #16: 0x00000001c1333a5c WebKit`std::__1::optional<WTF::HashMap<WTF::String, WebCore::AttributedString::AttributeValue, WTF::DefaultHashWTF::String, WTF::HashTraitsWTF::String, WTF::HashTraitsWebCore::AttributedString::AttributeValue, WTF::HashTableTraits>> IPC::Decoder::decode<WTF::HashMap<WTF::String, WebCore::AttributedString::AttributeValue, WTF::DefaultHashWTF::String, WTF::HashTraitsWTF::String, WTF::HashTraitsWebCore::AttributedString::AttributeValue, WTF::HashTableTraits>>() + 28
frame #17: 0x00000001c1333804 WebKit`std::__1::optional<std::__1::pair<WebCore::AttributedString::Range, WTF::HashMap<WTF::String, WebCore::AttributedString::AttributeValue, WTF::DefaultHashWTF::String, WTF::HashTraitsWTF::String, WTF::HashTraitsWebCore::AttributedString::AttributeValue, WTF::HashTableTraits>>> IPC::Decoder::decode<std::__1::pair<WebCore::AttributedString::Range, WTF::HashMap<WTF::String, WebCore::AttributedString::AttributeValue, WTF::DefaultHashWTF::String, WTF::HashTraitsWTF::String, WTF::HashTraitsWebCore::AttributedString::AttributeValue, WTF::HashTableTraits>>>() + 156
frame #18: 0x00000001c121f368 WebKit`IPC::ArgumentCoder<WebCore::AttributedString, void>::decode(IPC::Decoder&) + 172
frame #19: 0x00000001c121f124 WebKit`std::__1::optionalWebCore::AttributedString IPC::Decoder::decodeWebCore::AttributedString() + 28
frame #20: 0x00000001c12594ec WebKit`IPC::ArgumentCoder<WebCore::DictionaryPopupInfo, void>::decode(IPC::Decoder&) + 76
frame #21: 0x00000001c12d0660 WebKit`std::__1::optionalWebCore::DictionaryPopupInfo IPC::Decoder::decodeWebCore::DictionaryPopupInfo() + 28
frame #22: 0x00000001c12ceef0 WebKit`IPC::ArgumentCoder<WebKit::WebHitTestResultData, void>::decode(IPC::Decoder&) + 1292
frame #23: 0x00000001c1338950 WebKit`std::__1::optionalWebKit::WebHitTestResultData IPC::Decoder::decodeWebKit::WebHitTestResultData() + 28
frame #24: 0x00000001c1ec7edc WebKit`WebKit::WebPageProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 31392
frame #25: 0x00000001c1fb8f28 WebKit`IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 272
frame #26: 0x00000001c19ab2c0 WebKit`WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 44
frame #27: 0x00000001c1fb3254 WebKit`IPC::Connection::dispatchMessage(WTF::UniqueRefIPC::Decoder) + 252
frame #28: 0x00000001c1fb3768 WebKit`IPC::Connection::dispatchIncomingMessages() + 576
frame #29: 0x00000001b9ab90c4 JavaScriptCore`WTF::RunLoop::performWork() + 204
frame #30: 0x00000001b9ab9fec JavaScriptCore`WTF::RunLoop::performWork(void*) + 36
frame #31: 0x000000019b8cc8a4 CoreFoundation`CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28
frame #32: 0x000000019b8cc838 CoreFoundation`__CFRunLoopDoSource0 + 176
frame #33: 0x000000019b8cc59c CoreFoundation`__CFRunLoopDoSources0 + 244
frame #34: 0x000000019b8cb138 CoreFoundation`__CFRunLoopRun + 840
frame #35: 0x000000019b8ca734 CoreFoundation`CFRunLoopRunSpecific + 588
frame #36: 0x00000001a6e39530 HIToolbox`RunCurrentEventLoopInMode + 292
frame #37: 0x00000001a6e3f348 HIToolbox`ReceiveNextEventCommon + 676
frame #38: 0x00000001a6e3f508 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
frame #39: 0x000000019f442848 AppKit`_DPSNextEvent + 660
frame #40: 0x000000019fda8c24 AppKit`-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
frame #41: 0x000000019f435874 AppKit`-[NSApplication run] + 480
frame #42: 0x000000019f40c068 AppKit`NSApplicationMain + 888
frame #43: 0x00000001ca56a70c SwiftUI`merged generic specialization <SwiftUI.TestingAppDelegate> of function signature specialization <Arg[0] = Existential To Protocol Constrained Generic> of SwiftUI.runApp(__C.NSResponder & __C.NSApplicationDelegate) -> Swift.Never + 160
frame #44: 0x00000001ca9e09a0 SwiftUI`SwiftUI.runApp<τ_0_0 where τ_0_0: SwiftUI.App>(τ_0_0) -> Swift.Never + 140
frame #45: 0x00000001cad5ce68 SwiftUI`static SwiftUI.App.main() -> () + 224
frame #46: 0x0000000105943104 MyApp Dev.debug.dylib`static MyMacApp.$main() at :0
frame #47: 0x0000000105943c9c MyApp Dev.debug.dylib`main at MyMacApp.swift:24:8
frame #48: 0x000000019b464274 dyld`start + 2840
                    
                  
                
                    
                      (EN):
After upgrading to macOS 15+, the system contains two incompatible versions of the PingFang (苹方) font:
1.	A system-provided version (/System/Library/Fonts/PingFang.ttc)
2.	A user-installed version via Font Book (located in ~/Library/Fonts or /Library/Fonts)
When a user installs or removes the PingFang font via Font Book after the app starts, font resolution may switch, causing garbled text in newly opened windows or views.
This issue did not occur in macOS 13 or 14, and seems specific to how macOS 15+ handles system and user font overlays.
                    
                  
                
                    
                      I'm an iOS developer, and I've been testing our app in iOS 18.0 Beta. I noticed that there's a problem with the font rendering, and after troubleshooting, I've found out that it's caused by the removal of the PingFang.ttc font in 18.0.
I would like to ask the reason for removing this font file and which font should be used to display Chinese in the future?
My test device is an iPhone 11 Pro and the system version is iOS 18.0 (22A5297). I have also tested Beta 1 and it has the same issue.
In previous versions of the system, the PingFang font is located in this directory /System/Library/Fonts/LanguageSupport/PingFang.ttc. But in iOS 18.0, the font file in this directory has become Kohinoor.ttc, and I've tested that this font can't display Chinese either.
I traversed the following system font directories and could not find the PingFang.ttc font file.
/System/Library/Fonts/AppFonts
/System/Library/Fonts/Core
/System/Library/Fonts/CoreAddition
/System/Library/Fonts/CoreUI
/System/Library/Fonts/LanguageSupport
/System/Library/Fonts/UnicodeSupport
/System/Library/Fonts/Watch
Looking for answers, thanks for the help!
                    
                  
                
                    
                      We have crash reports as shown below that we haven't yet been able to repro and could use some help deubgging.
My guess is that the app is giving a label or text view an attributed string with an invalid attribute range, but attributed strings are used in many places throughout the app, and I don't know an efficient way to track this down.
I'm posting the stack trace here in hopes that someone more familiar with the internals of the system frameworks mentioned will be able to provide a clue to help narrow where I should look.
Fatal Exception: NSRangeException
NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds
0  CoreFoundation                 0x2d5fc __exceptionPreprocess
1  libobjc.A.dylib                0x31244 objc_exception_throw
2  Foundation                     0x47130 blockForLocation
3  UIFoundation                   0x2589c -[NSTextLineFragment _defaultRenderingAttributesAtCharacterIndex:effectiveRange:]
4  UIFoundation                   0x25778 __53-[NSTextLineFragment initWithAttributedString:range:]_block_invoke
5  CoreText                       0x58964 TLine::DrawGlyphsWithAttributeOverrides(TLineDrawContext const&, __CFDictionary const* (long, CFRange*) block_pointer, TDecoratorObserver*) const
6  CoreText                       0x58400 CTLineDrawWithAttributeOverrides
7  UIFoundation                   0x25320 _NSCoreTypesetterRenderLine
8  UIFoundation                   0x24b10 -[NSTextLineFragment drawAtPoint:graphicsContext:]
9  UIFoundation                   0x3e634 -[NSTextLineFragment drawAtPoint:inContext:]
10 UIFoundation                   0x3e450 -[NSTextLayoutFragment drawAtPoint:inContext:]
11 UIKitCore                      0x3e3098 __38-[_UITextLayoutFragmentView drawRect:]_block_invoke
12 UIKitCore                      0x3e31cc _UITextCanvasDrawWithFadedEdgesInContext
13 UIKitCore                      0x3e3040 -[_UITextLayoutFragmentView drawRect:]
14 UIKitCore                      0xd7a98 -[UIView(CALayerDelegate) drawLayer:inContext:]
15 QuartzCore                     0x109340 CABackingStoreUpdate_
16 QuartzCore                     0x109224 invocation function for block in CA::Layer::display_()
17 QuartzCore                     0x917f0 -[CALayer _display]
18 QuartzCore                     0x90130 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
19 QuartzCore                     0xe50c4 CA::Context::commit_transaction(CA::Transaction*, double, double*)
20 QuartzCore                     0x5bd8c CA::Transaction::commit()
21 UIKitCore                      0x9f3f0 _UIApplicationFlushCATransaction
22 UIKitCore                      0x9c89c __setupUpdateSequence_block_invoke_2
23 UIKitCore                      0x9c710 _UIUpdateSequenceRun
24 UIKitCore                      0x9f040 schedulerStepScheduledMainSection
25 UIKitCore                      0x9cc5c runloopSourceCallback
26 CoreFoundation                 0x73f4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
27 CoreFoundation                 0x73ee0 __CFRunLoopDoSource0
28 CoreFoundation                 0x76b40 __CFRunLoopDoSources0
29 CoreFoundation                 0x75d3c __CFRunLoopRun
30 CoreFoundation                 0xc8284 CFRunLoopRunSpecific
31 GraphicsServices               0x14c0 GSEventRunModal
32 UIKitCore                      0x3ee674 -[UIApplication _run]
33 UIKitCore                      0x14e88 UIApplicationMain
also filed as FB16905066
                    
                  
                
                    
                      With TextKit 1, I was able to “tag” characters with attribute string keys that flagged them to be invisible, then I would use NSLayoutManager’s layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:) to strip these characters out, preventing change to the underlying storage.
In TextKit 2, I don’t see an opportunity to do this. The best point I think to intercept would be NSTextLayoutFragment, but without being able to see what’s happening, I don’t know if it’s possible to alter the content used to generate the line fragments.
My end goal is to be able to hide characters for a Markdown editor, so maybe I’m thinking about this wrong? Any advice would be welcome.
                    
                  
                
                    
                      I installed a custom font (Font awesome) into my app. I triple checked that I did everything right: the font files are included in the bundle (they appear in the "Copy Bundle Resources" build phase) and the names of the fonts appear in the Info.plist file under "Fonts provided by application".
In Interface builder, I select a Label, set the font to "Custom", then I click the Family list to select the font I want.
Once or twice, I was actually able to see the Font Awesome fonts in this list and select one. However, they no longer appear there when I create new labels in new views. I do not understand why. I've been limping along by copying a label from one of the views where it worked and pasting it into the new view, but this is tiresome.
I know the fonts are installed correctly because I can see them when I run the app.
Why are the fonts not showing up on the font list in interface builder?
                    
                  
                
                    
                      (NOTE: In sum, this is destructive of user data.)
The client is a professor of Classics in constant need of properly-rendered glyphs that represent legitimate code points. As an example, the correct spelling might be:
εὔτρητος
It is spelled and rendered as intended. A file by this name will be correctly spelled by ls in the Terminal. Note that two diacritics are applied to the second letter, an upsilon (ὔ)
However, the Finder displays that file as
ἐύτρητος
and iterating the string reveals that the accents are improperly distributed over the two. This would never be correct.
This handicaps digital-humanities researchers from college to postdoctoral work.
A Character by Character iteration demonstrates the mangling.:
intended  (εὔτρητος)
displayed (ἐύτρητος) 
3B5 (ε)      1F10 (ἐ)	
	GREEK SMALL LETTER EPSILON, 
	GREEK SMALL LETTER EPSILON WITH PSILI
1F54 (ὔ)      3CD (ύ)
	GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA
	GREEK SMALL LETTER UPSILON WITH TONOS
3C4 (τ)      3C4 (τ)
	(back in sync)
3C1 (ρ)      3C1 (ρ)
3B7 (η)      3B7 (η)
3C4 (τ)      3C4 (τ)
3BF (ο)      3BF (ο)
3C2 (ς)      3C2 (ς)
I don't want to muddy the waters by guessing where and how the mistake is made, just see for yourself.
                    
                  
                
                    
                      Hi
I am drawing TextKit2 managed NSAttributedStrings into a NSBitmapImageRep successfully, enumerating the Text Layout Fragments is giving me bogus background drawing
This is the core drawing code, its pretty simple: I manage the flipped property myself since NSTextLayoutManager assumes a flipped coordinate.
  if let context = NSGraphicsContext(bitmapImageRep: self.textImageRep!)
        {
            NSGraphicsContext.current = context
            
            let rect = NSRect(origin: .zero, size: self.outputSize)
            NSColor.clear.set()
            rect.fill()
            
            // Flip the context
            context.cgContext.saveGState()
            
            context.cgContext.translateBy(x: 0, y: self.outputSize.height)
            context.cgContext.scaleBy(x: 1.0, y: -1.0)
            let textOrigin = CGPoint(x: 0.0, y: 0.0 )
            
            let titleRect = CGRect(origin: textOrigin, size: self.themeTextContainer.size)
            NSColor.orange.withAlphaComponent(1).set()
            titleRect.fill()
            self.layoutManager.enumerateTextLayoutFragments(from: nil, using: { textLayoutFragment in
                // Get the fragment's rendering bounds
                let fragmentBounds = textLayoutFragment.layoutFragmentFrame
                print("fragmentBounds: \(fragmentBounds)")
                // Render the fragment into the context
                
                textLayoutFragment.draw(at: fragmentBounds.origin, in: context.cgContext)
                
                return true
            })
           
            context.cgContext.restoreGState()
        }
        
        NSGraphicsContext.restoreGraphicsState()
I have a mutable string which has various paragraph styles which I add to the layout manager / text storage like so
 let titleParagraphStyle = NSMutableParagraphStyle()
        titleParagraphStyle.alignment = .center
        titleParagraphStyle.lineBreakMode = .byWordWrapping
        titleParagraphStyle.lineBreakStrategy = .standard
        
        var range = NSMakeRange(0, self.attributedProgrammingBlockTitle.length)
        self.attributedProgrammingBlockTitle.addAttribute(.foregroundColor, value: NSColor(red: 243.0/255.0, green: 97.0/255.0, blue: 97.0/255.0, alpha: 1.0), range:range)
        self.attributedProgrammingBlockTitle.addAttribute(.backgroundColor, value: NSColor.cyan, range:range)
        self.attributedProgrammingBlockTitle.addAttribute(.font, value: NSFont.systemFont(ofSize: 64), range:range)
        self.attributedProgrammingBlockTitle.addAttribute(.paragraphStyle, value:titleParagraphStyle, range:range)
        range = NSMakeRange(0, self.attributedThemeTitle.length)
        self.attributedThemeTitle.addAttribute(.foregroundColor, value: NSColor.white, range:range )
        self.attributedThemeTitle.addAttribute(.backgroundColor, value: NSColor.purple, range:range)
        self.attributedThemeTitle.addAttribute(.font, value: NSFont.systemFont(ofSize: 48), range:range)
        self.attributedThemeTitle.addAttribute(.paragraphStyle, value:NSParagraphStyle.default, range:range)
        range = NSMakeRange(0, self.attributedText.length)
        self.attributedText.addAttribute(.foregroundColor, value: NSColor.white, range:range )
        self.attributedText.addAttribute(.backgroundColor, value: NSColor.yellow, range:range)
        self.attributedText.addAttribute(.font, value: NSFont.systemFont(ofSize: 36), range:range)
        self.attributedText.addAttribute(.paragraphStyle, value:NSParagraphStyle.default, range:range)
        let allText = NSMutableAttributedString()
        
        allText.append(self.attributedProgrammingBlockTitle)
        allText.append(NSAttributedString(string: "\n\r"))
        allText.append(self.attributedThemeTitle)
        allText.append(NSAttributedString(string: "\n\r"))
        allText.append(self.attributedText)
        
        self.textStorage.textStorage?.beginEditing()
        self.textStorage.textStorage?.setAttributedString(allText)
        self.textStorage.textStorage?.endEditing()
        self.layoutManager.ensureLayout(for: self.layoutManager.documentRange)
however, i get incorrect drawing for the background color font attributes. Its origin is zero, and not correctly aligned at all with the text.
How can I get correct rendering of backgrounds from TextKit2?
Here is an image of my output:
                    
                  
                
                    
                      Hello! I am developing an ebook reader iOS app that uses c/c++ codec as a page renderer.
The codec uses TrueType as a font rendering engine that requires access to .ttf (or .ttc) files.
Currently, I supply TrueType with fonts embedded in the app package, so they lay within the app sandbox.
The codec supports the whole unicode plane and many languages that ebooks may use, but the fonts I supply don't have some of the important glyphs (i.e. katakana or hangul).
I see that iOS has its own font storage, located in /System/Library/Fonts/ directory. The codec is able to parse this directory and read .ttf files located inside, using these fonts as a fallback in the case when the supplied fonts can't draw certain glyphs.
I use opendir and fopen(in "rb" mode) as a way to read the data, and it works well.
Does this type of access to the system directory violate the sandbox rule for an app distribution, and, if yes, is there a way to get access to stored .ttf files not violating the mentioned rule?
                    
                  
                
                    
                      I like this font. but in license only allowed for use in Mockup UI.
Feel free to use in commercial?
https://mobbin.com/apps/bloom-ios-e1251835-34e6-426e-9f94-f9595f2567fa/1c919e9a-d144-4aa0-b788-f9752111e281/screens
                    
                  
                
                    
                      in ios it is not same as it in computer
there is text:"ยินดี
in computer is
but in ios it is
the fontsize is 16
I tried every font which is in ios and tried copy simsun in windows to ios and create CTFont
I draw it using UIGraphics drawString