2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file font_osx.h Functions related to font handling on MacOS. */
13 #include "../../fontcache/truetypefontcache.h"
14 #include "os/macosx/macos.h"
16 #include <CoreFoundation/CoreFoundation.h>
18 class CoreTextFontCache
: public TrueTypeFontCache
{
19 CFAutoRelease
<CTFontDescriptorRef
> font_desc
; ///< Font descriptor exlcuding font size.
20 CFAutoRelease
<CTFontRef
> font
; ///< CoreText font handle.
22 std::string font_name
; ///< Cached font name.
24 void SetFontSize(int pixels
);
25 const Sprite
*InternalGetGlyph(GlyphID key
, bool use_aa
) override
;
27 CoreTextFontCache(FontSize fs
, CFAutoRelease
<CTFontDescriptorRef
> &&font
, int pixels
);
28 ~CoreTextFontCache() {}
30 void ClearFontCache() override
;
31 GlyphID
MapCharToGlyph(char32_t key
, bool allow_fallback
= true) override
;
32 std::string
GetFontName() override
{ return font_name
; }
33 bool IsBuiltInFont() override
{ return false; }
34 const void *GetOSHandle() override
{ return font
.get(); }
37 void LoadCoreTextFont(FontSize fs
);
39 #endif /* FONT_OSX_H */