How to get a condensed San Francisco UIFont?

2015-10-07 Thread David Hoerl
I'd like to do is get a condensed - or better yet - a bold (semi-bold) 
condensed version of the "San Francisco" system font.


What I propose to do is get a "starter" font:

  let font = UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)

then get the font descriptor:

  let fd1 = font.fontDescriptor()

then add a "condensed" attribute:

  let fd2 = fd1.fontDescriptorByAddingAttributes[ the magic sauce ]

  let finalFont = UIFont(descriptor: fd2, size: 0)

My only problem is I don't know the "magic sauce", and there is a darth 
of information on fontDescriptorByAddingAttributes (google it yourself).


I sure would appreciate anyone who can tell me, or point me in the right 
direction, so I can find the "magic sauce" formula.


- David
___

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: How to get a condensed San Francisco UIFont?

2015-10-07 Thread Kevin Meaney
I believe the CoreText attributes should work.

The attribute key of kCTFontTraitsAttribute with a value of TraitCondensed 
might do the trick.

Kevin

> On 8 Oct 2015, at 00:01, David Hoerl  wrote:
> 
> I'd like to do is get a condensed - or better yet - a bold (semi-bold) 
> condensed version of the "San Francisco" system font.
> 
> What I propose to do is get a "starter" font:
> 
>  let font = UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
> 
> then get the font descriptor:
> 
>  let fd1 = font.fontDescriptor()
> 
> then add a "condensed" attribute:
> 
>  let fd2 = fd1.fontDescriptorByAddingAttributes[ the magic sauce ]
> 
>  let finalFont = UIFont(descriptor: fd2, size: 0)
> 
> My only problem is I don't know the "magic sauce", and there is a darth of 
> information on fontDescriptorByAddingAttributes (google it yourself).
> 
> I sure would appreciate anyone who can tell me, or point me in the right 
> direction, so I can find the "magic sauce" formula.
> 
> - David
> ___
> 
> 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/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.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: CFBundleSupportedPlatforms issue

2015-10-07 Thread Rick C.
Thanks for the help but there is only one OS X Deployment Target for my entire 
app not one for each included binary.  I really don’t see a place to change any 
settings for the binaries?



> On 7 Oct 2015, at 2:24 PM, Charles Srstka  wrote:
> 
>> On Oct 5, 2015, at 2:40 AM, Rick C. > > wrote:
>> 
>> Couldn't find platform family in Info.plist CFBundleSupportedPlatforms or 
>> Mach-O LC_VERSION_MIN for myBinary
> 
> Actually reading this again, before you bother with the Info.plist suggestion 
> I just sent, why don’t you check “OS X Deployment Target” in the build 
> settings and make sure they’re set to the same thing for your app and your 
> included binaries? Setting the OS X Deployment Target should cause 
> LC_VERSION_MIN to be added to the Mach-O binary.
> 
> Charles
> 

___

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: How to get a condensed San Francisco UIFont?

2015-10-07 Thread Jens Alfke

> On Oct 7, 2015, at 4:01 PM, David Hoerl  wrote:
> 
> then add a "condensed" attribute:
>  let fd2 = fd1.fontDescriptorByAddingAttributes[ the magic sauce ]

I haven’t used this API, but from looking at the header, I would try:

let fd2 = fd1.fontDescriptorWithSymbolicTraits(.Condensed)

—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: CFBundleSupportedPlatforms issue

2015-10-07 Thread Charles Srstka
> On Oct 5, 2015, at 2:40 AM, Rick C.  wrote:
> 
> Couldn't find platform family in Info.plist CFBundleSupportedPlatforms or 
> Mach-O LC_VERSION_MIN for myBinary

Actually reading this again, before you bother with the Info.plist suggestion I 
just sent, why don’t you check “OS X Deployment Target” in the build settings 
and make sure they’re set to the same thing for your app and your included 
binaries? Setting the OS X Deployment Target should cause LC_VERSION_MIN to be 
added to the Mach-O binary.

Charles

___

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: CFBundleSupportedPlatforms issue

2015-10-07 Thread Charles Srstka
> On Oct 5, 2015, at 2:40 AM, Rick C.  wrote:
> 
> I have 3 pre-complied binaries inside of my project.  They do have their own 
> entitlements files and they are codesigned but they do not have their own 
> Info.plist.

What happens if you give them one? You can embed an Info.plist inside a Mach-O 
binary by adding this to Other Linker Flags in Xcode’s build settings:

-sectcreate __TEXT __info_plist /path/to/Info.plist

Charles

___

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: NSSplitViewController : not in Interface Builder library?

2015-10-07 Thread Jerry Krinock

> On 2015 Sep 16, at 08:48, Bill Cheeseman  wrote:
> 
> I recently spent two weeks trying to get NSSplitViewController to work 
> programmatically in an application with nibs, without success. I got close, 
> and I concluded that it probably can be done, but I gave up because it was 
> taking too much time. I'm also having a lot of trouble getting it to work in 
> storyboards, so i think maybe it still isn't ready for prime time. (This was 
> in OS X 10.11 El Capitan late-beta.)

Well, I’ve found that at least one bug has been fixed in 10.11 GM.

At long last, we were able to get a “fixed width” (fully expanded or fully 
collapsed) sidebar with nice animations (contrast to the Mailbox List sidebar 
in Mail.app), in a nib, using NSSplitViewController.  Here is the demo project:

https://github.com/jerrykrinock/SplitViewSidebar.git


___

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: NSTextField subclass needs cell subclass as well - how?

2015-10-07 Thread Quincey Morris
On Oct 7, 2015, at 21:08 , Graham Cox  wrote:
> 
> Radar time.

If you’re going that route, it sure seems like ‘cellClass’ shouldn’t not be 
called — if it’s not possible to use it, then “deprecated” seems like a 
mis-description. But perhaps there’s a pattern of old methods to implement that 
triggers the old behavior, sort of like the way things work in NSDocument.
___

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

NSTextField subclass needs cell subclass as well - how?

2015-10-07 Thread Graham Cox
I have a NSTextField subclass that must currently also always have a 
NSTextFieldCell subclass internally (which in turn is needed only to provide a 
custom Field Editor when needed).

In 10.10, cells are deprecated, though the cell is still there. I previously 
returned the custom class from +cellClass, but this is now deprecated and no 
longer called. The documentation states that +setCellClass: can be called from 
-awakeFromNib to set a custom cell class, but that method is also deprecated 
and it doesn’t do what the documentation says anyway (if it ever did - first 
time I’ve tried this).

What can I do to make sure that the text fields get the necessary custom cell?

I *can* set the cell class in IB, and that’s fine as such, but I’d rather do it 
in code, because I have hundreds of these fields and it would be a lot simpler 
to simply set the cell class once in code instead of hundreds of times in IB.

I understand that cells are going away, but there currently doesn’t seem to be 
a replacement for returning a custom field editor for a given text field that 
doesn’t involve its cell. If there is, and I’ve missed it, that would be a 
better solution, so maybe someone could point me at what I should be doing.

—Graham



___

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: NSTextField subclass needs cell subclass as well - how?

2015-10-07 Thread Graham Cox

> On 8 Oct 2015, at 11:50 am, Graham Cox  wrote:
> 
> I understand that cells are going away, but there currently doesn’t seem to 
> be a replacement for returning a custom field editor for a given text field 
> that doesn’t involve its cell. If there is, and I’ve missed it, that would be 
> a better solution, so maybe someone could point me at what I should be doing.


I should just clarify: I do know about NSWindow and the window delegate’s 
involvement in returning a Field Editor, but it’s a poor fit for what I want to 
do in this case, which is to provide a custom Field Editor only for some 
specific fields, which are loaded dynamically and could end up in any of 
several different windows, which otherwise need to know nothing about them.

-[NSCell fieldEditorForView:] does exactly what I need, and it’s documented for 
this exact purpose. Unfortunately it’s a method of NSCell, not of NSControl, 
and so far it has no replacement in NSControl that can be used as cells are 
deprecated.

—Graham



___

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: NSTextField subclass needs cell subclass as well - how?

2015-10-07 Thread Graham Cox

> On 8 Oct 2015, at 2:33 pm, Quincey Morris 
>  wrote:
> 
> These statements sound a bit contradictory to me, but never mind.


Well, they shouldn’t be, I daresay my usual inabilty to express these things is 
getting in the way. My interface is very dynamic, with many different ‘panels’ 
that can be placed into a window according to some context. Each panel is a 
view managed by a NSViewController which loads its interface from a separate 
nib. These panels could have many text fields, most of which are the custom 
kind, but some are standard. Because of this dynamic loading, the window 
delegate of the host window(s) isn’t a good place to try and figure out what 
dynamic stuff is loaded at any given time.

The window doesn’t know or care about this dynamic stuff - it’s largely 
autonomous and independent of the window and its controller.

Likewise the dynamic stuff itself, those nib files can’t know anything about 
the window into which they’re ultimately loaded. There’s no reference that 
could be connected in IB even if this was a good idea, which it isn’t.


> You’re asking about swapping out the cells of text fields programmatically. 
> Is is technically impossible for you to swap out the text fields themselves? 
> (If necessary, by loading the affected controls uncustomized at first, then 
> replacing them with customized ones loaded from a text field nib that has a 
> custom cell set in IB?)


It might be technically feasible, but it sounds like the cure is worse than the 
disease :)

I’ve tried swapping out the text field’s cell by creating a subclass and 
copying all of the original settings into it. Unfortunately that doesn’t work - 
just copying across the state isn’t enough to make the replacement cell look 
and act like the original text field cell, for some reason - presumably there’s 
some order-dependent setup or other hidden stuff in the ‘real’ text field cell 
that I can’t get at.

I haven’t tried swapping the text field itself but it seems probable that would 
suffer the same fate - I’d have to copy all the state from the ‘real’ field and 
it doesn’t seem likely that’s going to work perfectly.

-[NSCell fieldEditorForView:] does exactly what I need. Only that it’s a cell 
method, not a control method. That’s the sole reason I need a custom text field 
cell, so I can override this method. If this had a cover method on NSControl, I 
wouldn’t have to do that. As cells go away, a cover method is going to be 
needed to maintain the same functionality, it just doesn’t seem to exist yet 
(or is private).

Radar time.

—Graham



___

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: NSTextField subclass needs cell subclass as well - how?

2015-10-07 Thread Quincey Morris
On Oct 7, 2015, at 17:50 , Graham Cox  wrote:
> 
>  I’d rather do it in code, because I have hundreds of these fields and it 
> would be a lot simpler to simply set the cell class once in code instead of 
> hundreds of times in IB.

On Oct 7, 2015, at 20:13 , Graham Cox  wrote:
> 
> what I want to do in this case, which is to provide a custom Field Editor 
> only for some specific fields, which are loaded dynamically and could end up 
> in any of several different windows

These statements sound a bit contradictory to me, but never mind. You’re asking 
about swapping out the cells of text fields programmatically. Is is technically 
impossible for you to swap out the text fields themselves? (If necessary, by 
loading the affected controls uncustomized at first, then replacing them with 
customized ones loaded from a text field nib that has a custom cell set in IB?)
___

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: AVMetadataItem key

2015-10-07 Thread Jan E. Schotsman


On Oct 5, 2015, at 12:39 AM, Fritz Anderson wrote:

On Oct 1, 2015, at 3:59 PM, Jan E. Schotsman   
wrote:


I have an AVMetaDataItem with
key = protocol? Int32(1851878757)
as shown by the debugger

How can can extract the value 1851878757 which is the four char  
code I need?

Using Swift 2


My cut at a UInt32-to-OSType (four-byte string) converter is at the  
end of this message. The doc comment should speak for itself.


Actually I got stuck because this did not work:

if let myNumber  = item.key as? UInt32

Next morning I realized I should try

if let myNumber  = item.key as? Int

which does work.

I had already defined a four char code struct. This is the improved  
version inspired by your function:


/*  
- */

struct MyFCC:Equatable,CustomStringConvertible // four char code
{
var string = String()

init( _ fcc:String ) { string = fcc }

	init?( rawCString:UnsafePointer, encoding:UInt =  
NSMacOSRomanStringEncoding )

{
let tempStr = String( CString:rawCString, encoding:encoding )
if tempStr == nil {return nil}
else
{
string = tempStr!
if string.utf8.count != 4 {return nil}
}
}

	init?( ptr:UnsafePointer, offset:Int = 0, encoding:UInt =  
NSMacOSRomanStringEncoding )

{
let codePtr = GL_FourBytesToRawCStringFromPtr( ptr, 
offset:offset )
self.init( rawCString:codePtr, encoding:encoding )
codePtr.destroy()
}

init?( var uint32:UInt32 )
{
let ptr = withUnsafePointer(){$0}
self.init( ptr:UnsafePointer(ptr) )
}

init?( data:NSData, offset:Int = 0 )
{
if data.length >= 4*(offset+1)
{
self.init( ptr:UnsafePointer(data.bytes), 
offset:offset )
}
else { return nil }
}

init?( readFromQuickTimeFile fileHandle:NSFileHandle )
{
let theData = fileHandle.readDataOfLength(4)
self.init( data:theData )
self.byteSwap()
}

var data:NSData
{
return self.string.withCString{ NSData( bytes:$0, length:4 ) }
}

var uint32:UInt32
{
return UnsafePointer(self.data.bytes)[0]
}

	mutating func byteSwap(){ self =  
self.dynamicType.init( uint32:self.uint32.byteSwapped )! }


mutating func sanitize()
{
// replace unacceptable characters by ...
}

func copyToPtr( ptr:UnsafeMutablePointer, offset:Int = 0 )
{
ptr[offset] = UnsafeMutablePointer(self.data.bytes)[0]
}

func writeToQuickTimeFile( fileHandle:NSFileHandle )
{
var temp = self
temp.byteSwap()
fileHandle.writeData( temp.data )
}

var description:String {return "FCC " + self.string}
}

/*  
- */
func GL_FourBytesToRawCStringFromPtr( ptr:UnsafePointer,  
offset:Int = 0 )->UnsafeMutablePointer

{
let codePtr = UnsafeMutablePointer.alloc(5)
for index in 0 ..< 4 { codePtr[index] = ptr[index+4*offset] }
codePtr[4] = 0

return codePtr
}

/*  
- */

func == (lhs:GL_FCC, rhs:GL_FCC)->Bool
{
return lhs.string == rhs.string
}

Playground test:

var myFcc  = MyFCC("name")// FCC name
myFcc.byteSwap()// FCC eman

var myFcc2 = MyFCC( uint32: 1851878757) // FCC eman
let data = myFcc2!.data // <656d616e>
let myFcc3 = MyFCC( data: data )// FCC eman

var equal = myFcc == myFcc2 // true
let myFcc4 = MyFCC("moov")// FCC moov
equal = myFcc == myFcc4 // false

let myFcc5 = MyFCC(uint32:0)// nil
let myFcc6 = MyFCC(uint32:0x)   // nil
let myFcc7 = MyFCC("0!?-")// FCC 0!?-

Jan E.
___

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