mirror of https://github.com/OpenTTD/OpenTTD
Remove: [OSX] Support for the pre 10.6 ATS font selection.
parent
b17ea3de36
commit
c21a298a8a
|
@ -394,8 +394,6 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
OSStatus os_err = -1;
|
||||
CFAutoRelease<CFStringRef> name(CFStringCreateWithCString(kCFAllocatorDefault, font_name, kCFStringEncodingUTF8));
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
|
||||
if (MacOSVersionIsAtLeast(10, 6, 0)) {
|
||||
/* Simply creating the font using CTFontCreateWithNameAndSize will *always* return
|
||||
* something, no matter the name. As such, we can't use it to check for existence.
|
||||
* We instead query the list of all font descriptors that match the given name which
|
||||
|
@ -410,36 +408,6 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
CFAutoRelease<CFURLRef> fontURL((CFURLRef)CTFontCopyAttribute(font.get(), kCTFontURLAttribute));
|
||||
if (CFURLGetFileSystemRepresentation(fontURL.get(), true, file_path, lengthof(file_path))) os_err = noErr;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6)
|
||||
ATSFontRef font = ATSFontFindFromName(name.get(), kATSOptionFlagsDefault);
|
||||
if (font == kInvalidFont) return err;
|
||||
|
||||
/* Get a file system reference for the font. */
|
||||
FSRef ref;
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
if (MacOSVersionIsAtLeast(10, 5, 0)) {
|
||||
os_err = ATSFontGetFileReference(font, &ref);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !defined(__LP64__)
|
||||
/* This type was introduced with the 10.5 SDK. */
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
|
||||
#define ATSFSSpec FSSpec
|
||||
#endif
|
||||
FSSpec spec;
|
||||
os_err = ATSFontGetFileSpecification(font, (ATSFSSpec *)&spec);
|
||||
if (os_err == noErr) os_err = FSpMakeFSRef(&spec, &ref);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Get unix path for file. */
|
||||
if (os_err == noErr) os_err = FSRefMakePath(&ref, file_path, sizeof(file_path));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (os_err == noErr) {
|
||||
DEBUG(freetype, 3, "Font path for %s: %s", font_name, file_path);
|
||||
|
@ -451,10 +419,6 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
|
||||
bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
if (MacOSVersionIsAtLeast(10, 5, 0)) {
|
||||
/* Determine fallback font using CoreText. This uses the language isocode
|
||||
* to find a suitable font. CoreText is available from 10.5 onwards. */
|
||||
char lang[16];
|
||||
|
@ -486,6 +450,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
CFAutoRelease<CFSetRef> mandatory_attribs(CFSetCreate(kCFAllocatorDefault, (const void **)&kCTFontLanguagesAttribute, 1, &kCFTypeSetCallBacks));
|
||||
CFAutoRelease<CFArrayRef> descs(CTFontDescriptorCreateMatchingFontDescriptors(lang_desc.get(), mandatory_attribs.get()));
|
||||
|
||||
bool result = false;
|
||||
for (CFIndex i = 0; descs.get() != nullptr && i < CFArrayGetCount(descs.get()); i++) {
|
||||
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descs.get(), i);
|
||||
|
||||
|
@ -518,45 +483,6 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6)
|
||||
/* Create a font iterator and iterate over all fonts that
|
||||
* are available to the application. */
|
||||
ATSFontIterator itr;
|
||||
ATSFontRef font;
|
||||
ATSFontIteratorCreate(kATSFontContextLocal, nullptr, nullptr, kATSOptionFlagsDefaultScope, &itr);
|
||||
while (!result && ATSFontIteratorNext(itr, &font) == noErr) {
|
||||
/* Get font name. */
|
||||
char name[128];
|
||||
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") != nullptr || strstr(name, "Bold")) continue;
|
||||
|
||||
/* Skip some inappropriate or ugly looking fonts that have better alternatives. */
|
||||
if (name[0] == '.' || strncmp(name, "Apple Symbols", 13) == 0 || strncmp(name, "LastResort", 10) == 0) continue;
|
||||
|
||||
/* Save result. */
|
||||
callback->SetFontNames(settings, name);
|
||||
if (!callback->FindMissingGlyphs(nullptr)) {
|
||||
DEBUG(freetype, 2, "ATS-Font for %s: %s", language_isocode, name);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ATSFontIteratorRelease(&itr);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
/* For some OS versions, the font 'Arial Unicode MS' does not report all languages it
|
||||
|
|
Loading…
Reference in New Issue