Xcode editor disables ligatures (which are useful for Swift)

Originator:kenferry
Number:rdar://17702962 Date Originated:
Status: Resolved:Behaves Correctly
Product: Product Version:
Classification: Reproducible:
 
The 'hasklig' font, https://github.com/i-tu/Hasklig/ , has ligatures for things like -> to a nice arrow. It seems very attractive for Swift.

These ligatures don't display in Xcode; it looks like Xcode intentionally turns off ligatures by putting NSLigatureAttributeName=0 in the attributed string.

Steps to Reproduce:
1. Download and install Hasklig, select it as the text font in Xcode.
2. Paste this code into a new Swift project:

    func dumpPasteboard()->() {
        let attr = NSPasteboard.generalPasteboard().readObjectsForClasses(NSArray(object: NSClassFromString("NSAttributedString")), options: nil)
        println(attr)
    }

    dumpPasteboard()
---> ligature for '->' fails to render

3. Copy "->" above, then run program. It spits this out:

    [->{
        NSFont = "\"Hasklig-Regular 11.00 pt. P [] (0x10041f260) fobj=0x104002430, spc=6.60\"";
        NSLigature = 0;
        NSParagraphStyle = "Alignment 0, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n    \"26.45L\"\n), DefaultTabInterval 26.45, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0";
    }]
---> note 'NSLigature = 0;'

Expected Results:
Ligature renders

Actual Results:
Ligature doesn't render. Note that attributed string appears to have ligatures explicitly turned off.

Version:
Version 6.0 (6A254o)

Notes:


Configuration:


Attachments:

Comments

Plugin

Here's quick hack you can use - https://github.com/robertvojta/LigatureXcodePlugin. Just wrote it because of my beloved PragmataPro font.

By robert.vojta at Sept. 1, 2015, 7:42 a.m. (reply...)

Engineering has determined that this issue behaves as intended based on the following:

That's correct. Ligatures are disabled as the source editor is tuned for source code and easy character alignment.

Swift allows you to use many Unicode characters and symbol equivalents to multi character representations though.

We are now closing this bug report.

If you have questions regarding the resolution of this issue, please update your bug report with that information.

Please be sure to regularly check new Apple releases for any updates that might affect this issue.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!