mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 03:40:47 +00:00
Be more tolerant with traits set wrongly by backends.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25463 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
94ad6e600e
commit
44c2fc3f42
2 changed files with 58 additions and 18 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2007-09-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSFontManager.m (-convertFont:toHaveTrait:,
|
||||||
|
-convertFont:toNotHaveTrait:): Handle NSUnboldFontMask and
|
||||||
|
NSUnitalicFontMask correctly.
|
||||||
|
* Source/NSFontManager.m (-fontWithFamily:traits:weight:size:) Be
|
||||||
|
more tolerant with traits set wrongly by backends.
|
||||||
|
|
||||||
2007-09-06 Fred Kiefer <FredKiefer@gmx.de>
|
2007-09-06 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/AppKit/NSCell.h: Add ivar in_editing, which gets set,
|
* Headers/AppKit/NSCell.h: Add ivar in_editing, which gets set,
|
||||||
|
|
|
@ -494,11 +494,19 @@ static Class fontPanelClass = Nil;
|
||||||
float size = [fontObject pointSize];
|
float size = [fontObject pointSize];
|
||||||
NSString *family = [fontObject familyName];
|
NSString *family = [fontObject familyName];
|
||||||
|
|
||||||
// We cannot reuse the weight in a bold
|
if (trait & NSBoldFontMask)
|
||||||
if (trait == NSBoldFontMask)
|
{
|
||||||
weight = 9;
|
// We cannot reuse the weight in a bold
|
||||||
|
weight = 9;
|
||||||
|
t = t & ~NSUnboldFontMask;
|
||||||
|
}
|
||||||
|
if (trait == NSItalicFontMask)
|
||||||
|
{
|
||||||
|
t = t & ~NSUnitalicFontMask;
|
||||||
|
}
|
||||||
|
|
||||||
t = t | trait;
|
t = t | trait;
|
||||||
|
|
||||||
newFont = [self fontWithFamily: family
|
newFont = [self fontWithFamily: family
|
||||||
traits: t
|
traits: t
|
||||||
weight: weight
|
weight: weight
|
||||||
|
@ -516,15 +524,6 @@ static Class fontPanelClass = Nil;
|
||||||
{
|
{
|
||||||
NSFontTraitMask t = [self traitsOfFont: fontObject];
|
NSFontTraitMask t = [self traitsOfFont: fontObject];
|
||||||
|
|
||||||
// This is a bit strange but is stated in the specification
|
|
||||||
if (trait & NSUnboldFontMask)
|
|
||||||
{
|
|
||||||
trait = (trait | NSBoldFontMask) & ~NSUnboldFontMask;
|
|
||||||
}
|
|
||||||
if (trait & NSUnitalicFontMask)
|
|
||||||
{
|
|
||||||
trait = (trait | NSItalicFontMask) & ~NSUnitalicFontMask;
|
|
||||||
}
|
|
||||||
if (!(t & trait))
|
if (!(t & trait))
|
||||||
{
|
{
|
||||||
// If already do not have that trait then just return it
|
// If already do not have that trait then just return it
|
||||||
|
@ -539,11 +538,27 @@ static Class fontPanelClass = Nil;
|
||||||
float size = [fontObject pointSize];
|
float size = [fontObject pointSize];
|
||||||
NSString *family = [fontObject familyName];
|
NSString *family = [fontObject familyName];
|
||||||
|
|
||||||
// We cannot reuse the weight in an unbold
|
|
||||||
if (trait & NSBoldFontMask)
|
if (trait & NSBoldFontMask)
|
||||||
{
|
{
|
||||||
|
// We cannot reuse the weight in an unbold
|
||||||
weight = 5;
|
weight = 5;
|
||||||
|
t = (t | NSUnboldFontMask);
|
||||||
}
|
}
|
||||||
|
else if (trait & NSUnboldFontMask)
|
||||||
|
{
|
||||||
|
// We cannot reuse the weight in a bold
|
||||||
|
weight = 9;
|
||||||
|
t = (t | NSBoldFontMask);
|
||||||
|
}
|
||||||
|
if (trait & NSItalicFontMask)
|
||||||
|
{
|
||||||
|
t = (t | NSUnitalicFontMask);
|
||||||
|
}
|
||||||
|
else if (trait & NSUnitalicFontMask)
|
||||||
|
{
|
||||||
|
t = (t | NSItalicFontMask);
|
||||||
|
}
|
||||||
|
|
||||||
t &= ~trait;
|
t &= ~trait;
|
||||||
newFont = [self fontWithFamily: family
|
newFont = [self fontWithFamily: family
|
||||||
traits: t
|
traits: t
|
||||||
|
@ -703,15 +718,30 @@ static Class fontPanelClass = Nil;
|
||||||
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
||||||
([[fontDef objectAtIndex: 3] unsignedIntValue] == traits))
|
([[fontDef objectAtIndex: 3] unsignedIntValue] == traits))
|
||||||
{
|
{
|
||||||
//NSLog(@"Found font");
|
//NSLog(@"Found font");
|
||||||
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
||||||
size: size];
|
size: size];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find something close
|
// Try to find something close by ignoring some trait flags
|
||||||
|
traits &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask
|
||||||
|
| NSUnitalicFontMask | NSUnboldFontMask);
|
||||||
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
|
{
|
||||||
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
|
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||||
|
|
||||||
traits &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask
|
||||||
|
| NSUnitalicFontMask | NSUnboldFontMask);
|
||||||
|
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
||||||
|
(t == traits))
|
||||||
|
{
|
||||||
|
//NSLog(@"Found font");
|
||||||
|
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
||||||
|
size: size];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (traits & NSBoldFontMask)
|
if (traits & NSBoldFontMask)
|
||||||
{
|
{
|
||||||
|
@ -721,7 +751,8 @@ static Class fontPanelClass = Nil;
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||||
|
|
||||||
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask
|
||||||
|
| NSUnitalicFontMask | NSUnboldFontMask);
|
||||||
if (t == traits)
|
if (t == traits)
|
||||||
{
|
{
|
||||||
//NSLog(@"Found font");
|
//NSLog(@"Found font");
|
||||||
|
@ -739,7 +770,8 @@ static Class fontPanelClass = Nil;
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||||
|
|
||||||
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask
|
||||||
|
| NSUnitalicFontMask | NSUnboldFontMask);
|
||||||
if ((([[fontDef objectAtIndex: 2] intValue] == 5) ||
|
if ((([[fontDef objectAtIndex: 2] intValue] == 5) ||
|
||||||
([[fontDef objectAtIndex: 2] intValue] == 6)) &&
|
([[fontDef objectAtIndex: 2] intValue] == 6)) &&
|
||||||
(t == traits))
|
(t == traits))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue