//輸出文本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;