mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 23:30:48 +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
8b0730a303
commit
f6b72a468b
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>
|
2005-01-21 21:43 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
Various whitespace cleanups, comment type fixes, and changes
|
Various whitespace cleanups, comment type fixes, and changes
|
||||||
|
|
|
@ -673,7 +673,7 @@ static Class fontPanelClass = Nil;
|
||||||
NSArray *fontDefs = [self availableMembersOfFontFamily: family];
|
NSArray *fontDefs = [self availableMembersOfFontFamily: family];
|
||||||
unsigned int i;
|
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
|
// First do an exact match search
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
|
@ -681,12 +681,12 @@ static Class fontPanelClass = Nil;
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
|
|
||||||
//NSLog(@"Testing font %@: %i: %i", [fontDef objectAtIndex: 0],
|
//NSLog(@"Testing font %@: %i: %i", [fontDef objectAtIndex: 0],
|
||||||
// [[fontDef objectAtIndex: 2] intValue],
|
// [[fontDef objectAtIndex: 2] intValue],
|
||||||
// [[fontDef objectAtIndex: 3] unsignedIntValue]);
|
// [[fontDef objectAtIndex: 3] unsignedIntValue]);
|
||||||
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];
|
||||||
}
|
}
|
||||||
|
@ -698,7 +698,7 @@ static Class fontPanelClass = Nil;
|
||||||
|
|
||||||
if (traits & NSBoldFontMask)
|
if (traits & NSBoldFontMask)
|
||||||
{
|
{
|
||||||
// For bold ignore weigth
|
//NSLog(@"Trying ignore weights for bold font");
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: 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++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
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);
|
||||||
if (([[fontDef objectAtIndex: 2] intValue] == weight) &&
|
if ((([[fontDef objectAtIndex: 2] intValue] == 5) ||
|
||||||
(t == traits))
|
([[fontDef objectAtIndex: 2] intValue] == 6)) &&
|
||||||
{
|
|
||||||
//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) &&
|
|
||||||
(t == traits))
|
(t == traits))
|
||||||
{
|
{
|
||||||
//NSLog(@"Found font");
|
//NSLog(@"Found font");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue