mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r25663) -Fix [FS#4857]: [OSX] Monospace font detection.
This commit is contained in:
parent
4ab4e5a9e4
commit
3cd7eeb160
@ -496,6 +496,8 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
||||
if ((symbolic_traits & kCTFontClassMaskTrait) == (CTFontStylisticClass)kCTFontSymbolicClass || (symbolic_traits & kCTFontVerticalTrait)) continue;
|
||||
/* Skip bold fonts (especially Arial Bold, which looks worse than regular Arial). */
|
||||
if (symbolic_traits & kCTFontBoldTrait) continue;
|
||||
/* Select monospaced fonts if asked for. */
|
||||
if (((symbolic_traits & kCTFontMonoSpaceTrait) == kCTFontMonoSpaceTrait) != callback->Monospace()) continue;
|
||||
|
||||
/* Get font name. */
|
||||
char name[128];
|
||||
@ -530,8 +532,13 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
||||
CFStringRef font_name;
|
||||
ATSFontGetName(font, kATSOptionFlagsDefault, &font_name);
|
||||
CFStringGetCString(font_name, name, lengthof(name), kCFStringEncodingUTF8);
|
||||
|
||||
bool monospace = IsMonospaceFont(font_name);
|
||||
CFRelease(font_name);
|
||||
|
||||
/* Select monospaced fonts if asked for. */
|
||||
if (monospace != callback->Monospace()) continue;
|
||||
|
||||
/* We only want the base font and not bold or italic variants. */
|
||||
if (strstr(name, "Italic") != NULL || strstr(name, "Bold")) continue;
|
||||
|
||||
|
@ -36,4 +36,6 @@ static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsMonospaceFont(CFStringRef name);
|
||||
|
||||
#endif /* MACOS_H */
|
||||
|
@ -193,3 +193,15 @@ uint GetCPUCoreCount()
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a font is a monospace font.
|
||||
* @param name Name of the font.
|
||||
* @return True if the font is a monospace font.
|
||||
*/
|
||||
bool IsMonospaceFont(CFStringRef name)
|
||||
{
|
||||
NSFont *font = [ NSFont fontWithName:(NSString *)name size:0.0f ];
|
||||
|
||||
return font != NULL ? [ font isFixedPitch ] : false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user