One Quickie


Draw a string in bold (NSString->Graphics)
- (void) drawLabel: (NSString *) label
           atPoint: (NSPoint) point
              bold: (BOOL) bold {
    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
    NSFont *currentFont = [NSFont userFontOfSize: 14.0];

    if (bold) {
	NSFontManager *fm = [NSFontManager sharedFontManager];
	NSFont *boldFont = [fm convertFont: currentFont
                               toHaveTrait: NSBoldFontMask];
	[attributes setObject: boldFont
                    forKey: NSFontAttributeName];
    } else {
	[attributes setObject: currentFont
                    forKey: NSFontAttributeName];
    }

    [label drawAtPoint: point  withAttributes: attributes];;

} // drawLabel



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com