mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
fontconfig: use fullname for displayName (most of the time)
Can't use fullname ALL the time, because some (mostly Adobe) fonts store a duplicate of their PostScript name in the fullname field (and for that case, we can just do what we already did), but it works well for just about everything else.
This commit is contained in:
parent
ecba94053d
commit
325c927814
1 changed files with 28 additions and 6 deletions
|
@ -69,13 +69,35 @@
|
|||
|
||||
- (NSString *) displayName
|
||||
{
|
||||
char *fcstyle;
|
||||
char *fcname;
|
||||
|
||||
if (FcPatternGetString(_pattern, FC_STYLE, 0, (FcChar8 **)&fcstyle) == FcResultMatch) {
|
||||
return [NSString stringWithFormat: @"%@ %@", _familyName,
|
||||
[NSString stringWithUTF8String: fcstyle]];
|
||||
}
|
||||
return _familyName;
|
||||
#ifdef FC_POSTSCRIPT_NAME
|
||||
char *fcpsname;
|
||||
#endif
|
||||
|
||||
/*
|
||||
If fullname && fullname != psname, use fullname as displayname.
|
||||
This works around some weird Adobe OpenType fonts which contain their
|
||||
PostScript name in their "human-readable name" field.
|
||||
|
||||
So, set the fullname as displayName (now AKA VisibleName) only
|
||||
if it's not the same as whatever the postscript name is.
|
||||
*/
|
||||
if (FcPatternGetString(_pattern, FC_FULLNAME, 0, (FcChar8 **)&fcname) == FcResultMatch
|
||||
#ifdef FC_POSTSCRIPT_NAME
|
||||
&& FcPatternGetString(_pattern, FC_POSTSCRIPT_NAME, 0, (FcChar8 **)&fcpsname) == FcResultMatch
|
||||
&& strcmp (fcpsname, fcname)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return [NSString stringWithUTF8String: fcname];
|
||||
}
|
||||
else if (FcPatternGetString(_pattern, FC_STYLE, 0, (FcChar8 **)&fcname) == FcResultMatch)
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@ %@", _familyName,
|
||||
[NSString stringWithUTF8String: fcname]];
|
||||
}
|
||||
return _familyName;
|
||||
}
|
||||
|
||||
- (int) weight
|
||||
|
|
Loading…
Reference in a new issue