32 using namespace ystdex;
36 using namespace Drawing;
46 ClipChar(
const Graphics& g,
const Point& pen,
const CharBitmap& cbmp, Rect r)
48 YAssert(
bool(g),
"Invalid graphics context found.");
50 const auto pt(
ClipBounds(r, Rect(pen.X + cbmp.GetLeft(),
51 pen.Y - cbmp.GetTop(), cbmp.GetWidth(), cbmp.GetHeight())));
57 template<
typename _tCharRenderer, _tCharRenderer& _fCharRenderer,
60 RenderCharFrom(
ucs4_t c,
const Graphics& g,
61 TextState& ts,
const Rect& clip, _tParams&&... args)
63 const auto cbmp(ts.Font.GetGlyph(c));
72 if(
const auto cbuf = cbmp.GetBuffer())
74 auto&& pc(ClipChar(g, ts.Pen, cbmp, clip));
76 if(!pc.ClipArea.IsUnstrictlyEmpty())
77 _fCharRenderer(std::move(pc), ts.Color, cbuf,
78 {cbmp.GetWidth(), cbmp.GetHeight()},
yforward(args)...);
80 ts.Pen.X += cbmp.GetXAdvance();
89 RenderCharFrom<decltype(RenderChar), RenderChar>(c, GetContext(),
96 const auto& g(GetContext());
97 const auto h(g.GetHeight());
101 if(n == 0 || l + n >
h)
108 TextRegion::TextRegion()
117 RenderCharFrom<decltype(RenderCharAlpha), RenderCharAlpha>(c,
140 const u32 t((l + n > g.GetHeight() ? g.GetHeight() - l : n)
190 const String& str,
bool line_wrap)
192 TextRenderer tr(ts, g, mask);
201 const String& str,
const Padding& m,
Color c,
bool line_wrap,
205 const Rect txt_bounds(bounds + m);
208 ts.ResetPen(bounds.GetPoint(), m);
214 DrawText(
const Graphics& g, TextState& ts,
const String& str,
bool line_wrap)
219 DrawText(
const Graphics& g,
const Rect& bounds,
const String& str,
220 const Padding& m,
Color c,
bool line_wrap,
const Font& fnt)
222 DrawClippedText(g, Rect(g.GetSize()), bounds, str, m, c, line_wrap, fnt);
226 const String& str,
bool line_wrap)
232 BlitTo(g.GetBufferPtr(), tr, g.GetSize(),
Point(), pt, s);