OpenTTD Source: src/os/macosx/font_osx.h Source File

OpenTTD Source 12.2

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_internal.h"
14 #include "os/macosx/macos.h"
15
16 #include <CoreFoundation/CoreFoundation.h>
17
18 class CoreTextFontCache : public TrueTypeFontCache {
19 CFAutoRelease<CTFontDescriptorRef> font_desc;
20 CFAutoRelease<CTFontRef> font;
21
22 std::string font_name;
23
24 void SetFontSize(int pixels);
25 const Sprite *InternalGetGlyph(GlyphID key, bool use_aa) override;
26 const void *InternalGetFontTable(uint32 tag, size_t &length) override;
27 public:
28 CoreTextFontCache(FontSize fs, CFAutoRelease<CTFontDescriptorRef> &&font, int pixels);
29 ~CoreTextFontCache() {}
30
31 void ClearFontCache() override;
32 GlyphID MapCharToGlyph(WChar key) override;
33 const char *GetFontName() override { return font_name.c_str(); }
34 bool IsBuiltInFont() override { return false; }
35 const void *GetOSHandle() override { return font.get(); }
36 };
37
38 void LoadCoreTextFont(FontSize fs);
39
40 #endif /* FONT_OSX_H */
GlyphID
uint32 GlyphID
Glyphs are characters from a font.
Definition: fontcache.h:17
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: fontcache_internal.h:23
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:35
CoreTextFontCache::GetOSHandle
const void * GetOSHandle() override
Get the native OS font handle, if there is one.
Definition: font_osx.h:35
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:52
CoreTextFontCache::ClearFontCache
void ClearFontCache() override
Reset cached glyphs.
Definition: font_osx.cpp:164
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:26
CoreTextFontCache
Definition: font_osx.h:18
CoreTextFontCache::IsBuiltInFont
bool IsBuiltInFont() override
Is this a built-in sprite font?
Definition: font_osx.h:34
LoadCoreTextFont
void LoadCoreTextFont(FontSize fs)
Loads the TrueType font.
Definition: font_osx.cpp:349
CoreTextFontCache::font
CFAutoRelease< CTFontRef > font
CoreText font handle.
Definition: font_osx.h:20
CoreTextFontCache::GetFontName
const char * GetFontName() override
Get the name of this font.
Definition: font_osx.h:33
macos.h
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:206
Sprite
Data structure describing a sprite.
Definition: spritecache.h:17
CoreTextFontCache::MapCharToGlyph
GlyphID MapCharToGlyph(WChar key) override
Map a character into a glyph.
Definition: font_osx.cpp:227