Add fallback for missing standard fonts.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25555 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-11-05 12:02:05 +00:00
parent 8f2ef7b3db
commit 440d7532e2
2 changed files with 372 additions and 340 deletions

View file

@ -1,3 +1,8 @@
2007-11-05 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSFont.m (-initWithName:matrix:fix:screenFont:role:): Add
fallback for missing standard fonts.
2007-11-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSControl.m,

View file

@ -801,9 +801,38 @@ static void setNSFont(NSString *key, NSFont *font)
fontInfo = RETAIN([GSFontInfo fontInfoForFontName: fontName
matrix: fontMatrix
screenFont: screen]);
cachedFlippedFont = placeHolder;
if (!screenFont)
cachedScreenFont = placeHolder;
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"])
{
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"])
{
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]);
}
}
if (fontInfo == nil)
{
DESTROY(fontName);
@ -842,9 +871,7 @@ static void setNSFont(NSString *key, NSFont *font)
RELEASE(fontName);
}
TEST_RELEASE(fontInfo);
if (cachedFlippedFont != placeHolder)
DESTROY(cachedFlippedFont);
if (cachedScreenFont != placeHolder)
DESTROY(cachedScreenFont);
[super dealloc];
}
@ -900,7 +927,7 @@ static void setNSFont(NSString *key, NSFont *font)
- (NSFont *)_flippedViewFont
{
if (cachedFlippedFont == placeHolder)
if (cachedFlippedFont == nil)
{
float fontMatrix[6];
memcpy(fontMatrix, matrix, sizeof(matrix));
@ -1040,7 +1067,7 @@ static BOOL flip_hack;
Note that if the font has no corresponding screen font, cachedScreenFont
will be set to nil.
*/
if (cachedScreenFont == placeHolder)
if (cachedScreenFont == nil)
cachedScreenFont = [placeHolder initWithName: fontName
matrix: matrix
fix: matrixExplicitlySet