mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 18:40:38 +00:00
* Source/NSFont.m (-initWithName:...): Move replacement name into
separate method -_replacementFontName and add replacement for "Helvetica-" prefix. * Header/AppKit/NSLayoutManager.h: Add some 10.5 methods. * Source/NSLayoutManager.m: Simple implementations for these new methods. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35922 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0f3af93a92
commit
e93fd24f0d
4 changed files with 148 additions and 29 deletions
|
@ -784,6 +784,40 @@ static void setNSFont(NSString *key, NSFont *font)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
Last fallback: If a system font was explicitly requested
|
||||
and this font does not exist, try to replace it with the
|
||||
corresponding font in the current setup.
|
||||
*/
|
||||
- (NSString*) _replacementFontName
|
||||
{
|
||||
if (([fontName isEqualToString: @"Helvetica"] &&
|
||||
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande"]))
|
||||
{
|
||||
return font_roles[RoleSystemFont].defaultFont;
|
||||
}
|
||||
else if (([fontName isEqualToString: @"Helvetica-Bold"] &&
|
||||
![font_roles[RoleBoldSystemFont].defaultFont isEqualToString: @"Helvetica-Bold"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande-Bold"]))
|
||||
{
|
||||
return font_roles[RoleBoldSystemFont].defaultFont;
|
||||
}
|
||||
else if ([fontName isEqualToString: @"Courier"] &&
|
||||
![font_roles[RoleUserFixedPitchFont].defaultFont isEqualToString: @"Courier"])
|
||||
{
|
||||
return font_roles[RoleUserFixedPitchFont].defaultFont;
|
||||
}
|
||||
else if ([fontName hasPrefix: @"Helvetica-"] &&
|
||||
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@-%@",
|
||||
font_roles[RoleSystemFont].defaultFont,
|
||||
[fontName substringFromIndex: 10]];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/** <init />
|
||||
* Initializes a newly created font instance from the name and
|
||||
* information given in the fontMatrix. The fontMatrix is a standard
|
||||
|
@ -829,36 +863,13 @@ static void setNSFont(NSString *key, NSFont *font)
|
|||
screenFont: screen]);
|
||||
if ((fontInfo == nil) && (aRole == RoleExplicit))
|
||||
{
|
||||
/*
|
||||
Last fallback: If a system font was explicitly requested
|
||||
and this font does not exist, try to replace it with the
|
||||
corresponding font in the current setup.
|
||||
*/
|
||||
if (([fontName isEqualToString: @"Helvetica"] &&
|
||||
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande"]))
|
||||
NSString *replacementFontName = [self _replacementFontName];
|
||||
|
||||
if (replacementFontName != nil)
|
||||
{
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
|
||||
font_roles[RoleSystemFont].defaultFont
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
}
|
||||
else if (([fontName isEqualToString: @"Helvetica-Bold"] &&
|
||||
![font_roles[RoleBoldSystemFont].defaultFont isEqualToString: @"Helvetica-Bold"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande-Bold"]))
|
||||
{
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
|
||||
font_roles[RoleBoldSystemFont].defaultFont
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
}
|
||||
else if ([fontName isEqualToString: @"Courier"] &&
|
||||
![font_roles[RoleUserFixedPitchFont].defaultFont isEqualToString: @"Courier"])
|
||||
{
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
|
||||
font_roles[RoleUserFixedPitchFont].defaultFont
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName: replacementFontName
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
}
|
||||
}
|
||||
if (fontInfo == nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue