mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.uppdev
git-svn-id: svn://ultimatepp.org/upp/trunk@6082 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
df4447469c
commit
f8e6676775
4 changed files with 34 additions and 20 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#include "glyph.h"
|
||||
|
||||
#define LTIMING(x) // RTIMING(x)
|
||||
|
||||
struct sMakeGlyph : public ImageMaker
|
||||
{
|
||||
int chr;
|
||||
|
|
@ -17,8 +19,10 @@ struct sMakeGlyph : public ImageMaker
|
|||
}
|
||||
|
||||
virtual Image Make() const {
|
||||
RTIMING("Render glyph");
|
||||
return RenderGlyph(font, chr, color, angle);
|
||||
LTIMING("Render glyph");
|
||||
Point at(font[chr], font.GetLineHeight());
|
||||
int n = 2 * (at.x + at.y);
|
||||
return AutoCrop(RenderGlyph(at, angle, chr, font, color, Size(n, n)), RGBAZero());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -27,18 +31,18 @@ void FDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Co
|
|||
sMakeGlyph g;
|
||||
g.font = font;
|
||||
g.color = ink;
|
||||
g.angle = angle; // TODO!
|
||||
g.angle = angle;
|
||||
for(int i = 0; i < n; i++) {
|
||||
g.chr = text[i];
|
||||
RTIMING("Paint glyph");
|
||||
LTIMING("Paint glyph");
|
||||
if(font.GetHeight() > 200) {
|
||||
Size sz(font[g.chr], font.GetLineHeight());
|
||||
int w = 2 * (sz.cx + sz.cy);
|
||||
Size bandsz(w, 32);
|
||||
for(int yy = 0; yy < w; yy += bandsz.cy) {
|
||||
Image m = RenderGlyph(font, g.chr, ink, angle, bandsz, Point(0, -yy));
|
||||
if(yy & 1)
|
||||
SysDrawImageOp(x - (sz.cx + sz.cy), y + yy - (sz.cx + sz.cy), m, m.GetSize(), Null);
|
||||
Point at(font[g.chr], font.GetLineHeight());
|
||||
int n = at.x + at.y;
|
||||
Size bandsz(2 * n, 32);
|
||||
for(int yy = 0; yy < n; yy += bandsz.cy) {
|
||||
Image m = RenderGlyph(Point(0, -yy), angle, g.chr, font, ink, bandsz);
|
||||
DDUMP(m.GetSize());
|
||||
SysDrawImageOp(x, y + yy, m, m.GetSize(), Null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -43,16 +43,17 @@ Image RenderGlyph(Font fnt, int chr, Color color, int angle)
|
|||
return AutoCrop(ib, RGBAZero());
|
||||
}
|
||||
|
||||
Image RenderGlyph(Font fnt, int chr, Color color, int angle, Size sz, Point offset)
|
||||
Image RenderGlyph(Point at, int angle, int chr, Font fnt, Color color, Size sz)
|
||||
{
|
||||
int cx = fnt[chr];
|
||||
int cy = fnt.GetLineHeight();
|
||||
ImageBuffer ib(sz);
|
||||
BufferPainter sw(ib, MODE_ANTIALIASED);
|
||||
sw.Offset(offset);
|
||||
BufferPainter sw(ib);
|
||||
sw.Clear(RGBAZero());
|
||||
sw.DrawText(cx + cy, cx + cy, angle, WString(chr, 1), fnt, color);
|
||||
ib.SetHotSpot(Point(cx + cy, cx + cy));
|
||||
sw.DrawText(at.x, at.y, angle, WString(chr, 1), fnt, color);
|
||||
ib.SetHotSpot(at);
|
||||
for(RGBA *s = ib; s < ib.End(); s++)
|
||||
s->a = (s->a & 0xf8);
|
||||
return ib;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ using namespace Upp;
|
|||
|
||||
|
||||
Image AutoCrop(const Image& m, RGBA c);
|
||||
Image RenderGlyph(Font fnt, int chr, Color color, int angle);
|
||||
|
||||
Image RenderGlyph(Font fnt, int chr, Color color, int angle, Size sz, Point offset);
|
||||
Image RenderGlyph(Point at, int angle, int chr, Font fnt, Color color, Size sz);
|
||||
|
||||
String CompressGlyph(const Image& m);
|
||||
Image DecompressGlyph(const String& g, Color c);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,18 @@ void MyApp::Paint(Draw& w)
|
|||
fw.draw = &w;
|
||||
fw.Init(sz);
|
||||
|
||||
fw.DrawText(0, 0, "Ahoj!", Roman(400));
|
||||
fw.DrawText(100, 100, "Ahoj!", Roman(400));
|
||||
|
||||
|
||||
RichText txt = ParseQTF(LoadFile(GetDataFile("text.qtf")));
|
||||
if(0) {
|
||||
RTIMING("SDraw");
|
||||
txt.Paint(Zoom(2, 10), fw, 0, 0, sz.cx);
|
||||
}
|
||||
if(0) {
|
||||
RTIMING("Draw");
|
||||
txt.Paint(Zoom(2, 10), w, 0, 0, sz.cx);
|
||||
}
|
||||
/*
|
||||
fw.cloff.Add();
|
||||
fw.cloff.Top().offset = Point(0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue