Delphi's drawing function [10]

Source: Internet
Author: User
Tags character set textout

Let's start with an example:procedure TForm1.FormPaint(Sender: TObject);
const
 S = '万一的 Delphi 博客';
var
 font: TFont;
begin
 font := TFont.Create;
 font.Name := '微软雅黑';
 font.Style := [fsBold, fsItalic];
 font.Color := clRed;
 font.Height := 72;
 Canvas.Font := font;
 Canvas.TextOut(10, 10, S);
 font.Free;
end;

Effect Chart:

Because the Font property of the Canvas is an instance of the TFONT class, the above program can be simplified to:Procedure Tform1.formpaint (Sender:tobject);
Const
S = ' In case of Delphi blog ';
Begin
Canvas.Font.Name: = ' Microsoft Ya-hei ';
Canvas.Font.Style: = [Fsbold, fsitalic];
Canvas.Font.Color: = clred;
Canvas.Font.Height: = 72;
Canvas.textout (A, S);
End
Common properties for the TFont class:
{Name: Font name}
{color: Colors}
{size, Height: Font size and font height, you can set the font sizes}
{style: font style; is a collection value, which is the following optional value or a combination of them:}
Fsbold
Fsitalic
Fsunderline
Fsstrikeout
{Pitch: Is word spacing related, there are three enumerated values optional (but I did not test the effect):}
Fpdefault
Fpvariable
Fpfixed
{Charset: Character set, is an integer, the possible values are:}
Ansi_charset = 0;
Default_charset = 1;
Symbol_charset = 2;
Shiftjis_charset = 128;
Hangeul_charset = 129;
Gb2312_charset = 134;
Chinesebig5_charset = 136;
Oem_charset = 255;
Johab_charset = 130;
Hebrew_charset = 177;
Arabic_charset = 178;
Greek_charset = 161;
Turkish_charset = 162;
Vietnamese_charset = 163;
Thai_charset = 222;
Easteurope_charset = 238;
Russian_charset = 204;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.