зеркало из https://github.com/mozilla/gecko-dev.git
Fix bug 173150: change the font panel to not show font face, and strip out font face info from the saved font.
Fix bug 188300: when the text samples have focus, return custom field editors so that we can get changeFont: notifications. Also fix a bug where if a font was missing, subsequent font selections would not stick (should help with bug 175651).
This commit is contained in:
Родитель
d2acc405fc
Коммит
509481de39
|
@ -75,6 +75,9 @@
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
|
// We use instances of this class as the field editor, to allow us to catch
|
||||||
|
// |changeFont:| messages.
|
||||||
|
|
||||||
@interface SampleTextView : NSTextView
|
@interface SampleTextView : NSTextView
|
||||||
{
|
{
|
||||||
id mPrefPane;
|
id mPrefPane;
|
||||||
|
@ -83,7 +86,6 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// try making these a real text view, then override changeFont:
|
|
||||||
@implementation SampleTextView
|
@implementation SampleTextView
|
||||||
|
|
||||||
- (void)setPrefPane:(id)inPrefPane
|
- (void)setPrefPane:(id)inPrefPane
|
||||||
|
@ -96,6 +98,16 @@
|
||||||
[mPrefPane changeFont:sender];
|
[mPrefPane changeFont:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)fontManager:(id)theFontManager willIncludeFont:(NSString *)fontName
|
||||||
|
{
|
||||||
|
return [mPrefPane fontManager:theFontManager willIncludeFont:fontName];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (unsigned int)validModesForFontPanel:(NSFontPanel *)fontPanel
|
||||||
|
{
|
||||||
|
return [mPrefPane validModesForFontPanel:fontPanel];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
@ -432,10 +444,11 @@
|
||||||
NSMutableDictionary *fontTypeDict = [regionDict objectForKey:fontType];
|
NSMutableDictionary *fontTypeDict = [regionDict objectForKey:fontType];
|
||||||
NSMutableDictionary *fontSizeDict = [regionDict objectForKey:@"fontsize"];
|
NSMutableDictionary *fontSizeDict = [regionDict objectForKey:@"fontsize"];
|
||||||
|
|
||||||
if ([[fontTypeDict objectForKey:@"missing"] boolValue]) // will be false if no object
|
if (font)
|
||||||
return;
|
{
|
||||||
|
// clear any missing flag
|
||||||
if (font) {
|
[fontTypeDict removeObjectForKey:@"missing"];
|
||||||
|
|
||||||
[fontTypeDict setObject:[font familyName] forKey:@"fontfamily"];
|
[fontTypeDict setObject:[font familyName] forKey:@"fontfamily"];
|
||||||
[fontSizeDict setObject:[NSNumber numberWithInt:(int)[font pointSize]] forKey:[self getFontSizeType:fontType]];
|
[fontSizeDict setObject:[NSNumber numberWithInt:(int)[font pointSize]] forKey:[self getFontSizeType:fontType]];
|
||||||
}
|
}
|
||||||
|
@ -495,8 +508,10 @@
|
||||||
NSTextField *sampleCell = [self getFontSampleForType:fontType];
|
NSTextField *sampleCell = [self getFontSampleForType:fontType];
|
||||||
NSString *displayString = nil;
|
NSString *displayString = nil;
|
||||||
|
|
||||||
if (font == nil) {
|
if (font == nil)
|
||||||
if (regionDict) {
|
{
|
||||||
|
if (regionDict)
|
||||||
|
{
|
||||||
NSDictionary *fontSizeDict = [regionDict objectForKey:@"fontsize"];
|
NSDictionary *fontSizeDict = [regionDict objectForKey:@"fontsize"];
|
||||||
NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
|
NSString *fontName = [fontTypeDict objectForKey:@"fontfamily"];
|
||||||
int fontSize = [[fontSizeDict objectForKey:[self getFontSizeType:fontType]] intValue];
|
int fontSize = [[fontSizeDict objectForKey:[self getFontSizeType:fontType]] intValue];
|
||||||
|
@ -505,27 +520,29 @@
|
||||||
font = [NSFont userFontOfSize:14.0];
|
font = [NSFont userFontOfSize:14.0];
|
||||||
|
|
||||||
// set the missing flag in the dict
|
// set the missing flag in the dict
|
||||||
if (![fontTypeDict objectForKey:@"missing"] || ![[fontTypeDict objectForKey:@"missing"] boolValue]) {
|
if (![fontTypeDict objectForKey:@"missing"] || ![[fontTypeDict objectForKey:@"missing"] boolValue])
|
||||||
[fontTypeDict setObject:[NSNumber numberWithBool:YES] forKey:@"missing"];
|
[fontTypeDict setObject:[NSNumber numberWithBool:YES] forKey:@"missing"];
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
// should never happen
|
// should never happen
|
||||||
// XXX localize
|
// XXX localize
|
||||||
displayString = @"Font missing";
|
displayString = @"Font missing";
|
||||||
font = [NSFont userFontOfSize:16.0];
|
font = [NSFont userFontOfSize:16.0];
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
NS_DURING
|
else
|
||||||
displayString = [NSString stringWithFormat:@"%@, %dpt", [font displayName], (int)[font pointSize]];
|
{
|
||||||
NS_HANDLER
|
displayString = [NSString stringWithFormat:@"%@, %dpt", [font familyName], (int)[font pointSize]];
|
||||||
displayString = [NSString stringWithFormat:@"%@, %dpt", [font familyName], (int)[font pointSize]];
|
|
||||||
NS_ENDHANDLER
|
|
||||||
|
|
||||||
// make sure we don't have a missing entry
|
// make sure we don't have a missing entry
|
||||||
[fontTypeDict removeObjectForKey:@"missing"];
|
[fontTypeDict removeObjectForKey:@"missing"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[sampleCell setFont:font];
|
// Set the font of the sample to a font that is not bold, italic etc.
|
||||||
|
NSFont* baseFont = [[NSFontManager sharedFontManager] fontWithFamily:[font familyName] traits:0 weight:5 /* normal weight */ size:[font pointSize]];
|
||||||
|
|
||||||
|
[sampleCell setFont:baseFont];
|
||||||
[sampleCell setStringValue:displayString];
|
[sampleCell setStringValue:displayString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,7 +864,6 @@ const int kMissingFontPopupItemTag = 9999;
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)changeFont:(id)sender
|
- (void)changeFont:(id)sender
|
||||||
{
|
{
|
||||||
if (mFontButtonForEditor) {
|
if (mFontButtonForEditor) {
|
||||||
|
@ -859,7 +875,27 @@ const int kMissingFontPopupItemTag = 9999;
|
||||||
- (BOOL)fontManager:(id)theFontManager willIncludeFont:(NSString *)fontName
|
- (BOOL)fontManager:(id)theFontManager willIncludeFont:(NSString *)fontName
|
||||||
{
|
{
|
||||||
// filter out fonts for the selected language
|
// filter out fonts for the selected language
|
||||||
|
//NSLog(@"willIncludeFont:%@", fontName);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NSFontPanelFaceModeMask = 1 << 0,
|
||||||
|
NSFontPanelSizeModeMask = 1 << 1,
|
||||||
|
NSFontPanelCollectionModeMask = 1 << 2,
|
||||||
|
NSFontPanelStandardModesMask = 0xFFFF,
|
||||||
|
NSFontPanelAllModesMask = 0xFFFFFFFF
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// this allows us to hide the font face panel
|
||||||
|
- (unsigned int)validModesForFontPanel:(NSFontPanel *)fontPanel
|
||||||
|
{
|
||||||
|
// hide the face panel
|
||||||
|
return (NSFontPanelStandardModesMask & ~NSFontPanelFaceModeMask);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче