OpenTTD Source: src/os/windows/font_win32.h Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef FONT_WIN32_H
11#define FONT_WIN32_H
12
13#include "../../core/alloc_type.hpp"
14#include "../../fontcache/truetypefontcache.h"
15#include "win32.h"
16
17#include <windows.h>
18
20 class Win32FontCache : public TrueTypeFontCache {
21private:
22 LOGFONT logfont;
23 HFONT font = nullptr;
24 HDC dc = nullptr;
25 HGDIOBJ old_font;
26 SIZE glyph_size;
27 std::string fontname;
28
29 ReusableBuffer<uint8_t> render_buffer;
30
31 void SetFontSize(int pixels);
32
33protected:
34 const Sprite *InternalGetGlyph(GlyphID key, bool aa) override;
35
36public:
37 Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels);
38 ~Win32FontCache();
39 void ClearFontCache() override;
40 GlyphID MapCharToGlyph(char32_t key, bool allow_fallback = true) override;
41 std::string GetFontName() override { return this->fontname; }
42 const void *GetOSHandle() override { return &this->logfont; }
43};
44
45void LoadWin32Font(FontSize fs);
46
47#endif /* FONT_WIN32_H */
FontCache::fs
const FontSize fs
The size of the font.
Definition fontcache.h:26
ReusableBuffer
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
Definition alloc_type.hpp:22
TrueTypeFontCache
Font cache for fonts that are based on a TrueType font.
Definition truetypefontcache.h:22
Win32FontCache
Font cache for fonts that are based on a Win32 font.
Definition font_win32.h:20
Win32FontCache::old_font
HGDIOBJ old_font
Old font selected into the GDI context.
Definition font_win32.h:25
Win32FontCache::fontname
std::string fontname
Cached copy of loaded font facename.
Definition font_win32.h:27
Win32FontCache::font
HFONT font
The font face associated with this font.
Definition font_win32.h:23
Win32FontCache::MapCharToGlyph
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback=true) override
Map a character into a glyph.
Definition font_win32.cpp:248
Win32FontCache::dc
HDC dc
Cached GDI device context.
Definition font_win32.h:24
Win32FontCache::GetOSHandle
const void * GetOSHandle() override
Get the native OS font handle, if there is one.
Definition font_win32.h:42
Win32FontCache::ClearFontCache
void ClearFontCache() override
Reset cached glyphs.
Definition font_win32.cpp:168
Win32FontCache::GetFontName
std::string GetFontName() override
Get the name of this font.
Definition font_win32.h:41
Win32FontCache::logfont
LOGFONT logfont
Logical font information for selecting the font face.
Definition font_win32.h:22
Win32FontCache::glyph_size
SIZE glyph_size
Maximum size of regular glyphs.
Definition font_win32.h:26
Win32FontCache::render_buffer
ReusableBuffer< uint8_t > render_buffer
Temporary buffer for rendering glyphs.
Definition font_win32.h:29
GlyphID
uint32_t GlyphID
Glyphs are characters from a font.
Definition fontcache.h:18
FontSize
FontSize
Available font sizes.
Definition gfx_type.h:248
Sprite
Data structure describing a sprite.
Definition spritecache_type.h:16
win32.h
declarations of functions for MS windows systems