> On 24 Feb 2015, at 05:08, Jens Alfke <[email protected]> wrote:
> 
>> On Feb 23, 2015, at 8:49 AM, sqwarqDev <[email protected]> wrote:
>> 
>> How do I programmatically tell each NSControl to increase its text size 
>> proportionally as its bounds increase?
> 
> You’ll have to do it manually. Observe the control’s frame, then when it 
> changes compute a new font size and update the control’s font.
> 
> (The easy way is to assume that text width scales linearly with font size; 
> strictly speaking this isn’t always true, but it’s probably true of any 
> standard system font like Helvetica that you’d be displaying in a control.)
> 


Thanks all. There's a fairly in-depth discussion covering many of the more 
complex scenarios here:

http://www.cocoabuilder.com/archive/cocoa/303445-linearly-scaling-text.html

However, my needs were fairly simple, and I was able to effect a satisfactory 
solution with the following:

- (void)windowDidResize:(NSNotification *)notification {
    
    float a = 110;
    NSSize myNSWindowSize = [[window contentView ] frame ].size;

    if (myNSWindowSize.height > 220) {
        if (myNSWindowSize.width > myNSWindowSize.height) {
            a = myNSWindowSize.height/2.4;
        } else {
            a = myNSWindowSize.width/3.8;
        }
    }

    NSFont *f = [NSFont fontWithName:@"Helvetica Neue" size:a];
    [textField setFont:f];
        
}



Best

Phil

DisplayDroid beta (a lightweight script editor and automation tool) is now 
available for free download. More info on sqwarq.com/displaydroid
OSXClock - big, beautiful alarm clock and timer for your mac. More info on 
sqwarq.com/osxclock

http://applehelpwriter.com
http://sqwarq.com - apps for OS X & iOS











_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to