Rise
The Vieneo Province
Loading...
Searching...
No Matches
Font11.cpp
Go to the documentation of this file.
1#include "Font11.h"
2#include "FrameProfiler11.h"
3#include <algorithm>
4#include <cmath>
5#include <cstring>
6#include <cwchar>
7#include <limits>
8
9namespace Rendering
10{
12 {
13 runs.clear();cachedBytes=0;device.Reset();
15 fixedPairOverlap.reset();
16 if(dc && previousFont)SelectObject(dc,previousFont);
17 if(font)DeleteObject(font);
18 if(dc)DeleteDC(dc);
19 dc=nullptr;font=nullptr;previousFont=nullptr;
20 }
21
22 HRESULT Font11::Initialize(ID3D11Device* native,const LOGFONTW& description)
23 {
24 Reset();if(!native || description.lfEscapement || description.lfOrientation)return E_INVALIDARG;
25 device=native;dc=CreateCompatibleDC(nullptr);font=CreateFontIndirectW(&description);
26 if(!dc || !font){Reset();return E_FAIL;}
27 previousFont=SelectObject(dc,font);
28 if(!previousFont || previousFont==HGDI_ERROR){previousFont=nullptr;Reset();return E_FAIL;}
29 SetBkMode(dc,TRANSPARENT);SetTextColor(dc,RGB(255,255,255));
30 return S_OK;
31 }
32
33 bool Font11::Words(const std::wstring& text,std::vector<Line>& words)
34 {
35 // D3DX lays Latin words out independently, avoiding kerning across spaces.
36 // Keep whole-run GDI shaping for scripts that need contextual selection.
37 for(const auto character:text)if(character<L' ' || character>=0x300)return false;
38 LONG x=0;
39 for(size_t i=0;i<text.size();)
40 {
41 const size_t first=i;const bool spaces=text[i]==L' ';
42 while(i<text.size() && (text[i]==L' ')==spaces)++i;
43 if(!spaces)while(i<text.size() && text[i]==L' ')++i;
44 Line word;word.text=text.substr(first,i-first);word.x=x;
45 if(spaces)
46 {
47 SIZE size{};GetTextExtentPoint32W(dc,word.text.c_str(),int(word.text.size()),&size);word.width=size.cx;
48 }
49 else {RECT bounds{};::DrawTextW(dc,word.text.c_str(),int(word.text.size()),&bounds,DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX);word.width=bounds.right;}
50 x+=word.width;words.push_back(std::move(word));
51 }
52 return true;
53 }
54
55 int Font11::Layout(const std::wstring& text,LONG width,LONG height,UINT format,std::vector<Line>& lines,RECT& bounds)
56 {
57 ProfileDisplayCpu11 timing("Text layout");
58 TEXTMETRICW metric{};if(!GetTextMetricsW(dc,&metric))return 0;
59 const auto measure=[&](const std::wstring& line) {
60 std::vector<Line> words;
61 if(Words(line,words))
62 {
63 return words.empty() ? 0L : words.back().x+words.back().width;
64 }
65 RECT rectangle{};::DrawTextW(dc,line.c_str(),int(line.size()),&rectangle,
66 DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|(format&(DT_EXPANDTABS|DT_RTLREADING)));
67 return rectangle.right;
68 };
69 std::wstring normalized;
70 for(const auto character:text)
71 if(character!=L'\r' && !(character==L'\n' && (format&DT_SINGLELINE)) && !(character==L'\t' && !(format&DT_EXPANDTABS)))
72 normalized+=character;
73 if(normalized.empty()){bounds={};return 0;}
74 std::wstring line;
75 auto append=[&]() {
76 Line entry;entry.text=line;entry.width=measure(line);
77 const size_t last=line.find_last_not_of(L" \t");
78 if(last==std::wstring::npos)entry.width=0;
79 else if(last+1<line.size())entry.width-=measure(line.substr(last+1));
80 lines.push_back(std::move(entry));line.clear();
81 };
82 for(size_t i=0;i<normalized.size();)
83 {
84 if(normalized[i]==L'\n')
85 {
86 ++i;
87 append();continue;
88 }
89 if((format&DT_WORDBREAK) && !(format&DT_SINGLELINE))
90 {
91 const size_t start=i;while(i<normalized.size() && normalized[i]!=L' ' && normalized[i]!=L'\t' && normalized[i]!=L'\n')++i;
92 if(i<normalized.size() && (normalized[i]==L' ' || normalized[i]==L'\t'))++i;
93 const auto word=normalized.substr(start,i-start);
94 // D3DX includes the following space in the fit decision, unlike
95 // GDI DrawText's word breaker. Preserve this legacy wrapping.
96 if(!line.empty() && measure(line+word)>width)
97 {
98 while(!line.empty() && (line.back()==L' ' || line.back()==L'\t'))line.pop_back();
99 append();
100 }
101 line+=word;
102 while(line.size()>1 && measure(line)>width)
103 {
104 size_t count=1;
105 while(count<line.size() && measure(line.substr(0,count+1))<=width)++count;
106 const auto remainder=line.substr(count);line.resize(count);append();line=remainder;
107 }
108 }
109 else line+=normalized[i++];
110 }
111 if(!line.empty() || lines.empty())append();
112 LONG y=0;
113 const LONG blockHeight=LONG(lines.size())*metric.tmHeight;
114 if(format&DT_VCENTER)y=LONG(std::floor(double(height-blockHeight)/2));
115 else if(format&DT_BOTTOM)y=height-blockHeight;
116 bounds={LONG_MAX,y,LONG_MIN,y};
117 for(auto& entry:lines)
118 {
119 bool right=(format&DT_RIGHT)!=0;
120 if(format&DT_RTLREADING)right=!right;
121 if(right && !(format&DT_CENTER))entry.x=width-entry.width;
122 else if(format&DT_CENTER)entry.x=(width-entry.width)/2;
123 entry.y=y;y+=metric.tmHeight;
124 bounds.left=(std::min)(bounds.left,entry.x);bounds.right=(std::max)(bounds.right,entry.x+entry.width);
125 }
126 bounds.bottom=y;return y;
127 }
128
130 {
131 ProfileDisplayCpu11 timing("Text rasterize cache miss");
132 TEXTMETRICW metric{};if(!GetTextMetricsW(dc,&metric))return E_FAIL;
133 const LONG border=(std::max)(4L,metric.tmHeight+metric.tmOverhang);
134 RECT measured{};std::vector<Line> lines;
135 run.result=Layout(run.text,run.width,run.height,run.format,lines,measured);
136 const LONG originX=border-measured.left,originY=border-measured.top;
137 const LONG width=(std::max)(1L,measured.right-measured.left)+border*2;
138 const LONG height=(std::max)(1L,measured.bottom-measured.top)+border*2;
139 if(width>8192 || height>8192 || size_t(width)*height>CacheLimit/4)return E_INVALIDARG;
140 BITMAPINFO info{};info.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
141 info.bmiHeader.biWidth=width;info.bmiHeader.biHeight=-height;
142 info.bmiHeader.biPlanes=1;info.bmiHeader.biBitCount=32;info.bmiHeader.biCompression=BI_RGB;
143 void* memory=nullptr;HBITMAP bitmap=CreateDIBSection(dc,&info,DIB_RGB_COLORS,&memory,nullptr,0);
144 if(!bitmap)return E_OUTOFMEMORY;
145 const auto previousBitmap=SelectObject(dc,bitmap);
146 if(!previousBitmap || previousBitmap==HGDI_ERROR){DeleteObject(bitmap);return E_FAIL;}
147 auto* pixels=static_cast<uint32_t*>(memory);std::fill(pixels,pixels+size_t(width)*height,0);
148 const int saved=SaveDC(dc);
149 if(!saved){SelectObject(dc,previousBitmap);DeleteObject(bitmap);return E_FAIL;}
150 if(!(run.format&DT_NOCLIP))IntersectClipRect(dc,originX,originY,originX+run.width,originY+run.height);
151 for(const auto& line:lines)
152 {
153 RECT destination{originX+line.x,originY+line.y,originX+line.x+line.width,originY+line.y+metric.tmHeight};
154 std::vector<Line> words;
155 if(Words(line.text,words))
156 {
157 for(const auto& word:words)
158 {
159 RECT placed{destination.left+word.x,destination.top,destination.left+word.x+word.width,destination.bottom};
160 ::DrawTextW(dc,word.text.c_str(),int(word.text.size()),&placed,DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP);
161 }
162 }
163 else
164 ::DrawTextW(dc,line.text.c_str(),int(line.text.size()),&destination,
165 DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|(run.format&(DT_EXPANDTABS|DT_RTLREADING)));
166 }
167 RestoreDC(dc,saved);
168 GdiFlush();
169 RECT bounds{width,height,0,0};
170 for(LONG y=0;y<height;++y)for(LONG x=0;x<width;++x)if(pixels[size_t(y)*width+x]&0xffffff)
171 {
172 bounds.left=(std::min)(bounds.left,x);bounds.top=(std::min)(bounds.top,y);
173 bounds.right=(std::max)(bounds.right,x+1);bounds.bottom=(std::max)(bounds.bottom,y+1);
174 }
175 HRESULT hr=S_OK;
176 if(bounds.right>bounds.left && bounds.bottom>bounds.top)
177 {
178 // One transparent texel around each edge keeps filtered/rotated text
179 // from extending the last covered texel beyond its glyph.
180 bounds.left=(std::max)(0L,bounds.left-1);bounds.top=(std::max)(0L,bounds.top-1);
181 bounds.right=(std::min)(width,bounds.right+1);bounds.bottom=(std::min)(height,bounds.bottom+1);
182 // GDI clips covered texels, but the transparent filtering border
183 // can still extend a scaled quad outside the text rectangle.
184 // Clip the quad too, so stationary labels and scrolling labels
185 // share the same boundary at fractional display scales.
186 if(!(run.format&DT_NOCLIP))
187 {
188 bounds.left=(std::max)(bounds.left,originX);bounds.top=(std::max)(bounds.top,originY);
189 bounds.right=(std::min)(bounds.right,originX+run.width);bounds.bottom=(std::min)(bounds.bottom,originY+run.height);
190 }
191 const UINT tw=UINT(bounds.right-bounds.left),th=UINT(bounds.bottom-bounds.top);
192 std::vector<uint32_t> coverage(size_t(tw)*th);
193 for(UINT y=0;y<th;++y)for(UINT x=0;x<tw;++x)
194 {
195 const uint32_t source=pixels[size_t(y+bounds.top)*width+x+bounds.left];
196 coverage[size_t(y)*tw+x]=0xffffff|((source&255)<<24);
197 }
198 D3D11_TEXTURE2D_DESC desc{};desc.Width=tw;desc.Height=th;desc.MipLevels=desc.ArraySize=1;
199 desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;desc.SampleDesc.Count=1;
200 desc.Usage=D3D11_USAGE_IMMUTABLE;desc.BindFlags=D3D11_BIND_SHADER_RESOURCE;
201 const D3D11_SUBRESOURCE_DATA initial{coverage.data(),tw*4,0};
202 Microsoft::WRL::ComPtr<ID3D11Texture2D> texture;
203 ProfileDisplayCpu11 uploadTiming("Text texture creation");
204 hr=device->CreateTexture2D(&desc,&initial,&texture);
205 if(SUCCEEDED(hr))hr=device->CreateShaderResourceView(texture.Get(),nullptr,&run.texture);
206 if(SUCCEEDED(hr))FrameProfiler11::Get().TextureUpload(UINT64(tw)*th*4);
207 uploadTiming.Stop();
208 run.source={0,0,LONG(tw),LONG(th)};run.offset={bounds.left-originX,bounds.top-originY};
209 run.bytes=coverage.size()*4;
210 }
211 SelectObject(dc,previousBitmap);DeleteObject(bitmap);
212 return hr;
213 }
214
215 int Font11::Draw(Sprite11* sprite,const wchar_t* text,int count,RECT* rectangle,UINT format,uint32_t color)
216 {
217 ProfileDisplayCpu11 timing("Text draw");
218 constexpr UINT supported=DT_BOTTOM|DT_CALCRECT|DT_CENTER|DT_EXPANDTABS|DT_NOCLIP|DT_RIGHT|DT_RTLREADING|DT_SINGLELINE|DT_VCENTER|DT_WORDBREAK;
219 if(!dc || !text || !rectangle || count<-1 || (format&~supported))return 0;
220 const size_t length=count<0 ? wcslen(text) : size_t(count);
221 if(length>size_t((std::numeric_limits<int>::max)()))return 0;
222 if(format&DT_CALCRECT)
223 {
224 RECT bounds{};std::vector<Line> lines;
225 const int result=Layout(std::wstring(text,length),rectangle->right-rectangle->left,rectangle->bottom-rectangle->top,format,lines,bounds);
226 OffsetRect(&bounds,rectangle->left,rectangle->top);*rectangle=bounds;return result;
227 }
228 if(!sprite)return 0;
229 const LONG width=rectangle->right-rectangle->left,height=rectangle->bottom-rectangle->top;
230 ProfileDisplayCpu11 lookupTiming("Text cache lookup");
231 auto found=std::find_if(runs.begin(),runs.end(),[&](const Run& run) {
232 return run.width==width && run.height==height && run.format==format
233 && run.text.size()==length && run.text.compare(0,length,text,length)==0;
234 });
235 lookupTiming.Stop();
236 if(found==runs.end())
237 {
238 Run run;run.text.assign(text,length);run.width=width;run.height=height;run.format=format;
239 if(FAILED(Rasterize(run)))return 0;
240 cachedBytes+=run.bytes;runs.push_front(std::move(run));
241 while(runs.size()>1 && (cachedBytes>CacheLimit || runs.size()>256))
242 {cachedBytes-=runs.back().bytes;runs.pop_back();}
243 }
244 else runs.splice(runs.begin(),runs,found);
245 const auto& run=runs.front();
246 if(run.texture)
247 {
248 const Sprite11::Vector position(float(rectangle->left+run.offset.x),float(rectangle->top+run.offset.y),0);
249 if(FAILED(sprite->Draw(run.texture.Get(),&run.source,nullptr,&position,color)))return 0;
250 }
251 return run.result;
252 }
253
255 {
256 if(fixedAttempted)return bool(fixedAtlas);
257 fixedAttempted=true;
258 ProfileDisplayCpu11 timing("Text fixed atlas build");
259 TEXTMETRICW metric{};
260 // TMPF_FIXED_PITCH is set for variable-pitch fonts. Italic/overhanging
261 // fonts can overlap adjacent cells and must keep whole-run blending.
262 if(!GetTextMetricsW(dc,&metric) || (metric.tmPitchAndFamily&TMPF_FIXED_PITCH)
263 || metric.tmItalic || metric.tmOverhang || metric.tmAveCharWidth<=0 || metric.tmHeight<=0
264 || metric.tmAveCharWidth>256 || metric.tmHeight>256)return false;
265 fixedAdvance=metric.tmAveCharWidth;fixedHeight=metric.tmHeight;
266 for(wchar_t c=L' ';c<=L'~';++c)
267 {
268 SIZE size{};
269 if(!GetTextExtentPoint32W(dc,&c,1,&size) || size.cx!=fixedAdvance)return false;
270 }
271 const DWORD pairCount=GetKerningPairsW(dc,0,nullptr);
272 std::vector<KERNINGPAIR> pairs(pairCount);
273 if(pairCount && GetKerningPairsW(dc,pairCount,pairs.data())!=pairCount)return false;
274 for(const auto& pair:pairs)
275 if(pair.iKernAmount && pair.wFirst>=32 && pair.wFirst<=126 && pair.wSecond>=32 && pair.wSecond<=126)return false;
276 const LONG border=(std::max)(4L,fixedHeight);
277 const LONG cellWidth=fixedAdvance+border*2,cellHeight=fixedHeight+border*2;
278 const LONG width=cellWidth*16,height=cellHeight*6;
279 if(width>8192 || height>8192 || size_t(width)*height>CacheLimit/16)return false;
280 BITMAPINFO info{};info.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
281 info.bmiHeader.biWidth=width;info.bmiHeader.biHeight=-height;
282 info.bmiHeader.biPlanes=1;info.bmiHeader.biBitCount=32;info.bmiHeader.biCompression=BI_RGB;
283 void* memory=nullptr;HBITMAP bitmap=CreateDIBSection(dc,&info,DIB_RGB_COLORS,&memory,nullptr,0);
284 if(!bitmap)return false;
285 const auto previousBitmap=SelectObject(dc,bitmap);
286 if(!previousBitmap || previousBitmap==HGDI_ERROR){DeleteObject(bitmap);return false;}
287 auto* pixels=static_cast<uint32_t*>(memory);std::fill(pixels,pixels+size_t(width)*height,0);
288 for(size_t i=0;i<fixedGlyphs.size();++i)
289 {
290 const wchar_t c=wchar_t(i+32);
291 RECT rectangle{LONG(i%16)*cellWidth+border,LONG(i/16)*cellHeight+border,0,0};
292 rectangle.right=rectangle.left+fixedAdvance;rectangle.bottom=rectangle.top+fixedHeight;
293 ::DrawTextW(dc,&c,1,&rectangle,DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP);
294 }
295 GdiFlush();
296 for(size_t i=0;i<fixedGlyphs.size();++i)
297 {
298 const LONG left=LONG(i%16)*cellWidth,top=LONG(i/16)*cellHeight;
299 RECT bounds{cellWidth,cellHeight,0,0};
300 for(LONG y=0;y<cellHeight;++y)for(LONG x=0;x<cellWidth;++x)
301 if(pixels[size_t(top+y)*width+left+x]&0xffffff)
302 {
303 bounds.left=(std::min)(bounds.left,x);bounds.top=(std::min)(bounds.top,y);
304 bounds.right=(std::max)(bounds.right,x+1);bounds.bottom=(std::max)(bounds.bottom,y+1);
305 }
306 if(bounds.right>bounds.left && bounds.bottom>bounds.top)
307 {
308 // Bound overhang to immediate neighbors; their actual covered
309 // pixels are checked below, rather than just bounding boxes.
310 if(bounds.left<border-fixedAdvance/2 || bounds.right>border+fixedAdvance+fixedAdvance/2
311 || bounds.top<=0 || bounds.bottom>=cellHeight)fixedGlyphs[i].independent=false;
312 --bounds.left;--bounds.top;++bounds.right;++bounds.bottom;
313 fixedGlyphs[i].offset={bounds.left-border,bounds.top-border};
314 OffsetRect(&bounds,left,top);fixedGlyphs[i].source=bounds;
315 }
316 }
317 for(size_t a=0;a<fixedGlyphs.size();++a)for(size_t b=0;b<fixedGlyphs.size();++b)
318 {
319 const auto& first=fixedGlyphs[a];const auto& second=fixedGlyphs[b];
320 if(first.source.right==first.source.left || second.source.right==second.source.left)continue;
321 const LONG left=(std::max)(first.offset.x+1,fixedAdvance+second.offset.x+1);
322 const LONG right=(std::min)(first.offset.x+first.source.right-first.source.left-1,
323 fixedAdvance+second.offset.x+second.source.right-second.source.left-1);
324 const LONG top=(std::max)(first.offset.y+1,second.offset.y+1);
325 const LONG bottom=(std::min)(first.offset.y+first.source.bottom-first.source.top-1,
326 second.offset.y+second.source.bottom-second.source.top-1);
327 for(LONG y=top;y<bottom;++y)for(LONG x=left;x<right;++x)
328 if((pixels[size_t(first.source.top+y-first.offset.y)*width+first.source.left+x-first.offset.x]&255)
329 && (pixels[size_t(second.source.top+y-second.offset.y)*width+second.source.left+x-fixedAdvance-second.offset.x]&255))
330 fixedPairOverlap.set(a*fixedGlyphs.size()+b);
331 }
332 for(size_t i=0;i<size_t(width)*height;++i)pixels[i]=0xffffff|((pixels[i]&255)<<24);
333 D3D11_TEXTURE2D_DESC desc{};desc.Width=width;desc.Height=height;desc.MipLevels=desc.ArraySize=1;
334 desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;desc.SampleDesc.Count=1;
335 desc.Usage=D3D11_USAGE_IMMUTABLE;desc.BindFlags=D3D11_BIND_SHADER_RESOURCE;
336 const D3D11_SUBRESOURCE_DATA initial{pixels,UINT(width)*4,0};
337 Microsoft::WRL::ComPtr<ID3D11Texture2D> texture;
338 HRESULT hr=device->CreateTexture2D(&desc,&initial,&texture);
339 if(SUCCEEDED(hr))hr=device->CreateShaderResourceView(texture.Get(),nullptr,&fixedAtlas);
340 SelectObject(dc,previousBitmap);DeleteObject(bitmap);
341 if(FAILED(hr))return false;
343 return true;
344 }
345
346 int Font11::DrawFixed(Sprite11* sprite,const wchar_t* text,int count,RECT* rectangle,UINT format,uint32_t color)
347 {
348 if(!dc || !text || !rectangle || count<-1)return 0;
349 const size_t length=count<0 ? wcslen(text) : size_t(count);
350 const auto fallback=[&](){return Draw(sprite,text,count,rectangle,format,color);};
351 if(!sprite || (format!=DT_NOCLIP && format!=(DT_NOCLIP|DT_SINGLELINE)) || length>4096)return fallback();
352 if(!length)return 0;
353 // Separate glyph quads blend identically on the pixel grid. Fractional
354 // transforms filter neighboring glyphs together in a whole-run texture,
355 // so retain that path there. Instruments draw at integer coordinates
356 // into their display texture; subsequent screen scaling is unchanged.
357 const auto& transform=sprite->Transform();
358 if(transform._11!=1 || transform._22!=1 || transform._44!=1
359 || transform._12 || transform._13 || transform._14 || transform._21 || transform._23 || transform._24
360 || transform._31 || transform._32 || transform._34
361 || transform._41!=std::floor(transform._41) || transform._42!=std::floor(transform._42))return fallback();
362 for(size_t i=0;i<length;++i)if(text[i]<L' ' || text[i]>L'~')return fallback();
363 if(!PrepareFixedAtlas())return fallback();
364 // Preserve whole-run blending if adjacent glyphs cover the same pixel.
365 for(size_t i=0;i<length;++i)
366 {
367 const size_t glyph=size_t(text[i]-L' ');
368 if(!fixedGlyphs[glyph].independent
369 || (i && fixedPairOverlap.test(size_t(text[i-1]-L' ')*fixedGlyphs.size()+glyph)))return fallback();
370 }
371 ProfileDisplayCpu11 timing("Text draw");
372 ProfileDisplayCpu11 atlasTiming("Text fixed atlas draw");
373 for(size_t i=0;i<length;++i)
374 {
375 const auto& glyph=fixedGlyphs[size_t(text[i]-L' ')];
376 if(glyph.source.right==glyph.source.left)continue;
377 const Sprite11::Vector at(float(rectangle->left+LONG(i)*fixedAdvance+glyph.offset.x),float(rectangle->top+glyph.offset.y),0);
378 if(FAILED(sprite->Draw(fixedAtlas.Get(),&glyph.source,nullptr,&at,color)))return 0;
379 }
380 return fixedHeight;
381 }
382
383 int Font11::DrawAnsi(Sprite11* sprite,const char* text,int count,RECT* rectangle,UINT format,uint32_t color)
384 {
385 if(!text || count<-1)return 0;
386 const size_t inputLength=count<0 ? strlen(text) : size_t(count);
387 if(inputLength>size_t((std::numeric_limits<int>::max)()))return 0;
388 const int length=int(inputLength);
389 const int required=MultiByteToWideChar(CP_ACP,0,text,length,nullptr,0);
390 if(required<=0)return 0;
391 std::wstring converted(size_t(required),L'\0');
392 if(!MultiByteToWideChar(CP_ACP,0,text,length,converted.data(),required))return 0;
393 return Draw(sprite,converted.c_str(),required,rectangle,format,color);
394 }
395}
SCRIPT_CONTROL SCRIPT_STATE const void int
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
int DrawFixed(Sprite11 *sprite, const wchar_t *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition Font11.cpp:346
HRESULT Rasterize(Run &run)
Definition Font11.cpp:129
bool Words(const std::wstring &text, std::vector< Line > &words)
Definition Font11.cpp:33
std::list< Run > runs
Definition Font11.h:58
int Draw(Sprite11 *sprite, const wchar_t *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition Font11.cpp:215
static constexpr size_t CacheLimit
Definition Font11.h:60
int Layout(const std::wstring &text, LONG width, LONG height, UINT format, std::vector< Line > &lines, RECT &bounds)
Definition Font11.cpp:55
size_t cachedBytes
Definition Font11.h:59
LONG fixedAdvance
Definition Font11.h:51
bool fixedAttempted
Definition Font11.h:53
std::array< Glyph, 95 > fixedGlyphs
Definition Font11.h:48
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > fixedAtlas
Definition Font11.h:50
std::bitset< 95 *95 > fixedPairOverlap
Definition Font11.h:49
int DrawAnsi(Sprite11 *sprite, const char *text, int count, RECT *rectangle, UINT format, uint32_t color)
Definition Font11.cpp:383
HGDIOBJ previousFont
Definition Font11.h:57
Microsoft::WRL::ComPtr< ID3D11Device > device
Definition Font11.h:54
bool PrepareFixedAtlas()
Definition Font11.cpp:254
HRESULT Initialize(ID3D11Device *device, const LOGFONTW &description)
Definition Font11.cpp:22
size_t fixedBytes
Definition Font11.h:52
void TextureUpload(UINT64 bytes)
static FrameProfiler11 & Get()
DirectX::XMFLOAT3 Vector
Definition Sprite11.h:11
const Matrix & Transform() const
Definition Sprite11.h:22
HRESULT Draw(ID3D11ShaderResourceView *texture, const RECT *source=nullptr, const Vector *center=nullptr, const Vector *position=nullptr, uint32_t color=0xffffffff)
Definition Sprite11.cpp:100
std::wstring text
Definition Font11.h:42
Microsoft::WRL::ComPtr< ID3D11ShaderResourceView > texture
Definition Font11.h:40
std::wstring text
Definition Font11.h:33