More changes for the fonts prefs panel.

This commit is contained in:
sfraser%netscape.com 2002-07-16 17:43:43 +00:00
Родитель b0651090a1
Коммит f51bd3348e
16 изменённых файлов: 184 добавлений и 190 удалений

Просмотреть файл

@ -25,6 +25,7 @@
IBOutlet NSTextField *fontSampleSerif; IBOutlet NSTextField *fontSampleSerif;
IBOutlet NSTextField *fontSampleSansSerif; IBOutlet NSTextField *fontSampleSansSerif;
IBOutlet NSTextField *fontSampleMonospace; IBOutlet NSTextField *fontSampleMonospace;
IBOutlet NSTextField *fontSampleCursive;
NSArray *regionMappingTable; NSArray *regionMappingTable;
} }

Просмотреть файл

@ -13,10 +13,6 @@
#include "nsIPref.h" #include "nsIPref.h"
#include "nsIMemory.h" #include "nsIMemory.h"
// Use a category to put a changeFont message onto the tab view
@interface NSTabView (FontManagerDelegate)
- (void)changeFont:(id)sender;
@end
@interface OrgMozillaChimeraPreferenceAppearance(Private) @interface OrgMozillaChimeraPreferenceAppearance(Private)
@ -41,6 +37,7 @@
@end @end
@implementation OrgMozillaChimeraPreferenceAppearance @implementation OrgMozillaChimeraPreferenceAppearance
- (void) dealloc - (void) dealloc
@ -48,6 +45,12 @@
[regionMappingTable release]; [regionMappingTable release];
} }
- (id)initWithBundle:(NSBundle *)bundle
{
self = [super initWithBundle:bundle];
return self;
}
- (void) mainViewDidLoad - (void) mainViewDidLoad
{ {
BOOL gotPref; BOOL gotPref;
@ -65,7 +68,10 @@
[colorwellVisitedLinks setColor:[self getColorPref:"browser.visited_color" withSuccess:&gotPref]]; [colorwellVisitedLinks setColor:[self getColorPref:"browser.visited_color" withSuccess:&gotPref]];
[self setupFontRegionTable]; [self setupFontRegionTable];
[NSFontManager sharedFontManager];
// prep the font panel
NSFontPanel *fontPanel = [[NSFontManager sharedFontManager] fontPanel:YES];
//[fontPanel setBecomesKeyOnlyIfNeeded:NO];
} }
- (void)willUnselect - (void)willUnselect
@ -85,8 +91,12 @@
regionMappingTable = [[NSArray arrayWithContentsOfFile:resPath] retain]; regionMappingTable = [[NSArray arrayWithContentsOfFile:resPath] retain];
[self loadFontPrefs]; [self loadFontPrefs];
[tableViewFontRegion reloadData]; [tableViewFontRegion reloadData];
if ([tableViewFontRegion selectedRow] == 0)
[tableViewFontRegion selectRow:-1 byExtendingSelection:NO]; // make sure the next line triggers a change
[tableViewFontRegion selectRow:0 byExtendingSelection:NO]; // trigger initial setup [tableViewFontRegion selectRow:0 byExtendingSelection:NO]; // trigger initial setup
} }
@ -122,7 +132,9 @@
- (IBAction)fontChoiceButtonClicked:(id)sender - (IBAction)fontChoiceButtonClicked:(id)sender
{ {
[self syncFontPanel]; [self syncFontPanel];
[[NSFontManager sharedFontManager] orderFrontFontPanel:self];
NSFontPanel *fontPanel = [[NSFontManager sharedFontManager] fontPanel:YES];
[fontPanel makeKeyAndOrderFront:self];
} }
- (IBAction)fontRegionListClicked:(id)sender - (IBAction)fontRegionListClicked:(id)sender
@ -140,26 +152,33 @@
/* /*
For each region in the array, there is a dictionary of For each region in the array, there is a dictionary of
{ {
region =
code = code =
region = (from localized strings file)
to which we add here a sub-dictionary per font type, thus: to which we add here a sub-dictionary per font type, thus:
serif = { serif = {
fontname = fontfamily = Times-Regular
fontsize = fontsize = 16
} }
sans-serif = { sans-serif = {
fontname = fontfamily =
fontsize = fontsize =
missing = // set if a font is missing missing = // set if a font is missing
} }
monospace = { monospace = {
fontname = fontfamily =
fontsize =
}
cursive = {
fontfamily =
fontsize = fontsize =
} }
} }
*/ */
NSString *regionName = NSLocalizedStringFromTableInBundle(regionCode, @"RegionNames",
[NSBundle bundleForClass:[OrgMozillaChimeraPreferenceAppearance class]], @"");
[regionDict setObject:regionName forKey:@"region"];
NSMutableDictionary *serifDict = [self makeDictFromPrefsForFontType:@"serif" andRegion:regionCode]; NSMutableDictionary *serifDict = [self makeDictFromPrefsForFontType:@"serif" andRegion:regionCode];
[regionDict setObject:serifDict forKey:@"serif"]; [regionDict setObject:serifDict forKey:@"serif"];
@ -169,6 +188,9 @@
NSMutableDictionary *monoDict = [self makeDictFromPrefsForFontType:@"monospace" andRegion:regionCode]; NSMutableDictionary *monoDict = [self makeDictFromPrefsForFontType:@"monospace" andRegion:regionCode];
[regionDict setObject:monoDict forKey:@"monospace"]; [regionDict setObject:monoDict forKey:@"monospace"];
NSMutableDictionary *cursDict = [self makeDictFromPrefsForFontType:@"cursive" andRegion:regionCode];
[regionDict setObject:cursDict forKey:@"cursive"];
} }
} }
@ -185,6 +207,7 @@
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"serif"]; [self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"serif"];
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"sans-serif"]; [self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"sans-serif"];
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"monospace"]; [self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"monospace"];
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"cursive"];
} }
} }
@ -206,7 +229,7 @@
if (gotPref && gotSize) if (gotPref && gotSize)
{ {
[fontDict setObject:fontName forKey:@"fontname"]; [fontDict setObject:fontName forKey:@"fontfamily"];
[fontDict setObject:[NSNumber numberWithInt:fontSize] forKey:@"fontsize"]; [fontDict setObject:[NSNumber numberWithInt:fontSize] forKey:@"fontsize"];
} }
@ -220,7 +243,7 @@
if (!fontTypeDict || !regionCode) return; if (!fontTypeDict || !regionCode) return;
NSString *fontName = [fontTypeDict objectForKey:@"fontname"]; NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue]; int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue];
NSString *fontPrefName = [NSString stringWithFormat:@"font.name.%@.%@", fontType, regionCode]; NSString *fontPrefName = [NSString stringWithFormat:@"font.name.%@.%@", fontType, regionCode];
@ -249,7 +272,7 @@
if (theFont) if (theFont)
{ {
[fontTypeDict setObject:[theFont familyName] forKey:@"fontname"]; [fontTypeDict setObject:[theFont familyName] forKey:@"fontfamily"];
[fontTypeDict setObject:[NSNumber numberWithInt:(int)[theFont pointSize]] forKey:@"fontsize"]; [fontTypeDict setObject:[NSNumber numberWithInt:(int)[theFont pointSize]] forKey:@"fontsize"];
} }
} }
@ -257,15 +280,20 @@
- (NSFont*)getFontOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict; - (NSFont*)getFontOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict;
{ {
NSDictionary *fontTypeDict = [regionDict objectForKey:fontType]; NSDictionary *fontTypeDict = [regionDict objectForKey:fontType];
NSString *fontName = [fontTypeDict objectForKey:@"fontname"]; NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue]; int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue];
NSFont *returnFont = nil; NSFont *returnFont = nil;
if (fontName && fontSize > 0) if (fontName && fontSize > 0)
returnFont = [NSFont fontWithName:fontName size:fontSize]; {
// we can't use [NSFont fontWithName] here, because we only store font
// family names in the prefs file. So use the font manager instead
// returnFont = [NSFont fontWithName:fontName size:fontSize];
returnFont = [[NSFontManager sharedFontManager] fontWithFamily:fontName traits:0 weight:5 size:fontSize];
}
else if (fontName) // no size else if (fontName) // no size
returnFont = [NSFont fontWithName:fontName size:16.0]; returnFont = [[NSFontManager sharedFontManager] fontWithFamily:fontName traits:0 weight:5 size:16.0];
/* /*
if (returnFont == nil) if (returnFont == nil)
@ -283,6 +311,7 @@
[self setupFontSampleOfType:@"serif" fromDict:regionDict]; [self setupFontSampleOfType:@"serif" fromDict:regionDict];
[self setupFontSampleOfType:@"sans-serif" fromDict:regionDict]; [self setupFontSampleOfType:@"sans-serif" fromDict:regionDict];
[self setupFontSampleOfType:@"monospace" fromDict:regionDict]; [self setupFontSampleOfType:@"monospace" fromDict:regionDict];
[self setupFontSampleOfType:@"cursive" fromDict:regionDict];
} }
- (void)setupFontSampleOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict; - (void)setupFontSampleOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict;
@ -297,14 +326,14 @@
// a string to display from the dict. // a string to display from the dict.
NSMutableDictionary *fontTypeDict = [regionDict objectForKey:fontType]; NSMutableDictionary *fontTypeDict = [regionDict objectForKey:fontType];
NSTextField *textField = [self getFontSampleForType:fontType]; NSTextField *sampleCell = [self getFontSampleForType:fontType];
NSString *displayString = nil; NSString *displayString = nil;
if (font == nil) if (font == nil)
{ {
if (regionDict) if (regionDict)
{ {
NSString *fontName = [fontTypeDict objectForKey:@"fontname"]; NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue]; int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue];
// XXX localize // XXX localize
@ -338,8 +367,8 @@
[fontTypeDict removeObjectForKey:@"missing"]; [fontTypeDict removeObjectForKey:@"missing"];
} }
[textField setFont:font]; [sampleCell setFont:font];
[textField setStringValue:displayString]; [sampleCell setStringValue:displayString];
} }
- (void)updateFontSampleOfType:(NSString *)fontType - (void)updateFontSampleOfType:(NSString *)fontType
@ -350,8 +379,8 @@
NSMutableDictionary *regionDict = [regionMappingTable objectAtIndex:selectedRow]; NSMutableDictionary *regionDict = [regionMappingTable objectAtIndex:selectedRow];
NSTextField *textField = [self getFontSampleForType:fontType]; NSTextField *sampleCell = [self getFontSampleForType:fontType];
NSFont *sampleFont = [[NSFontManager sharedFontManager] convertFont:[textField font]]; NSFont *sampleFont = [[NSFontManager sharedFontManager] convertFont:[sampleCell font]];
[self setFontSampleOfType:fontType withFont:sampleFont andDict:regionDict]; [self setFontSampleOfType:fontType withFont:sampleFont andDict:regionDict];
} }
@ -367,6 +396,9 @@
if ([fontType isEqualToString:@"monospace"]) if ([fontType isEqualToString:@"monospace"])
return fontSampleMonospace; return fontSampleMonospace;
if ([fontType isEqualToString:@"cursive"])
return fontSampleCursive;
return nil; return nil;
} }
@ -389,6 +421,7 @@
[self saveFontsToDict:regionDict forFontType:@"serif"]; [self saveFontsToDict:regionDict forFontType:@"serif"];
[self saveFontsToDict:regionDict forFontType:@"sans-serif"]; [self saveFontsToDict:regionDict forFontType:@"sans-serif"];
[self saveFontsToDict:regionDict forFontType:@"monospace"]; [self saveFontsToDict:regionDict forFontType:@"monospace"];
[self saveFontsToDict:regionDict forFontType:@"cursive"];
} }
@end @end
@ -397,8 +430,6 @@
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{ {
NSLog(@"Table selection changed");
if ([aNotification object] != tableViewFontRegion) if ([aNotification object] != tableViewFontRegion)
return; return;
@ -459,21 +490,3 @@
} }
@end @end
// Use a category to put a changeFont message onto the tab view (since this
// is guaranteed to be in the repsonder chain. We've set the tab view's delegate
// to be the file's owner in IB, so we just forward the message.
@implementation NSTabView (FontManagerDelegate)
- (void)changeFont:(id)sender
{
[[self delegate] changeFont:sender];
}
- (BOOL)fontManager:(id)theFontManager willIncludeFont:(NSString *)fontName
{
NSLog(@"willIncludeFont called");
return YES;
}
@end

Просмотреть файл

@ -1,7 +1,13 @@
{ {
IBClasses = ( IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = FontChangeReceiver; LANGUAGE = ObjC; SUPERCLASS = NSView; }, {
ACTIONS = {};
CLASS = FontReceiverView;
LANGUAGE = ObjC;
OUTLETS = {delegate = id; };
SUPERCLASS = NSView;
},
{ {
CLASS = NSPreferencePane; CLASS = NSPreferencePane;
LANGUAGE = ObjC; LANGUAGE = ObjC;
@ -24,6 +30,7 @@
colorwellTextColor = NSColorWell; colorwellTextColor = NSColorWell;
colorwellUnvisitedLinks = NSColorWell; colorwellUnvisitedLinks = NSColorWell;
colorwellVisitedLinks = NSColorWell; colorwellVisitedLinks = NSColorWell;
fontSampleCursive = NSTextField;
fontSampleMonospace = NSTextField; fontSampleMonospace = NSTextField;
fontSampleSansSerif = NSTextField; fontSampleSansSerif = NSTextField;
fontSampleSerif = NSTextField; fontSampleSerif = NSTextField;

Двоичные данные
camino/PreferencePanes/Appearance/Appearance.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -1,7 +1,13 @@
{ {
IBClasses = ( IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = FontChangeReceiver; LANGUAGE = ObjC; SUPERCLASS = NSView; }, {
ACTIONS = {};
CLASS = FontReceiverView;
LANGUAGE = ObjC;
OUTLETS = {delegate = id; };
SUPERCLASS = NSView;
},
{ {
CLASS = NSPreferencePane; CLASS = NSPreferencePane;
LANGUAGE = ObjC; LANGUAGE = ObjC;
@ -24,6 +30,7 @@
colorwellTextColor = NSColorWell; colorwellTextColor = NSColorWell;
colorwellUnvisitedLinks = NSColorWell; colorwellUnvisitedLinks = NSColorWell;
colorwellVisitedLinks = NSColorWell; colorwellVisitedLinks = NSColorWell;
fontSampleCursive = NSTextField;
fontSampleMonospace = NSTextField; fontSampleMonospace = NSTextField;
fontSampleSansSerif = NSTextField; fontSampleSansSerif = NSTextField;
fontSampleSerif = NSTextField; fontSampleSerif = NSTextField;

Двоичные данные
camino/PreferencePanes/Appearance/English.lproj/Appearance.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,15 @@
"x-western" = "Western";
"x-central-euro" = "Central European";
"x-cyrillic" = "Cyrillic";
"x-baltic" = "Baltic";
"el" = "Greek";
"tr" = "Turkish";
"he" = "Hebrew";
"ar" = "Arabic";
"ko" = "Korean";
"th" = "Thai";
"zh-TW" = "Traditional Chinese";
"zh-CN" = "Simplified Chinese";
"ja" = "Japanese";
"x-unicode" = "Unicode";
"x-user-def" = "User-Defined";

Просмотреть файл

@ -1,62 +1,47 @@
( (
{ {
region = "Western";
code = "x-western"; code = "x-western";
}, },
{ {
region = "Central European";
code = "x-central-euro"; code = "x-central-euro";
}, },
{ {
region = "Japanese";
code = "ja";
},
{
region = "Traditional Chinese";
code = "zh-TW";
},
{
region = "Simplified Chinese";
code = "zh-CN";
},
{
region = "Korean";
code = "ko";
},
{
region = "Cyrillic";
code = "x-cyrillic"; code = "x-cyrillic";
}, },
{ {
region = "Baltic";
code = "x-baltic"; code = "x-baltic";
}, },
{ {
region = "Greek";
code = "el"; code = "el";
}, },
{ {
region = "Turkish";
code = "tr"; code = "tr";
}, },
{ {
region = "Unicode";
code = "x-unicode";
},
{
region = "User-Defined";
code = "x-user-def";
},
{
region = "Thai";
code = "th";
},
{
region = "Hebrew";
code = "he"; code = "he";
}, },
{ {
region = "Arabic";
code = "ar"; code = "ar";
},
{
code = "ko";
},
{
code = "th";
},
{
code = "zh-TW";
},
{
code = "zh-CN";
},
{
code = "ja";
},
{
code = "x-unicode";
},
{
code = "x-user-def";
} }
) )

Просмотреть файл

@ -25,6 +25,7 @@
IBOutlet NSTextField *fontSampleSerif; IBOutlet NSTextField *fontSampleSerif;
IBOutlet NSTextField *fontSampleSansSerif; IBOutlet NSTextField *fontSampleSansSerif;
IBOutlet NSTextField *fontSampleMonospace; IBOutlet NSTextField *fontSampleMonospace;
IBOutlet NSTextField *fontSampleCursive;
NSArray *regionMappingTable; NSArray *regionMappingTable;
} }

Просмотреть файл

@ -13,10 +13,6 @@
#include "nsIPref.h" #include "nsIPref.h"
#include "nsIMemory.h" #include "nsIMemory.h"
// Use a category to put a changeFont message onto the tab view
@interface NSTabView (FontManagerDelegate)
- (void)changeFont:(id)sender;
@end
@interface OrgMozillaChimeraPreferenceAppearance(Private) @interface OrgMozillaChimeraPreferenceAppearance(Private)
@ -41,6 +37,7 @@
@end @end
@implementation OrgMozillaChimeraPreferenceAppearance @implementation OrgMozillaChimeraPreferenceAppearance
- (void) dealloc - (void) dealloc
@ -48,6 +45,12 @@
[regionMappingTable release]; [regionMappingTable release];
} }
- (id)initWithBundle:(NSBundle *)bundle
{
self = [super initWithBundle:bundle];
return self;
}
- (void) mainViewDidLoad - (void) mainViewDidLoad
{ {
BOOL gotPref; BOOL gotPref;
@ -65,7 +68,10 @@
[colorwellVisitedLinks setColor:[self getColorPref:"browser.visited_color" withSuccess:&gotPref]]; [colorwellVisitedLinks setColor:[self getColorPref:"browser.visited_color" withSuccess:&gotPref]];
[self setupFontRegionTable]; [self setupFontRegionTable];
[NSFontManager sharedFontManager];
// prep the font panel
NSFontPanel *fontPanel = [[NSFontManager sharedFontManager] fontPanel:YES];
//[fontPanel setBecomesKeyOnlyIfNeeded:NO];
} }
- (void)willUnselect - (void)willUnselect
@ -85,8 +91,12 @@
regionMappingTable = [[NSArray arrayWithContentsOfFile:resPath] retain]; regionMappingTable = [[NSArray arrayWithContentsOfFile:resPath] retain];
[self loadFontPrefs]; [self loadFontPrefs];
[tableViewFontRegion reloadData]; [tableViewFontRegion reloadData];
if ([tableViewFontRegion selectedRow] == 0)
[tableViewFontRegion selectRow:-1 byExtendingSelection:NO]; // make sure the next line triggers a change
[tableViewFontRegion selectRow:0 byExtendingSelection:NO]; // trigger initial setup [tableViewFontRegion selectRow:0 byExtendingSelection:NO]; // trigger initial setup
} }
@ -122,7 +132,9 @@
- (IBAction)fontChoiceButtonClicked:(id)sender - (IBAction)fontChoiceButtonClicked:(id)sender
{ {
[self syncFontPanel]; [self syncFontPanel];
[[NSFontManager sharedFontManager] orderFrontFontPanel:self];
NSFontPanel *fontPanel = [[NSFontManager sharedFontManager] fontPanel:YES];
[fontPanel makeKeyAndOrderFront:self];
} }
- (IBAction)fontRegionListClicked:(id)sender - (IBAction)fontRegionListClicked:(id)sender
@ -140,26 +152,33 @@
/* /*
For each region in the array, there is a dictionary of For each region in the array, there is a dictionary of
{ {
region =
code = code =
region = (from localized strings file)
to which we add here a sub-dictionary per font type, thus: to which we add here a sub-dictionary per font type, thus:
serif = { serif = {
fontname = fontfamily = Times-Regular
fontsize = fontsize = 16
} }
sans-serif = { sans-serif = {
fontname = fontfamily =
fontsize = fontsize =
missing = // set if a font is missing missing = // set if a font is missing
} }
monospace = { monospace = {
fontname = fontfamily =
fontsize =
}
cursive = {
fontfamily =
fontsize = fontsize =
} }
} }
*/ */
NSString *regionName = NSLocalizedStringFromTableInBundle(regionCode, @"RegionNames",
[NSBundle bundleForClass:[OrgMozillaChimeraPreferenceAppearance class]], @"");
[regionDict setObject:regionName forKey:@"region"];
NSMutableDictionary *serifDict = [self makeDictFromPrefsForFontType:@"serif" andRegion:regionCode]; NSMutableDictionary *serifDict = [self makeDictFromPrefsForFontType:@"serif" andRegion:regionCode];
[regionDict setObject:serifDict forKey:@"serif"]; [regionDict setObject:serifDict forKey:@"serif"];
@ -169,6 +188,9 @@
NSMutableDictionary *monoDict = [self makeDictFromPrefsForFontType:@"monospace" andRegion:regionCode]; NSMutableDictionary *monoDict = [self makeDictFromPrefsForFontType:@"monospace" andRegion:regionCode];
[regionDict setObject:monoDict forKey:@"monospace"]; [regionDict setObject:monoDict forKey:@"monospace"];
NSMutableDictionary *cursDict = [self makeDictFromPrefsForFontType:@"cursive" andRegion:regionCode];
[regionDict setObject:cursDict forKey:@"cursive"];
} }
} }
@ -185,6 +207,7 @@
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"serif"]; [self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"serif"];
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"sans-serif"]; [self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"sans-serif"];
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"monospace"]; [self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"monospace"];
[self saveToPrefsEntriesInDict:(NSDictionary*)regionDict forFontType:@"cursive"];
} }
} }
@ -206,7 +229,7 @@
if (gotPref && gotSize) if (gotPref && gotSize)
{ {
[fontDict setObject:fontName forKey:@"fontname"]; [fontDict setObject:fontName forKey:@"fontfamily"];
[fontDict setObject:[NSNumber numberWithInt:fontSize] forKey:@"fontsize"]; [fontDict setObject:[NSNumber numberWithInt:fontSize] forKey:@"fontsize"];
} }
@ -220,7 +243,7 @@
if (!fontTypeDict || !regionCode) return; if (!fontTypeDict || !regionCode) return;
NSString *fontName = [fontTypeDict objectForKey:@"fontname"]; NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue]; int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue];
NSString *fontPrefName = [NSString stringWithFormat:@"font.name.%@.%@", fontType, regionCode]; NSString *fontPrefName = [NSString stringWithFormat:@"font.name.%@.%@", fontType, regionCode];
@ -249,7 +272,7 @@
if (theFont) if (theFont)
{ {
[fontTypeDict setObject:[theFont familyName] forKey:@"fontname"]; [fontTypeDict setObject:[theFont familyName] forKey:@"fontfamily"];
[fontTypeDict setObject:[NSNumber numberWithInt:(int)[theFont pointSize]] forKey:@"fontsize"]; [fontTypeDict setObject:[NSNumber numberWithInt:(int)[theFont pointSize]] forKey:@"fontsize"];
} }
} }
@ -257,15 +280,20 @@
- (NSFont*)getFontOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict; - (NSFont*)getFontOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict;
{ {
NSDictionary *fontTypeDict = [regionDict objectForKey:fontType]; NSDictionary *fontTypeDict = [regionDict objectForKey:fontType];
NSString *fontName = [fontTypeDict objectForKey:@"fontname"]; NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue]; int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue];
NSFont *returnFont = nil; NSFont *returnFont = nil;
if (fontName && fontSize > 0) if (fontName && fontSize > 0)
returnFont = [NSFont fontWithName:fontName size:fontSize]; {
// we can't use [NSFont fontWithName] here, because we only store font
// family names in the prefs file. So use the font manager instead
// returnFont = [NSFont fontWithName:fontName size:fontSize];
returnFont = [[NSFontManager sharedFontManager] fontWithFamily:fontName traits:0 weight:5 size:fontSize];
}
else if (fontName) // no size else if (fontName) // no size
returnFont = [NSFont fontWithName:fontName size:16.0]; returnFont = [[NSFontManager sharedFontManager] fontWithFamily:fontName traits:0 weight:5 size:16.0];
/* /*
if (returnFont == nil) if (returnFont == nil)
@ -283,6 +311,7 @@
[self setupFontSampleOfType:@"serif" fromDict:regionDict]; [self setupFontSampleOfType:@"serif" fromDict:regionDict];
[self setupFontSampleOfType:@"sans-serif" fromDict:regionDict]; [self setupFontSampleOfType:@"sans-serif" fromDict:regionDict];
[self setupFontSampleOfType:@"monospace" fromDict:regionDict]; [self setupFontSampleOfType:@"monospace" fromDict:regionDict];
[self setupFontSampleOfType:@"cursive" fromDict:regionDict];
} }
- (void)setupFontSampleOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict; - (void)setupFontSampleOfType:(NSString*)fontType fromDict:(NSDictionary*)regionDict;
@ -297,14 +326,14 @@
// a string to display from the dict. // a string to display from the dict.
NSMutableDictionary *fontTypeDict = [regionDict objectForKey:fontType]; NSMutableDictionary *fontTypeDict = [regionDict objectForKey:fontType];
NSTextField *textField = [self getFontSampleForType:fontType]; NSTextField *sampleCell = [self getFontSampleForType:fontType];
NSString *displayString = nil; NSString *displayString = nil;
if (font == nil) if (font == nil)
{ {
if (regionDict) if (regionDict)
{ {
NSString *fontName = [fontTypeDict objectForKey:@"fontname"]; NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue]; int fontSize = [[fontTypeDict objectForKey:@"fontsize"] intValue];
// XXX localize // XXX localize
@ -338,8 +367,8 @@
[fontTypeDict removeObjectForKey:@"missing"]; [fontTypeDict removeObjectForKey:@"missing"];
} }
[textField setFont:font]; [sampleCell setFont:font];
[textField setStringValue:displayString]; [sampleCell setStringValue:displayString];
} }
- (void)updateFontSampleOfType:(NSString *)fontType - (void)updateFontSampleOfType:(NSString *)fontType
@ -350,8 +379,8 @@
NSMutableDictionary *regionDict = [regionMappingTable objectAtIndex:selectedRow]; NSMutableDictionary *regionDict = [regionMappingTable objectAtIndex:selectedRow];
NSTextField *textField = [self getFontSampleForType:fontType]; NSTextField *sampleCell = [self getFontSampleForType:fontType];
NSFont *sampleFont = [[NSFontManager sharedFontManager] convertFont:[textField font]]; NSFont *sampleFont = [[NSFontManager sharedFontManager] convertFont:[sampleCell font]];
[self setFontSampleOfType:fontType withFont:sampleFont andDict:regionDict]; [self setFontSampleOfType:fontType withFont:sampleFont andDict:regionDict];
} }
@ -367,6 +396,9 @@
if ([fontType isEqualToString:@"monospace"]) if ([fontType isEqualToString:@"monospace"])
return fontSampleMonospace; return fontSampleMonospace;
if ([fontType isEqualToString:@"cursive"])
return fontSampleCursive;
return nil; return nil;
} }
@ -389,6 +421,7 @@
[self saveFontsToDict:regionDict forFontType:@"serif"]; [self saveFontsToDict:regionDict forFontType:@"serif"];
[self saveFontsToDict:regionDict forFontType:@"sans-serif"]; [self saveFontsToDict:regionDict forFontType:@"sans-serif"];
[self saveFontsToDict:regionDict forFontType:@"monospace"]; [self saveFontsToDict:regionDict forFontType:@"monospace"];
[self saveFontsToDict:regionDict forFontType:@"cursive"];
} }
@end @end
@ -397,8 +430,6 @@
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{ {
NSLog(@"Table selection changed");
if ([aNotification object] != tableViewFontRegion) if ([aNotification object] != tableViewFontRegion)
return; return;
@ -459,21 +490,3 @@
} }
@end @end
// Use a category to put a changeFont message onto the tab view (since this
// is guaranteed to be in the repsonder chain. We've set the tab view's delegate
// to be the file's owner in IB, so we just forward the message.
@implementation NSTabView (FontManagerDelegate)
- (void)changeFont:(id)sender
{
[[self delegate] changeFont:sender];
}
- (BOOL)fontManager:(id)theFontManager willIncludeFont:(NSString *)fontName
{
NSLog(@"willIncludeFont called");
return YES;
}
@end

Просмотреть файл

@ -1,7 +1,13 @@
{ {
IBClasses = ( IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = FontChangeReceiver; LANGUAGE = ObjC; SUPERCLASS = NSView; }, {
ACTIONS = {};
CLASS = FontReceiverView;
LANGUAGE = ObjC;
OUTLETS = {delegate = id; };
SUPERCLASS = NSView;
},
{ {
CLASS = NSPreferencePane; CLASS = NSPreferencePane;
LANGUAGE = ObjC; LANGUAGE = ObjC;
@ -24,6 +30,7 @@
colorwellTextColor = NSColorWell; colorwellTextColor = NSColorWell;
colorwellUnvisitedLinks = NSColorWell; colorwellUnvisitedLinks = NSColorWell;
colorwellVisitedLinks = NSColorWell; colorwellVisitedLinks = NSColorWell;
fontSampleCursive = NSTextField;
fontSampleMonospace = NSTextField; fontSampleMonospace = NSTextField;
fontSampleSansSerif = NSTextField; fontSampleSansSerif = NSTextField;
fontSampleSerif = NSTextField; fontSampleSerif = NSTextField;

Двоичные данные
chimera/PreferencePanes/Appearance/Appearance.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -1,7 +1,13 @@
{ {
IBClasses = ( IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = FontChangeReceiver; LANGUAGE = ObjC; SUPERCLASS = NSView; }, {
ACTIONS = {};
CLASS = FontReceiverView;
LANGUAGE = ObjC;
OUTLETS = {delegate = id; };
SUPERCLASS = NSView;
},
{ {
CLASS = NSPreferencePane; CLASS = NSPreferencePane;
LANGUAGE = ObjC; LANGUAGE = ObjC;
@ -24,6 +30,7 @@
colorwellTextColor = NSColorWell; colorwellTextColor = NSColorWell;
colorwellUnvisitedLinks = NSColorWell; colorwellUnvisitedLinks = NSColorWell;
colorwellVisitedLinks = NSColorWell; colorwellVisitedLinks = NSColorWell;
fontSampleCursive = NSTextField;
fontSampleMonospace = NSTextField; fontSampleMonospace = NSTextField;
fontSampleSansSerif = NSTextField; fontSampleSansSerif = NSTextField;
fontSampleSerif = NSTextField; fontSampleSerif = NSTextField;

Двоичные данные
chimera/PreferencePanes/Appearance/English.lproj/Appearance.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

Просмотреть файл

@ -1,62 +0,0 @@
(
{
region = "Western";
code = "x-western";
},
{
region = "Central European";
code = "x-central-euro";
},
{
region = "Japanese";
code = "ja";
},
{
region = "Traditional Chinese";
code = "zh-TW";
},
{
region = "Simplified Chinese";
code = "zh-CN";
},
{
region = "Korean";
code = "ko";
},
{
region = "Cyrillic";
code = "x-cyrillic";
},
{
region = "Baltic";
code = "x-baltic";
},
{
region = "Greek";
code = "el";
},
{
region = "Turkish";
code = "tr";
},
{
region = "Unicode";
code = "x-unicode";
},
{
region = "User-Defined";
code = "x-user-def";
},
{
region = "Thai";
code = "th";
},
{
region = "Hebrew";
code = "he";
},
{
region = "Arabic";
code = "ar";
}
)