Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
Font11.h
Go to the documentation of this file.
1
#pragma once
2
#include "
Sprite11.h
"
3
#include <list>
4
#include <bitset>
5
6
namespace
Rendering
7
{
8
// GDI owns the existing font selection/layout semantics; native textures and
9
// Sprite11 own all GPU work. The 16 MiB run cache also retains shaped text;
10
// an opt-in fixed-width atlas has a separate 4 MiB ceiling per font.
11
class
Font11
12
{
13
public
:
14
Font11
()=
default
;
15
Font11
(
const
Font11
&)=
delete
;
16
Font11
&
operator=
(
const
Font11
&)=
delete
;
17
~Font11
(){
Reset
();}
18
HRESULT
Initialize
(ID3D11Device*
device
,
const
LOGFONTW& description);
19
int
Draw
(
Sprite11
* sprite,
const
wchar_t
* text,
int
count,RECT* rectangle,UINT format,uint32_t color);
20
// Opt-in for rapidly changing fixed-width readouts. Other text/layouts
21
// retain the shaped run cache and its existing GDI semantics.
22
int
DrawFixed
(
Sprite11
* sprite,
const
wchar_t
* text,
int
count,RECT* rectangle,UINT format,uint32_t color);
23
int
DrawAnsi
(
Sprite11
* sprite,
const
char
* text,
int
count,RECT* rectangle,UINT format,uint32_t color);
24
HDC
DC
()
const
{
return
dc
;}
25
bool
Metrics
(TEXTMETRICW& result)
const
{
return
dc
&& GetTextMetricsW(
dc
,&result);}
26
void
Reset
();
27
size_t
CachedBytes
()
const
{
return
cachedBytes
+
fixedBytes
;}
28
size_t
CachedRuns
()
const
{
return
runs
.size();}
29
size_t
FixedAtlasBytes
()
const
{
return
fixedBytes
;}
30
private
:
31
struct
Run
32
{
33
std::wstring
text
;
34
LONG
width
=0,
height
=0;
35
UINT
format
=0;
36
RECT
source
{};
37
POINT
offset
{};
38
int
result
=0;
39
size_t
bytes
=0;
40
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>
texture
;
41
};
42
struct
Line
{std::wstring
text
;LONG
x
=0,
y
=0,
width
=0;};
43
bool
Words
(
const
std::wstring& text,std::vector<Line>& words);
44
int
Layout
(
const
std::wstring& text,LONG width,LONG height,UINT format,std::vector<Line>& lines,RECT& bounds);
45
HRESULT
Rasterize
(
Run
& run);
46
bool
PrepareFixedAtlas
();
47
struct
Glyph
{RECT
source
{};POINT
offset
{};
bool
independent
=
true
;};
48
std::array<Glyph,95>
fixedGlyphs
{};
49
std::bitset<95*95>
fixedPairOverlap
;
50
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>
fixedAtlas
;
51
LONG
fixedAdvance
=0,
fixedHeight
=0;
52
size_t
fixedBytes
=0;
53
bool
fixedAttempted
=
false
;
54
Microsoft::WRL::ComPtr<ID3D11Device>
device
;
55
HDC
dc
=
nullptr
;
56
HFONT
font
=
nullptr
;
57
HGDIOBJ
previousFont
=
nullptr
;
58
std::list<Run>
runs
;
59
size_t
cachedBytes
=0;
60
static
constexpr
size_t
CacheLimit
=16*1024*1024;
61
};
62
}
HRESULT
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
Sprite11.h
Rendering::Font11::font
HFONT font
Definition
Font11.h:56
Rendering::Font11::DrawFixed
int DrawFixed(Sprite11 *sprite, const wchar_t *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition
Font11.cpp:346
Rendering::Font11::~Font11
~Font11()
Definition
Font11.h:17
Rendering::Font11::Rasterize
HRESULT Rasterize(Run &run)
Definition
Font11.cpp:129
Rendering::Font11::Words
bool Words(const std::wstring &text, std::vector< Line > &words)
Definition
Font11.cpp:33
Rendering::Font11::runs
std::list< Run > runs
Definition
Font11.h:58
Rendering::Font11::Draw
int Draw(Sprite11 *sprite, const wchar_t *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition
Font11.cpp:215
Rendering::Font11::Metrics
bool Metrics(TEXTMETRICW &result) const
Definition
Font11.h:25
Rendering::Font11::CacheLimit
static constexpr size_t CacheLimit
Definition
Font11.h:60
Rendering::Font11::Layout
int Layout(const std::wstring &text, LONG width, LONG height, UINT format, std::vector< Line > &lines, RECT &bounds)
Definition
Font11.cpp:55
Rendering::Font11::cachedBytes
size_t cachedBytes
Definition
Font11.h:59
Rendering::Font11::operator=
Font11 & operator=(const Font11 &)=delete
Rendering::Font11::fixedAdvance
LONG fixedAdvance
Definition
Font11.h:51
Rendering::Font11::FixedAtlasBytes
size_t FixedAtlasBytes() const
Definition
Font11.h:29
Rendering::Font11::fixedAttempted
bool fixedAttempted
Definition
Font11.h:53
Rendering::Font11::DC
HDC DC() const
Definition
Font11.h:24
Rendering::Font11::CachedRuns
size_t CachedRuns() const
Definition
Font11.h:28
Rendering::Font11::fixedGlyphs
std::array< Glyph, 95 > fixedGlyphs
Definition
Font11.h:48
Rendering::Font11::Reset
void Reset()
Definition
Font11.cpp:11
Rendering::Font11::fixedAtlas
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > fixedAtlas
Definition
Font11.h:50
Rendering::Font11::fixedPairOverlap
std::bitset< 95 *95 > fixedPairOverlap
Definition
Font11.h:49
Rendering::Font11::DrawAnsi
int DrawAnsi(Sprite11 *sprite, const char *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition
Font11.cpp:383
Rendering::Font11::previousFont
HGDIOBJ previousFont
Definition
Font11.h:57
Rendering::Font11::device
Microsoft::WRL::ComPtr< ID3D11Device > device
Definition
Font11.h:54
Rendering::Font11::fixedHeight
LONG fixedHeight
Definition
Font11.h:51
Rendering::Font11::Font11
Font11()=default
Rendering::Font11::dc
HDC dc
Definition
Font11.h:55
Rendering::Font11::PrepareFixedAtlas
bool PrepareFixedAtlas()
Definition
Font11.cpp:254
Rendering::Font11::Initialize
HRESULT Initialize(ID3D11Device *device, const LOGFONTW &description)
Definition
Font11.cpp:22
Rendering::Font11::fixedBytes
size_t fixedBytes
Definition
Font11.h:52
Rendering::Font11::Font11
Font11(const Font11 &)=delete
Rendering::Font11::CachedBytes
size_t CachedBytes() const
Definition
Font11.h:27
Rendering::Sprite11
Definition
Sprite11.h:9
Rendering
Definition
AdDiagnostics11.cpp:16
Rendering::Font11::Glyph
Definition
Font11.h:47
Rendering::Font11::Glyph::offset
POINT offset
Definition
Font11.h:47
Rendering::Font11::Glyph::independent
bool independent
Definition
Font11.h:47
Rendering::Font11::Glyph::source
RECT source
Definition
Font11.h:47
Rendering::Font11::Line
Definition
Font11.h:42
Rendering::Font11::Line::text
std::wstring text
Definition
Font11.h:42
Rendering::Font11::Line::x
LONG x
Definition
Font11.h:42
Rendering::Font11::Line::y
LONG y
Definition
Font11.h:42
Rendering::Font11::Line::width
LONG width
Definition
Font11.h:42
Rendering::Font11::Run
Definition
Font11.h:32
Rendering::Font11::Run::result
int result
Definition
Font11.h:38
Rendering::Font11::Run::texture
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > texture
Definition
Font11.h:40
Rendering::Font11::Run::width
LONG width
Definition
Font11.h:34
Rendering::Font11::Run::source
RECT source
Definition
Font11.h:36
Rendering::Font11::Run::offset
POINT offset
Definition
Font11.h:37
Rendering::Font11::Run::height
LONG height
Definition
Font11.h:34
Rendering::Font11::Run::bytes
size_t bytes
Definition
Font11.h:39
Rendering::Font11::Run::text
std::wstring text
Definition
Font11.h:33
Rendering::Font11::Run::format
UINT format
Definition
Font11.h:35
Rendering
Font11.h
Generated on
for Rise by
1.18.0