begin
if (Canvas = nil) or (s = '') then
Exit;
TempFont := 0;
SaveFont := nil;
try
if Effect.Angle <> 0 then
begin
SaveFont := TFont.Create;
SaveFont.Assign(Canvas.Font);
GetObject(Canvas.Font.Handle, SizeOf(TLogFont), @LogFont);
LogFont.lfEscapement := Effect.Angle * 10;
TempFont := CreateFontIndirect(LogFont);
Canvas.Font.Handle := TempFont;
end;
if Effect.Shadow.Enabled then //阴影计算
begin
TextPoint := GetTextPoint;
ShadowPoint := GetShadowPoint;
//添加判断描边字参数判断 2010.05.10 WYH
IsBorder := false;
BorderWidth :=0;
if ShadowPoint.y = 20 then
begin
if ShadowPoint.x > 0 then
begin
IsBorder :=true;
BorderWidth :=ShadowPoint.x;
end;
end;
TextPoint.x := TextPoint.x + x;
TextPoint.y := TextPoint.y + y;
ShadowPoint.x := ShadowPoint.x + x;
ShadowPoint.y := ShadowPoint.y + y;
end
else
begin
TextPoint := Point(x, y);
end;
Mask.DrawMask(s); //创建字体蒙板
if Effect.Outline then
Mask.Outline;
if Effect.Spray > 0 then
Mask.Spray(Effect.Spray);
if Effect.HorzMirror then
Mask.HorzMirror;
if Effect.VertMirror then
Mask.VertMirror;
OldBrushStyle := Canvas.Brush.Style;
if Effect.Shadow.Enabled then //阴影处理
begin
ShadowMask := TCnAAMask.Create(Self);
ShadowMask.Assign(Mask); //阴影蒙板
if Effect.Shadow.Blur > 0 then
ShadowMask.Blur(Effect.Shadow.Blur); //阴影模糊
// 判断是否是描边字
if IsBorder then
begin
for i := 0 to BorderWidth do
begin
j := Round( sqrt ( BorderWidth*BorderWidth - i*i ));
Blend.Blend(TextPoint.x + i, TextPoint.y +j, Effect.Shadow.Color,
Effect.Shadow.Alpha * Effect.Alpha div 100, ShadowMask);
Blend.Blend(TextPoint.x + i, TextPoint.y -j, Effect.Shadow.Color,
Effect.Shadow.Alpha * Effect.Alpha div 100, ShadowMask);
Blend.Blend(TextPoint.x - i, TextPoint.y +j, Effect.Shadow.Color,
Effect.Shadow.Alpha * Effect.Alpha div 100, ShadowMask);
Blend.Blend(TextPoint.x - i, TextPoint.y -j, Effect.Shadow.Color,
Effect.Shadow.Alpha * Effect.Alpha div 100, ShadowMask);
end;
end
else
begin
Blend.Blend(ShadowPoint.x, ShadowPoint.y, Effect.Shadow.Color,
Effect.Shadow.Alpha * Effect.Alpha div 100, ShadowMask);
end;
ShadowMask.Free;
Canvas.Brush.Style := bsClear; //透明
end;
if Effect.Blur > 0 then //文本模糊
Mask.Blur(Effect.Blur);
if Effect.Texture.Enabled and Assigned(Effect.Texture.Picture.Graphic) and
not Effect.Texture.Picture.Graphic.Empty then
begin
CreateForeBmp; //创建字体纹理图
if Effect.Noise > 0 then
AddNoise(Effect.Noise);
Blend.BlendEx(TextPoint.x, TextPoint.y, Effect.Alpha, Mask);
end
else if Effect.Gradual.Enabled then
begin //创建渐变色前景图
CreateGradual;
if Effect.Noise > 0 then
AddNoise(Effect.Noise);
Blend.BlendEx(TextPoint.x, TextPoint.y, Effect.Alpha, Mask);
end
else
begin //混合输出
if Effect.Noise > 0 then
begin
CreateNoiseBmp;
Blend.BlendEx(TextPoint.x, TextPoint.y, Effect.Alpha, Mask);
end
else
Blend.Blend(TextPoint.x, TextPoint.y, Canvas.Font.Color, Effect.Alpha, Mask);
end;
if Effect.Shadow.Enabled then
Canvas.Brush.Style := OldBrushStyle;
finally
if Effect.Angle <> 0 then
begin
Canvas.Font.Assign(SaveFont);
SaveFont.Free;
DeleteObject(TempFont);
end;
end;
end;