<div dir="ltr"><div>PS</div>There are only 17 planes in the (current?) Unicode standard, but I'm assuming that the CharacterSet.hasMember(inPlane:) shouldn't (randomly?) crash for UInt8 values other than 0 ... 16?<div>It also seems strange that it reproducibly crashes or not depending on which specific font I use.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 13, 2017 at 4:00 PM, Jens Persson <span dir="ltr"><<a href="mailto:jens@bitcycle.com" target="_blank">jens@bitcycle.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The below program demonstrates a possible bug that I encountered.</div>Can anyone else reproduce my results (as explained in the comments)?<div>If so, is it a Swift or Cocoa bug (I haven't tried it in Objective C)?</div><div><div><br></div><div>import AppKit</div><div><br></div><div>extension NSFont {</div><div> var planesWithMembers: [UInt8] {</div><div> return (UInt8(0) ... UInt8(255)).filter {</div><div> // The follwing line will crash (EXC_BAD_ACCESS) for some fonts:</div><div> coveredCharacterSet.hasMember(<wbr>inPlane: $0)</div><div> // I have tested it with Xcode 8.3.3 and Xcode 9 beta 1, both</div><div> // Swift 3 and 4, and they all reproduce the crash.</div><div> // macOS 10.12.5</div><div> }</div><div> }</div><div>}</div><div><br></div><div>// Examples that will not cause the crash:</div><div>// let fontName = "AlBayan"</div><div>// let fontName = "AppleBraille"</div><div>// let fontName = "Chalkboard"</div><div>// let fontName = "Helvetica"</div><div>// let fontName = "Zapfino"</div><div><br></div><div>// Examples that will cause the crash:</div><div>// let fontName = "AppleColorEmoji"</div><div>// let fontName = "AppleSymbols"</div><div>let fontName = "Baskerville"</div><div>// let fontName = "Geneva"</div><div>// let fontName = "SnellRoundhand"</div><div><br></div><div>let font = NSFont(name: fontName, size: 12)!</div><div>let result = font.planesWithMembers</div><div>print("Planes that contains members:", result)</div></div><div><br></div></div>
</blockquote></div><br></div>