mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:41:55 +00:00
[convertWeight:ofFont:] better conversion.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7270 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dbd418e69e
commit
1793afe2fd
1 changed files with 42 additions and 17 deletions
|
@ -53,6 +53,10 @@ static Class fontPanelClass = Nil;
|
||||||
- (GSFontInfo *) fontInfo;
|
- (GSFontInfo *) fontInfo;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSFontManager (GNUstepBackend)
|
||||||
|
- (BOOL) _includeFont: (NSString*)fontName;
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSFontManager
|
@implementation NSFontManager
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -572,7 +576,7 @@ static Class fontPanelClass = Nil;
|
||||||
- (NSFont*) convertWeight: (BOOL)upFlag
|
- (NSFont*) convertWeight: (BOOL)upFlag
|
||||||
ofFont: (NSFont*)fontObject
|
ofFont: (NSFont*)fontObject
|
||||||
{
|
{
|
||||||
NSFont *newFont;
|
NSFont *newFont = nil;
|
||||||
NSString *fontName = nil;
|
NSString *fontName = nil;
|
||||||
NSFontTraitMask trait = [self traitsOfFont: fontObject];
|
NSFontTraitMask trait = [self traitsOfFont: fontObject];
|
||||||
float size = [fontObject pointSize];
|
float size = [fontObject pointSize];
|
||||||
|
@ -589,10 +593,6 @@ static Class fontPanelClass = Nil;
|
||||||
// sometimes it says 0 to 9 and sometimes 0 to 15
|
// sometimes it says 0 to 9 and sometimes 0 to 15
|
||||||
int next_w = 15;
|
int next_w = 15;
|
||||||
|
|
||||||
// Correct the trait
|
|
||||||
if (w == 8)
|
|
||||||
trait |= NSBoldFontMask;
|
|
||||||
|
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
|
@ -606,17 +606,30 @@ static Class fontPanelClass = Nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w = next_w;
|
if (fontName == nil)
|
||||||
|
{
|
||||||
|
// Not found, try again with changed trait
|
||||||
|
trait |= NSBoldFontMask;
|
||||||
|
|
||||||
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
|
{
|
||||||
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
|
int w1 = [[fontDef objectAtIndex: 2] intValue];
|
||||||
|
|
||||||
|
if (w1 > w && w1 < next_w &&
|
||||||
|
[[fontDef objectAtIndex: 3] unsignedIntValue] == trait)
|
||||||
|
{
|
||||||
|
next_w = w1;
|
||||||
|
fontName = [fontDef objectAtIndex: 0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int next_w = 0;
|
int next_w = 0;
|
||||||
|
|
||||||
// Correct the trait
|
|
||||||
if (w == 9)
|
|
||||||
trait &= ~NSBoldFontMask;
|
|
||||||
|
|
||||||
for (i = 0; i < [fontDefs count]; i++)
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
{
|
{
|
||||||
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
|
@ -630,18 +643,30 @@ static Class fontPanelClass = Nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w = next_w;
|
if (fontName == nil)
|
||||||
|
{
|
||||||
|
// Not found, try again with changed trait
|
||||||
|
trait &= ~NSBoldFontMask;
|
||||||
|
|
||||||
|
for (i = 0; i < [fontDefs count]; i++)
|
||||||
|
{
|
||||||
|
NSArray *fontDef = [fontDefs objectAtIndex: i];
|
||||||
|
int w1 = [[fontDef objectAtIndex: 2] intValue];
|
||||||
|
|
||||||
|
if (w1 < w && w1 > next_w &&
|
||||||
|
[[fontDef objectAtIndex: 3] unsignedIntValue] == trait)
|
||||||
|
{
|
||||||
|
next_w = w1;
|
||||||
|
fontName = [fontDef objectAtIndex: 0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontName != nil)
|
if (fontName != nil)
|
||||||
newFont = [NSFont fontWithName: fontName
|
newFont = [NSFont fontWithName: fontName
|
||||||
size: size];
|
size: size];
|
||||||
else
|
|
||||||
newFont = [self fontWithFamily: family
|
|
||||||
traits: trait
|
|
||||||
weight: w
|
|
||||||
size: size];
|
|
||||||
|
|
||||||
if (newFont == nil)
|
if (newFont == nil)
|
||||||
return fontObject;
|
return fontObject;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue