OpenTTD Source  1.11.0-beta2
font_win32.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_WIN32_H
11 #define FONT_WIN32_H
12 
13 #include "../../fontcache_internal.h"
14 #include "win32.h"
15 
18 private:
19  LOGFONT logfont;
20  HFONT font = nullptr;
21  HDC dc = nullptr;
22  HGDIOBJ old_font;
23  SIZE glyph_size;
24 
25  void SetFontSize(FontSize fs, int pixels);
26 
27 protected:
28  const void *InternalGetFontTable(uint32 tag, size_t &length) override;
29  const Sprite *InternalGetGlyph(GlyphID key, bool aa) override;
30 
31 public:
32  Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels);
33  ~Win32FontCache();
34  void ClearFontCache() override;
35  GlyphID MapCharToGlyph(WChar key) override;
36  const char *GetFontName() override { return FS2OTTD(this->logfont.lfFaceName); }
37  const void *GetOSHandle() override { return &this->logfont; }
38 };
39 
40 void LoadWin32Font(FontSize fs);
41 
42 #endif /* FONT_WIN32_H */
GlyphID
uint32 GlyphID
Glyphs are characters from a font.
Definition: fontcache.h:17
Win32FontCache::Win32FontCache
Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels)
Create a new Win32FontCache.
Definition: font_win32.cpp:376
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
Win32FontCache::old_font
HGDIOBJ old_font
Old font selected into the GDI context.
Definition: font_win32.h:22
FS2OTTD
const char * FS2OTTD(const wchar_t *name)
Convert to OpenTTD's encoding from wide characters.
Definition: win32.cpp:565
win32.h
Win32FontCache::font
HFONT font
The font face associated with this font.
Definition: font_win32.h:20
LoadWin32Font
void LoadWin32Font(FontSize fs)
Loads the GDI font.
Definition: font_win32.cpp:577
Win32FontCache::dc
HDC dc
Cached GDI device context.
Definition: font_win32.h:21
Win32FontCache::ClearFontCache
void ClearFontCache() override
Reset cached glyphs.
Definition: font_win32.cpp:447
Win32FontCache::GetFontName
const char * GetFontName() override
Get the name of this font.
Definition: font_win32.h:36
FontCache::fs
const FontSize fs
The size of the font.
Definition: fontcache.h:26
Win32FontCache::logfont
LOGFONT logfont
Logical font information for selecting the font face.
Definition: font_win32.h:19
Win32FontCache
Font cache for fonts that are based on a Win32 font.
Definition: font_win32.h:17
Win32FontCache::glyph_size
SIZE glyph_size
Maximum size of regular glyphs.
Definition: font_win32.h:23
Win32FontCache::GetOSHandle
const void * GetOSHandle() override
Get the native OS font handle, if there is one.
Definition: font_win32.h:37
Win32FontCache::MapCharToGlyph
GlyphID MapCharToGlyph(WChar key) override
Map a character into a glyph.
Definition: font_win32.cpp:533
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:206
Sprite
Data structure describing a sprite.
Definition: spritecache.h:17