哈哈,很有意思的一个问题。这里给你两个小技巧,一个可以输出空心字体,另外一个在你的Form上用你的字体开透明的窟窿。
1。输出空心字体:
procedure TForm1.Button1Click(Sender: TObject);
begin
Canvas.Font.Name := 'Times New Roman'; //这里的字体一定要是TrueType Font
Canvas.Font.size := 72;
Canvas.Font.style := [fsItalic,fsBold];
beginpath(canvas.handle); //开始捕获 Canvas上绘制的轮廓
SetBkMode( Canvas.Handle, TRANSPARENT );
canvas.TextOut(20,40,'Hello');
endpath(canvas.handle); //结束捕获
Canvas.Pen.Color := clred;
StrokePath(canvas.handle); //将捕获的轮廓用当前的Pen画到Canvas上
end;
2。用字体开透明窟窿:
procedure TForm1.Button1Click(Sender: TObject);
begin
canvas.Font.Name := 'Times New Roman';
canvas.Font.size := 72;
canvas.Font.style := [fsItalic,fsBold];
beginpath(canvas.handle);
SetBkMode(Canvas.Handle, TRANSPARENT ); //试验一下不用这行语句,会得到很有意思的结果
canvas.Polygon([Point(0,0),Point(Width,0),
Point(Width,Height),Point(0,Height),
Point(0,0)]); //试验不用该语句看看结果如何
canvas.TextOut(20,40,'Hello');
endpath(canvas.handle);
SetWindowRgn( Handle, PathToRegion(canvas.Handle), true );
end;