Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann
I have a file “Some Font.ttf” and I want to know the displayName of this font, 
which might be “Some-Font” or “Nice Font” or anything else.
Or nil if this is not a well-formatted font file.
I do NOT want to install the font nor do anything with it.

Short of reverse-engeneering the ttf format (which probably would be rather too 
much): is there a way to get this?

Ideally I would line to do:
NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
NSString *displayName = font.displayName;   //  font.fontName would 
probably also do

but this seems not to exist.

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Ken Thomases
On Feb 26, 2016, at 4:16 AM, Gerriet M. Denkmann  wrote:
> 
> I have a file “Some Font.ttf” and I want to know the displayName of this 
> font, which might be “Some-Font” or “Nice Font” or anything else.
> Or nil if this is not a well-formatted font file.
> I do NOT want to install the font nor do anything with it.
> 
> Short of reverse-engeneering the ttf format (which probably would be rather 
> too much): is there a way to get this?
> 
> Ideally I would line to do:
> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
> NSString *displayName = font.displayName; //  font.fontName would 
> probably also do
> 
> but this seems not to exist.

You can use CTFontManagerCreateFontDescriptorsFromURL() and then, for each 
descriptor, CTFontDescriptorCopyAttribute() with kCTFontDisplayNameAttribute.

Keep in mind that you may get multiple descriptors because a font file may 
include multiple fonts.  Consequently, there may be multiple display names.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 26 Feb 2016, at 17:33, Ken Thomases  wrote:
> 
> On Feb 26, 2016, at 4:16 AM, Gerriet M. Denkmann  wrote:
>> 
>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>> font, which might be “Some-Font” or “Nice Font” or anything else.
>> Or nil if this is not a well-formatted font file.
>> I do NOT want to install the font nor do anything with it.
>> 
>> Short of reverse-engeneering the ttf format (which probably would be rather 
>> too much): is there a way to get this?
>> 
>> Ideally I would line to do:
>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>> NSString *displayName = font.displayName;//  font.fontName would 
>> probably also do
>> 
>> but this seems not to exist.
> 
> You can use CTFontManagerCreateFontDescriptorsFromURL() and then, for each 
> descriptor, CTFontDescriptorCopyAttribute() with kCTFontDisplayNameAttribute.
> 
> Keep in mind that you may get multiple descriptors because a font file may 
> include multiple fonts.  Consequently, there may be multiple display names.

Thanks a lot. Works perfectly.
But did not find any font file which contains more than one descriptor. Any 
examples (for testing)?

Kind regards,

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Jens Alfke
If this functionality exists it would probably be down in the CoreText 
framework. Take a look there. 

—Jens 

> On Feb 26, 2016, at 2:16 AM, Gerriet M. Denkmann  wrote:
> 
> I have a file “Some Font.ttf” and I want to know the displayName of this 
> font, which might be “Some-Font” or “Nice Font” or anything else.
> Or nil if this is not a well-formatted font file.
> I do NOT want to install the font nor do anything with it.
> 
> Short of reverse-engeneering the ttf format (which probably would be rather 
> too much): is there a way to get this?
> 
> Ideally I would line to do:
> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
> NSString *displayName = font.displayName;//font.fontName would 
> probably also do
> 
> but this seems not to exist.
> 
> Gerriet.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/jens%40mooseyard.com
> 
> This email sent to j...@mooseyard.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 27 Feb 2016, at 00:31, Jens Alfke  wrote:
> 
> If this functionality exists it would probably be down in the CoreText 
> framework. Take a look there. 
> 
> —Jens 

As Ken Thomases kindly told me it does exist exactly there: 
CTFontManagerCreateFontDescriptorsFromURL.

Kind regards,

Gerriet.

> 
>> On Feb 26, 2016, at 2:16 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>> font, which might be “Some-Font” or “Nice Font” or anything else.
>> Or nil if this is not a well-formatted font file.
>> I do NOT want to install the font nor do anything with it.
>> 
>> Short of reverse-engeneering the ttf format (which probably would be rather 
>> too much): is there a way to get this?
>> 
>> Ideally I would line to do:
>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>> NSString *displayName = font.displayName;//font.fontName would 
>> probably also do
>> 
>> but this seems not to exist.
>> 
>> Gerriet.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Alex Kac
Are you wanting this for any arbitrary font? I believe you can “install” a font 
just for your application - and then use the NSFont methods to get it.

http://stackoverflow.com/questions/5283572/custom-font-in-a-cocoa-application

> On Feb 26, 2016, at 10:31 AM, Jens Alfke  wrote:
> 
> If this functionality exists it would probably be down in the CoreText 
> framework. Take a look there. 
> 
> —Jens 
> 
>> On Feb 26, 2016, at 2:16 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>> font, which might be “Some-Font” or “Nice Font” or anything else.
>> Or nil if this is not a well-formatted font file.
>> I do NOT want to install the font nor do anything with it.
>> 
>> Short of reverse-engeneering the ttf format (which probably would be rather 
>> too much): is there a way to get this?
>> 
>> Ideally I would line to do:
>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>> NSString *displayName = font.displayName;//font.fontName would 
>> probably also do
>> 
>> but this seems not to exist.

Alex Kac - El capitán


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 27 Feb 2016, at 00:37, Alex Kac  wrote:
> 
> Are you wanting this for any arbitrary font? I believe you can “install” a 
> font just for your application - and then use the NSFont methods to get it.
> 
> http://stackoverflow.com/questions/5283572/custom-font-in-a-cocoa-application

I do not want a fixed set of fonts to be included into my app. Rather I want my 
app to do things (to be precise: install them on my iOS devices) for any 
arbitrary font.
The solution suggested by Ken Thomases 
(CTFontManagerCreateFontDescriptorsFromURL ) works perfectly for me.

But thanks for the link - this might come in handy some other time.


Kind regards

Gerriet.

> 
>> On Feb 26, 2016, at 10:31 AM, Jens Alfke  wrote:
>> 
>> If this functionality exists it would probably be down in the CoreText 
>> framework. Take a look there. 
>> 
>> —Jens 
>> 
>>> On Feb 26, 2016, at 2:16 AM, Gerriet M. Denkmann  
>>> wrote:
>>> 
>>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>>> font, which might be “Some-Font” or “Nice Font” or anything else.
>>> Or nil if this is not a well-formatted font file.
>>> I do NOT want to install the font nor do anything with it.
>>> 
>>> Short of reverse-engeneering the ttf format (which probably would be rather 
>>> too much): is there a way to get this?
>>> 
>>> Ideally I would line to do:
>>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>>> NSString *displayName = font.displayName;//font.fontName would 
>>> probably also do
>>> 
>>> but this seems not to exist.
> 
> Alex Kac - El capitán
> 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

cycle windows

2016-02-26 Thread John Weeks
Is there a way to query the keyboard equivalent for Cycle Windows? Or maybe a 
notification of some sort that Cycle Windows has been triggered?

Thanks!

-John Weeks
WaveMetrics, inc.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Alex Zavatone
I've got this somewhere for iOS, I think.  Give me a sec and I'll dig it up.

On Feb 26, 2016, at 5:16 AM, Gerriet M. Denkmann wrote:

> I have a file “Some Font.ttf” and I want to know the displayName of this 
> font, which might be “Some-Font” or “Nice Font” or anything else.
> Or nil if this is not a well-formatted font file.
> I do NOT want to install the font nor do anything with it.
> 
> Short of reverse-engeneering the ttf format (which probably would be rather 
> too much): is there a way to get this?
> 
> Ideally I would line to do:
> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
> NSString *displayName = font.displayName; //  font.fontName would 
> probably also do
> 
> but this seems not to exist.
> 
> Gerriet.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Alex Zavatone
Hopefully, one of these will help.

#pragma mark - Font Util
//

- (void)dumpFonts {
for (NSString* family in [UIFont familyNames])   {
NSLog(@"Font Family = %@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])   {
NSLog(@"Font Name = %@", name);
}
}
}

// Ye olde schoole codee
- (void)dumpFontsx {
// List all fonts on iPhone
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
 [UIFont fontNamesForFamilyName:
  [familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(@"Font name: %@", [fontNames objectAtIndex:indFont]);
}
}
}





On Feb 26, 2016, at 2:17 PM, Alex Zavatone wrote:

> I've got this somewhere for iOS, I think.  Give me a sec and I'll dig it up.
> 
> On Feb 26, 2016, at 5:16 AM, Gerriet M. Denkmann wrote:
> 
>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>> font, which might be “Some-Font” or “Nice Font” or anything else.
>> Or nil if this is not a well-formatted font file.
>> I do NOT want to install the font nor do anything with it.
>> 
>> Short of reverse-engeneering the ttf format (which probably would be rather 
>> too much): is there a way to get this?
>> 
>> Ideally I would line to do:
>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>> NSString *displayName = font.displayName;//  font.fontName would 
>> probably also do
>> 
>> but this seems not to exist.
>> 
>> Gerriet.
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

SCNView : setting "overlaySKScene" doesn't render anything

2016-02-26 Thread Gavin Eadie
I have struggled long and hard with this .. I think I’ve looked at 'everything' 
related on Google, but I’m still flummoxed.

This is on Mac OS 10.11.3, build with Xcode 7.2, and this is what I think is 
the salient code.

override func viewDidLoad() {
super.viewDidLoad()

let scene = SCNScene()
let sceneView = self.view as! SCNView

sceneView.scene = scene
sceneView.overlaySKScene = OverlayScene(size: sceneView.bounds.size)
sceneView.backgroundColor = NSColor.blackColor()
sceneView.autoenablesDefaultLighting = true
sceneView.showsStatistics = true
}

('OverlayScene' generates a simple SKScene with some centered text)

On the Mac it works correctly if the window layout is described by a XIB.
On the Mac it doesn’t show the overlay if the window layout is described by a 
Storyboard.

The XIB and Storyboard are quite different (as is normal), but what in there 
could have this effect?

Any help to resolve this would be appreciated .. I suspect, as is often the 
case, I’m overlooking something obvious .. Thanks

FWIW: This same code works correctly on iOS using a Storyboard.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Eric Dolecki
I've used that dump fonts method before there was iosfonts.com to help. I 
haven't tried that in agrees but seems like it should do the trick. 

Sent from Outlook on my phone.




On Fri, Feb 26, 2016 at 11:23 AM -0800, "Alex Zavatone"  wrote:










Hopefully, one of these will help.

#pragma mark - Font Util
//

- (void)dumpFonts {
for (NSString* family in [UIFont familyNames])   {
NSLog(@"Font Family = %@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])   {
NSLog(@"Font Name = %@", name);
}
}
}

// Ye olde schoole codee
- (void)dumpFontsx {
// List all fonts on iPhone
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
 [UIFont fontNamesForFamilyName:
  [familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(@"Font name: %@", [fontNames objectAtIndex:indFont]);
}
}
}





On Feb 26, 2016, at 2:17 PM, Alex Zavatone wrote:

> I've got this somewhere for iOS, I think.  Give me a sec and I'll dig it up.
> 
> On Feb 26, 2016, at 5:16 AM, Gerriet M. Denkmann wrote:
> 
>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>> font, which might be “Some-Font” or “Nice Font” or anything else.
>> Or nil if this is not a well-formatted font file.
>> I do NOT want to install the font nor do anything with it.
>> 
>> Short of reverse-engeneering the ttf format (which probably would be rather 
>> too much): is there a way to get this?
>> 
>> Ideally I would line to do:
>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>> NSString *displayName = font.displayName;//  font.fontName would 
>> probably also do
>> 
>> but this seems not to exist.
>> 
>> Gerriet.
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/edolecki%40gmail.com

This email sent to edole...@gmail.com




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SCNView : setting "overlaySKScene" doesn't render anything

2016-02-26 Thread Gavin Eadie
The intelligence boosting power of posting a question strikes again.

The problem was that in the Mac OS X Storyboard, the "Rendering API" of the
SCNView was initialized to "unknown" when it needed to be "Metal"
(curiously, "OpenGL" and "Default" don't render the overlay either).  This
is the "renderingAPI" required property of the SCNRenderer protocol that
SCNView obeys; it's most easily set in IB.


On Fri, Feb 26, 2016 at 5:19 PM, Gavin Eadie  wrote:

> I have struggled long and hard with this .. I think I’ve looked at
> 'everything' related on Google, but I’m still flummoxed.
>
> This is on Mac OS 10.11.3, build with Xcode 7.2, and this is what I think
> is the salient code.
>
> override func viewDidLoad() {
> super.viewDidLoad()
>
> let scene = SCNScene()
> let sceneView = self.view as! SCNView
>
> sceneView.scene = scene
> sceneView.overlaySKScene = OverlayScene(size: sceneView.bounds.
> size)
> sceneView.backgroundColor = NSColor.blackColor()
> sceneView.autoenablesDefaultLighting = true
> sceneView.showsStatistics = true
> }
>
> ('OverlayScene' generates a simple SKScene with some centered text)
>
> On the Mac it works correctly if the window layout is described by a XIB.
> On the Mac it doesn’t show the overlay if the window layout is described
> by a Storyboard.
>
> The XIB and Storyboard are quite different (as is normal), but what in
> there could have this effect?
>
> Any help to resolve this would be appreciated .. I suspect, as is often
> the case, I’m overlooking something obvious .. Thanks
>
> FWIW: This same code works correctly on iOS using a Storyboard.
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSURLErrorKey vs. NSURLErrorFailingURLErrorKey

2016-02-26 Thread Jens Alfke
So, NSError.h declares NSURLErrorKey, as a userInfo key for the URL associated 
with the error.
And NSURLError.h declares NSURLErrorFailingURLErrorKey, which appears to have 
the same purpose.
Neither of these is deprecated, although there’s yet another constant 
(NSErrorFailingURLStringKey) that is.

What’s the difference between these? If I’m creating an NSError and adding a 
URL to it, which one is preferred?

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSURLErrorKey vs. NSURLErrorFailingURLErrorKey

2016-02-26 Thread Quincey Morris
On Feb 26, 2016, at 16:33 , Jens Alfke  wrote:
> 
> What’s the difference between these? If I’m creating an NSError and adding a 
> URL to it, which one is preferred?

According to NSError documentation:

> • NSURLErrorKey
> The corresponding value is an NSURL object.
> 
> • NSURLErrorFailingURLErrorKey
> The corresponding value is an NSURL containing the URL which caused a load to 
> fail. This key is only present in the NSURLErrorDomain.
> 
> • NSURLErrorFailingURLStringErrorKey
> The corresponding value is an NSString object for the URL which caused a load 
> to fail. This key is only present in the NSURLErrorDomain.
> 
> This constant supersedes NSErrorFailingURLStringKey, which was deprecated in 
> OS X v10.6. Both constants refer to the same value for 
> backward-compatibility, but this symbol name has a better prefix.

It sounds like NSURLErrorKey is what you want.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSURLErrorKey vs. NSURLErrorFailingURLErrorKey

2016-02-26 Thread dangerwillrobinsondanger
It seems like the shorter one would be for a "click here to see more 
information or open this file URL" and the longer one is for "this URL failed 
to load". 
But it definitely deserves a docs bug. 
It might be one of those obscure things noted in some programming guide doc, 
but even if it is that's too hard to find when the header and the class 
reference could be more explicit. 
That said, the structure of the NSError userInfo dictionary is pretty loosely 
defined to use as you please it seems. 

Sent from my iPhone

> On Feb 27, 2016, at 9:33 AM, Jens Alfke  wrote:
> 
> So, NSError.h declares NSURLErrorKey, as a userInfo key for the URL 
> associated with the error.
> And NSURLError.h declares NSURLErrorFailingURLErrorKey, which appears to have 
> the same purpose.
> Neither of these is deprecated, although there’s yet another constant 
> (NSErrorFailingURLStringKey) that is.
> 
> What’s the difference between these? If I’m creating an NSError and adding a 
> URL to it, which one is preferred?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSURLErrorKey vs. NSURLErrorFailingURLErrorKey

2016-02-26 Thread Jens Alfke

> On Feb 26, 2016, at 4:48 PM, Quincey Morris 
>  wrote:
> 
> According to NSError documentation:

Thanks, but I did read the documentation before asking.



> On Feb 26, 2016, at 4:53 PM, dangerwillrobinsondan...@gmail.com wrote:
> 
> It seems like the shorter one would be for a "click here to see more 
> information or open this file URL”

Oh god, that possibility hadn’t even occurred to me — some kind of link to put 
into the alert?
These are errors related to a REST API, and I’m recording the URL that the 
error occurred at, which is absolutely not something the user needs to see.

> That said, the structure of the NSError userInfo dictionary is pretty loosely 
> defined to use as you please it seems. 

I work on a framework, not an app. So the NSErrors that I create and return 
need to be interpreted properly by the app developer; either so they can take 
action based on the error, or so that they can display the error in a 
meaningful way. In this case, if I use the wrong key it sounds like the 
resulting error alert might contain the long and cryptic URL of some REST API 
endpoint, which is useless to the user.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSURLErrorKey vs. NSURLErrorFailingURLErrorKey

2016-02-26 Thread Quincey Morris
On Feb 26, 2016, at 18:12 , Jens Alfke  wrote:
> 
> Thanks, but I did read the documentation before asking.

Then your question makes no sense. One of the URL keys is specific to 
NSURLErrorDomain, and that isn’t your error domain to use. That means your only 
standard choice is the other URL key.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Ken Thomases
On Feb 26, 2016, at 7:17 AM, Gerriet M. Denkmann  wrote:
> 
> On 26 Feb 2016, at 17:33, Ken Thomases  wrote:
>> 
>> On Feb 26, 2016, at 4:16 AM, Gerriet M. Denkmann  
>> wrote:
>>> 
>>> I have a file “Some Font.ttf” and I want to know the displayName of this 
>>> font, which might be “Some-Font” or “Nice Font” or anything else.
>>> Or nil if this is not a well-formatted font file.
>>> I do NOT want to install the font nor do anything with it.
>>> 
>>> Short of reverse-engeneering the ttf format (which probably would be rather 
>>> too much): is there a way to get this?
>>> 
>>> Ideally I would line to do:
>>> NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
>>> NSString *displayName = font.displayName;   //  font.fontName would 
>>> probably also do
>>> 
>>> but this seems not to exist.
>> 
>> You can use CTFontManagerCreateFontDescriptorsFromURL() and then, for each 
>> descriptor, CTFontDescriptorCopyAttribute() with kCTFontDisplayNameAttribute.
>> 
>> Keep in mind that you may get multiple descriptors because a font file may 
>> include multiple fonts.  Consequently, there may be multiple display names.
> 
> Thanks a lot. Works perfectly.
> But did not find any font file which contains more than one descriptor. Any 
> examples (for testing)?

Well, the very first thing I found in Font Book was the American Typewriter 
font family, which is in /Library/Fonts/AmericanTypewriter.ttc.  That's a 
TrueType font collection file, which contains various weights of the font.

There are also font suitcase files such as /System/Library/Fonts/Times.dfont.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Getting displayName out of font file

2016-02-26 Thread Gerriet M. Denkmann

> On 27 Feb 2016, at 09:54, Ken Thomases  wrote:
> 
> On Feb 26, 2016, at 7:17 AM, Gerriet M. Denkmann  wrote:
>> 
>> On 26 Feb 2016, at 17:33, Ken Thomases  wrote:
>>> 
>>> On Feb 26, 2016, at 4:16 AM, Gerriet M. Denkmann  
>>> wrote:
 
 I have a file “Some Font.ttf” and I want to know the displayName of this 
 font, which might be “Some-Font” or “Nice Font” or anything else.
 Or nil if this is not a well-formatted font file.
 I do NOT want to install the font nor do anything with it.
 
 Short of reverse-engeneering the ttf format (which probably would be 
 rather too much): is there a way to get this?
 
 Ideally I would line to do:
 NSFont *font = [ NSFont fontFromFilePath: @“/path/to/Some Font.ttf” ];
 NSString *displayName = font.displayName;  //  font.fontName would 
 probably also do
 
 but this seems not to exist.
>>> 
>>> You can use CTFontManagerCreateFontDescriptorsFromURL() and then, for each 
>>> descriptor, CTFontDescriptorCopyAttribute() with 
>>> kCTFontDisplayNameAttribute.
>>> 
>>> Keep in mind that you may get multiple descriptors because a font file may 
>>> include multiple fonts.  Consequently, there may be multiple display names.
>> 
>> Thanks a lot. Works perfectly.
>> But did not find any font file which contains more than one descriptor. Any 
>> examples (for testing)?
> 
> Well, the very first thing I found in Font Book was the American Typewriter 
> font family, which is in /Library/Fonts/AmericanTypewriter.ttc.  That's a 
> TrueType font collection file, which contains various weights of the font.
> 
> There are also font suitcase files such as /System/Library/Fonts/Times.dfont.

Of the about 380 font files on my computer, slightly more than 100 contain 
multiple fonts; all .ttc or .dfont.
And there is just one .ttf font file (/Library/Fonts/Skia.ttf) which contains 
10 fonts (regular, bold, …).

Thanks very much for your help!


Kind regards,

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com