OpenTTD Source  20240919-master-gdf0233f4c2
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 */
CoreTextFontCache::font_name
std::string font_name
Cached font name.
Definition: font_osx.h:22
TrueTypeFontCache
Font cache for fonts that are based on a TrueType font.
Definition: truetypefontcache.h:22
CoreTextFontCache::GetOSHandle
const void * GetOSHandle() override
Get the native OS font handle, if there is one.
Definition: font_osx.h:34
CoreTextFontCache::MapCharToGlyph
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback=true) override
Map a character into a glyph.
Definition: font_osx.cpp:182
CFAutoRelease
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
CoreTextFontCache::GetFontName
std::string GetFontName() override
Get the name of this font.
Definition: font_osx.h:32
CoreTextFontCache::ClearFontCache
void ClearFontCache() override
Reset cached glyphs.
Definition: font_osx.cpp:119
GlyphID
uint32_t GlyphID
Glyphs are characters from a font.
Definition: fontcache.h:17
CoreTextFontCache::font_desc
CFAutoRelease< CTFontDescriptorRef > font_desc
Font descriptor exlcuding font size.
Definition: font_osx.h:19
FontCache::fs
const FontSize fs
The size of the font.
Definition: fontcache.h:25
CoreTextFontCache
Definition: font_osx.h:18
CoreTextFontCache::IsBuiltInFont
bool IsBuiltInFont() override
Is this a built-in sprite font?
Definition: font_osx.h:33
LoadCoreTextFont
void LoadCoreTextFont(FontSize fs)
Loads the TrueType font.
Definition: font_osx.cpp:329
CoreTextFontCache::font
CFAutoRelease< CTFontRef > font
CoreText font handle.
Definition: font_osx.h:20
macos.h
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:208
Sprite
Data structure describing a sprite.
Definition: spritecache.h:17