Adium

Changeset 13

Show
Ignore:
Timestamp:
12/15/2002 09:28:32 AM (6 years ago)
Author:
adamiser
Message:

Fixed a crash when recieving messages with a font not installed on the user's system. Now Adium will default back to helvetica.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/adium/Frameworks/AIUtilities Framework/AITextAttributes.m

    r4 r13  
    1919 
    2020#import "AITextAttributes.h" 
     21#define FONT_DEFAULT_NAME       @"Helvetica" 
    2122 
    2223@interface AITextAttributes (PRIVATE) 
     
    120121- (void)updateFont 
    121122{ 
    122     [dictionary setObject:[[NSFontManager sharedFontManager] fontWithFamily:fontFamilyName traits:fontTraitsMask weight:5 size:fontSize] forKey:NSFontAttributeName]; 
     123    NSFont      *font = nil; 
     124 
     125    //Ensure font size isn't 0 
     126    if(!fontSize) fontSize = 12; 
     127 
     128    //Create the font 
     129    if(fontFamilyName){ 
     130        font = [[NSFontManager sharedFontManager] fontWithFamily:fontFamilyName traits:fontTraitsMask weight:5 size:fontSize]; 
     131    } 
    123132     
     133    //If no name was specified or the font is not available, use the default font 
     134    if(!font){ 
     135        font = [[NSFontManager sharedFontManager] fontWithFamily:FONT_DEFAULT_NAME traits:fontTraitsMask weight:5 size:fontSize]; 
     136    } 
     137 
     138    if(font){ //Just to be safe, incase the default font was unavailable for some reason 
     139        [dictionary setObject:font forKey:NSFontAttributeName]; 
     140    } 
    124141} 
    125142