NSFontManager's availableMembers(ofFontFamily: String) broken?


(Jens Persson) #1

It crashes runtime except when the given string is not an existing font
family name, in which case it returns nil (as expected).

So I'm unable to use it.

Here's a REPL session demo of the issue, but it's the same in Xcode 8 and
8.1 beta 1 (haven't tried any other versions):

Welcome to Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38).
Type :help for assistance.
  1> import AppKit
  2> NSFontManager.shared().availableMembers(ofFontFamily: "Blahblah")
$R0: [[Any]]? = nil
  3> NSFontManager.shared().availableMembers(ofFontFamily: "Georgia")
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
  4> NSFontManager.shared().availableMembers(ofFontFamily: "Times")
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
  5> NSFontManager.shared().availableMembers(ofFontFamily: "Timeeess")
$R1: [[Any]]? = nil
  6>

Any ideas and/or workarounds?

/Jens


(Jens Persson) #2

Found this:
http://stackoverflow.com/questions/39395237/why-is-nsfontmanager-availablemembersoffontfamily-crashing-in-xcode-8-gm

···

On Sat, Oct 8, 2016 at 8:37 AM, Jens Persson <jens@bitcycle.com> wrote:

It crashes runtime except when the given string is not an existing font
family name, in which case it returns nil (as expected).

So I'm unable to use it.

Here's a REPL session demo of the issue, but it's the same in Xcode 8 and
8.1 beta 1 (haven't tried any other versions):

Welcome to Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38).
Type :help for assistance.
  1> import AppKit
  2> NSFontManager.shared().availableMembers(ofFontFamily: "Blahblah")
$R0: [[Any]]? = nil
  3> NSFontManager.shared().availableMembers(ofFontFamily: "Georgia")
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
  4> NSFontManager.shared().availableMembers(ofFontFamily: "Times")
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
  5> NSFontManager.shared().availableMembers(ofFontFamily: "Timeeess")
$R1: [[Any]]? = nil
  6>

Any ideas and/or workarounds?

/Jens


(Quinn “The Eskimo!”) #3

Following the bug reports from that thread, this seems to have been fixed in 10.12.1. Alas, I’m not in a position to try it there myself, but I recommend you give it a go and let us know how you get along.

Share and Enjoy

···

On 8 Oct 2016, at 07:41, Jens Persson via swift-users <swift-users@swift.org> wrote:

Found this: http://stackoverflow.com/questions/39395237/why-is-nsfontmanager-availablemembersoffontfamily-crashing-in-xcode-8-gm

--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware