mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
fixed search logic in [NSFontManager -fontWithFamily:traits:weight:size]
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20596 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ad2419e484
commit
02a7f545d7
2 changed files with 15 additions and 26 deletions
|
@ -1,3 +1,9 @@
|
|||
2005-01-22 Adrian Robert <arobert@cogsci.ucsd.edu>
|
||||
* Source/NSFontManager.m (-fontWithFamily:traits:weight:size:)
|
||||
Corrected logic in fallback approximate trait search for weight 5 or 6
|
||||
(regular) fonts. Font w/approximate traits but originally-requested
|
||||
weight will now be found.
|
||||
|
||||
2005-01-21 21:43 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
Various whitespace cleanups, comment type fixes, and changes
|
||||
|
|
|
@ -673,7 +673,7 @@ static Class fontPanelClass = Nil;
|
|||
NSArray *fontDefs = [self availableMembersOfFontFamily: family];
|
||||
unsigned int i;
|
||||
|
||||
//NSLog(@"Searching font %@: %i: %i", family, weight, traits);
|
||||
//NSLog(@"Searching font %@: %i: %i size %.0f", family, weight, traits, size);
|
||||
|
||||
// First do an exact match search
|
||||
for (i = 0; i < [fontDefs count]; i++)
|
||||
|
@ -681,12 +681,12 @@ static Class fontPanelClass = Nil;
|
|||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||
|
||||
//NSLog(@"Testing font %@: %i: %i", [fontDef objectAtIndex: 0],
|
||||
// [[fontDef objectAtIndex: 2] intValue],
|
||||
// [[fontDef objectAtIndex: 3] unsignedIntValue]);
|
||||
// [[fontDef objectAtIndex: 2] intValue],
|
||||
// [[fontDef objectAtIndex: 3] unsignedIntValue]);
|
||||
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
||||
([[fontDef objectAtIndex: 3] unsignedIntValue] == traits))
|
||||
{
|
||||
//NSLog(@"Found font");
|
||||
//NSLog(@"Found font");
|
||||
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
||||
size: size];
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ static Class fontPanelClass = Nil;
|
|||
|
||||
if (traits & NSBoldFontMask)
|
||||
{
|
||||
// For bold ignore weigth
|
||||
//NSLog(@"Trying ignore weights for bold font");
|
||||
for (i = 0; i < [fontDefs count]; i++)
|
||||
{
|
||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||
|
@ -714,34 +714,17 @@ static Class fontPanelClass = Nil;
|
|||
}
|
||||
}
|
||||
|
||||
if (weight == 5)
|
||||
if (weight == 5 || weight == 6)
|
||||
{
|
||||
weight = 6;
|
||||
//NSLog(@"Trying alternate non-bold weights for non-bold font");
|
||||
for (i = 0; i < [fontDefs count]; i++)
|
||||
{
|
||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||
|
||||
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
||||
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
||||
(t == traits))
|
||||
{
|
||||
//NSLog(@"Found font");
|
||||
return [NSFont fontWithName: [fontDef objectAtIndex: 0]
|
||||
size: size];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (weight == 6)
|
||||
{
|
||||
weight = 5;
|
||||
for (i = 0; i < [fontDefs count]; i++)
|
||||
{
|
||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||
NSFontTraitMask t = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||
|
||||
t &= ~(NSNonStandardCharacterSetFontMask | NSFixedPitchFontMask);
|
||||
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
||||
if ((([[fontDef objectAtIndex: 2] intValue] == 5) ||
|
||||
([[fontDef objectAtIndex: 2] intValue] == 6)) &&
|
||||
(t == traits))
|
||||
{
|
||||
//NSLog(@"Found font");
|
||||
|
|
Loading…
Reference in a new issue