The below program demonstrates a possible bug that I encountered.
Can anyone else reproduce my results (as explained in the comments)?
If so, is it a Swift or Cocoa bug (I haven't tried it in Objective C)?

import AppKit

extension NSFont {
    var planesWithMembers: [UInt8] {
        return (UInt8(0) ... UInt8(255)).filter {
            // The follwing line will crash (EXC_BAD_ACCESS) for some fonts:
            coveredCharacterSet.hasMember(inPlane: $0)
            // I have tested it with Xcode 8.3.3 and Xcode 9 beta 1, both
            // Swift 3 and 4, and they all reproduce the crash.
            // macOS 10.12.5
        }
    }
}

// Examples that will not cause the crash:
// let fontName = "AlBayan"
// let fontName = "AppleBraille"
// let fontName = "Chalkboard"
// let fontName = "Helvetica"
// let fontName = "Zapfino"

// Examples that will cause the crash:
// let fontName = "AppleColorEmoji"
// let fontName = "AppleSymbols"
let fontName = "Baskerville"
// let fontName = "Geneva"
// let fontName = "SnellRoundhand"

let font = NSFont(name: fontName, size: 12)!
let result = font.planesWithMembers
print("Planes that contains members:", result)
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to