Mastodon
Programmierung

Fonts: Rotated Fonts

[code lang=”delphi”]//Rotating fonts is a straight forward process, so long as the Windows font
// mapper can supply a rotated font based on the font you request. Using a\
// TrueType font virtually guarantees success.

// Here is an example of creating a font that is rotated to
// whatever degree you specify
Procedure TForm1.DrawRotatedText(TheCanvas : TCanvas; TheAngle : Integer; TheText : String);
var
lf : TLogFont;
tf : TFont;
begin
with TheCanvas do begin
Font.Name := ‘Arial’;
Font.Size := 24;
Brush.Style := bsClear;
tf := TFont.Create;
try
tf.Assign(Font);
GetObject(tf.Handle, sizeof(lf), @lf);
lf.lfEscapement := TheAngle * 10;
lf.lfOrientation := TheAngle * 10;
tf.Handle := CreateFontIndirect(lf);
Font.Assign(tf);
finally
tf.Free;
end;
TextOut(20, Height div 2, TheText);
end;
end;

// Call it like so
procedure TForm1.RotatedTextClick(Sender: TObject);
Var
TheAngle : Integer;
begin
TheAngle := StrToInt(Edit1.Text);
DrawRotatedText(Image2.Canvas, TheAngle, ‘Hello’);
end;
[/code]

[tags]Dephi, Graphic, Fonts[/tags]

0 Kommentare zu “Fonts: Rotated Fonts

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.