ultimatepp/uppdev/Glyph/FDrawText.cpp
cxl a505beca6d .uppdev: FDraw
git-svn-id: svn://ultimatepp.org/upp/trunk@6065 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2013-05-13 11:52:48 +00:00

39 lines
821 B
C++

#include "glyph.h"
struct sMakeGlyph : public ImageMaker
{
int chr;
Font font;
int angle;
Color color;
virtual String Key() const {
StringBuffer h;
RawCat(h, chr);
RawCat(h, font);
RawCat(h, angle);
RawCat(h, color);
return h;
}
virtual Image Make() const {
RTIMING("Render glyph");
return RenderGlyph(font, chr, color, angle);
}
};
void FDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx)
{
sMakeGlyph g;
g.font = font;
g.color = ink;
g.angle = angle; // TODO!
for(int i = 0; i < n; i++) {
g.chr = text[i];
RTIMING("Paint glyph");
Image m = MakeImage(g);
Point h = m.GetHotSpot();
SysDrawImageOp(x - h.x, y - h.y, m, m.GetSize(), Null);
x += dx ? *dx++ : font[g.chr];
}
}