OpenTTD Source  20241108-master-g80f628063a
font_osx.h
Go to the documentation of this file.
1 /*
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/>.
6  */
7 
10 #ifndef FONT_OSX_H
11 #define FONT_OSX_H
12 
13 #include "../../fontcache/truetypefontcache.h"
14 #include "os/macosx/macos.h"
15 
16 #include <CoreFoundation/CoreFoundation.h>
17 
21 
22  std::string font_name;
23 
24  void SetFontSize(int pixels);
25  const Sprite *InternalGetGlyph(GlyphID key, bool use_aa) override;
26 public:
28  ~CoreTextFontCache() {}
29 
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(); }
35 };
36 
37 void LoadCoreTextFont(FontSize fs);
38 
39 #endif /* FONT_OSX_H */
CFAutoRelease< CTFontDescriptorRef > font_desc
Font descriptor exlcuding font size.
Definition: font_osx.h:19
bool IsBuiltInFont() override
Is this a built-in sprite font?
Definition: font_osx.h:33
std::string font_name
Cached font name.
Definition: font_osx.h:22
CFAutoRelease< CTFontRef > font
CoreText font handle.
Definition: font_osx.h:20
void ClearFontCache() override
Reset cached glyphs.
Definition: font_osx.cpp:119
std::string GetFontName() override
Get the name of this font.
Definition: font_osx.h:32
const void * GetOSHandle() override
Get the native OS font handle, if there is one.
Definition: font_osx.h:34
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback=true) override
Map a character into a glyph.
Definition: font_osx.cpp:182
const FontSize fs
The size of the font.
Definition: fontcache.h:25
Font cache for fonts that are based on a TrueType font.
void LoadCoreTextFont(FontSize fs)
Loads the TrueType font.
Definition: font_osx.cpp:329
uint32_t GlyphID
Glyphs are characters from a font.
Definition: fontcache.h:17
FontSize
Available font sizes.
Definition: gfx_type.h:208
Functions related to MacOS support.
std::unique_ptr< typename std::remove_pointer< T >::type, CFDeleter< typename std::remove_pointer< T >::type > > CFAutoRelease
Specialisation of std::unique_ptr for CoreFoundation objects.
Definition: macos.h:54
Data structure describing a sprite.
Definition: spritecache.h:17