//输出文本var
g: TGPGraphics;
sb: TGPSolidBrush;
fontFamily: TGPFontFamily;
font: TGPFont;
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(MakeColor(0,0,255));
fontFamily := TGPFontFamily.Create('宋体');
font := TGPFont.Create(fontFamily, 48, FontStyleRegular, UnitPixel);
{参数 3 参考: 文本样式类型表; 参数 4 参考: 坐标单位类型表}
g.DrawString('Hello World!', -1, font, MakePoint(10.0,10.0), sb);
{参数 2 是输出文本的长度, -1 表示全部输出;
参数 4 中的坐标不能用整数, 因为函数指定类型是: TGPRectF}
sb.Free;
fontFamily.Free;
font.Free;
g.Free;
end;
//简单输出文本var
g: TGPGraphics;
sb: TGPSolidBrush;
font: TGPFont;
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(MakeColor(255,0,0));
font := TGPFont.Create('宋体',32.0);
g.DrawString('再见, 2007!', -1, font, MakePoint(10.0,10.0), sb);
sb.Free;
font.Free;
g.Free;
end;
//使用窗体字体属性输出文本var
g: TGPGraphics;
sb: TGPSolidBrush;
font: TGPFont;
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(MakeColor(255,0,0));
font := TGPFont.Create(Self.Canvas.Handle); //根据窗体的字体属性建立
g.DrawString('再见, 2007!', -1, font, MakePoint(10.0,10.0), sb);
sb.Free;
font.Free;
g.Free;
end;
//文本呈现质量var
g : TGPGraphics;
FontFamily: TGPFontFamily;
Font: TGPFont;
sb: TGPSolidBrush;
begin
g := TGPGraphics.Create(Canvas.Handle);
FontFamily := TGPFontFamily.Create('Times New Roman');
Font := TGPFont.Create(FontFamily, 32, FontStyleRegular, UnitPixel);
sb := TGPSolidBrush.Create(MakeColor(255, 0, 0, 255));
g.SetTextRenderingHint(TextRenderingHintSingleBitPerPixel);
g.DrawString('SingleBitPerPixel', -1, font, MakePoint(10.0, 10.0), sb);
g.SetTextRenderingHint(TextRenderingHintAntiAlias);
g.DrawString('AntiAlias', -1, font, MakePoint(10.0, 60.0), sb);
g.Free;
FontFamily.Free;
Font.Free;
sb.Free;
end;