mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 09:31:19 +00:00
If a font can't be found in the usual ways, try as a composite name font
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14712 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e0159ddd70
commit
5002c33cb1
1 changed files with 26 additions and 4 deletions
|
@ -140,13 +140,35 @@ readNSString (StringContext *ctxt)
|
||||||
traits: traits
|
traits: traits
|
||||||
weight: weight
|
weight: weight
|
||||||
size: fontSize];
|
size: fontSize];
|
||||||
|
if (font == nil)
|
||||||
|
{
|
||||||
|
/* Before giving up and using a default font, we try if this is
|
||||||
|
* not the case of a font with a composite name, such as
|
||||||
|
* 'Helvetica-Light'. In that case, even if we don't have
|
||||||
|
* exactly an 'Helvetica-Light' font family, we might have an
|
||||||
|
* 'Helvetica' one. */
|
||||||
|
NSRange range = [fontName rangeOfString:@"-"];
|
||||||
|
|
||||||
|
if (range.location != NSNotFound)
|
||||||
|
{
|
||||||
|
NSString *fontFamily = [fontName substringToIndex: range.location];
|
||||||
|
|
||||||
|
font = [[NSFontManager sharedFontManager] fontWithFamily: fontFamily
|
||||||
|
traits: traits
|
||||||
|
weight: weight
|
||||||
|
size: fontSize];
|
||||||
|
}
|
||||||
|
|
||||||
if (font == nil)
|
if (font == nil)
|
||||||
{
|
{
|
||||||
NSDebugMLLog(@"RTFParser",
|
NSDebugMLLog(@"RTFParser",
|
||||||
@"Could not find font %@ size %f traits %d weight %d",
|
@"Could not find font %@ size %f traits %d weight %d",
|
||||||
fontName, fontSize, traits, weight);
|
fontName, fontSize, traits, weight);
|
||||||
|
|
||||||
|
/* Last resort, default font. :-( */
|
||||||
font = [NSFont userFontOfSize: fontSize];
|
font = [NSFont userFontOfSize: fontSize];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue