Re: Rotated text
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 18 Nov 2006 10:26:37 -0800
On Nov 18, 4:30 pm, "Tom de Neef" <tden...@xxxxxxxx> wrote:
Currently I use the procedure below to output text at an angle on a canvas.
Several source on the internet approach it in this way. But I must say: the
quality of the result is pretty poor. Are there better ways to do this ?
Thank you,
Tom
procedure AngleTextOut(ACanvas: TCanvas; Angle, X, Y: Integer; Str: string);
var
LogRec: TLogFont;
OldFontHandle,NewFontHandle: hFont;
begin
GetObject(ACanvas.Font.Handle, SizeOf(LogRec), Addr(LogRec));
LogRec.lfEscapement := Angle*10;
NewFontHandle := CreateFontIndirect(LogRec);
OldFontHandle := SelectObject(ACanvas.Handle, NewFontHandle);
ACanvas.TextOut(X, Y, Str);
NewFontHandle := SelectObject(ACanvas.Handle, OldFontHandle);
DeleteObject(NewFontHandle);
end;
In what way is the "quality poor" ?
I use a similar code with good quality faces but the origin of narrow
characters seems misplaced. I start with an existing font in AFont, and
a canvas ACanvas.
var
LogFont : TLogFont;
FontAngleD := FontAngleR * DegPerRad; // in deg
{make a font of this angle}
with LogFont do begin
FillChar(LogFont, sizeof(TLogFont), 0); {clear memory}
lfHeight := AFont.Height;
lfEscapement := trunc(FontAngleD * 10);
lfOrientation := lfEscapement; // should be same
lfWeight := FW_BOLD;
lfOutPrecision := OUT_TT_PRECIS;
lfFaceName := 'Arial';
ACanvas.Font.Handle := CreateFontIndirect(LogFont);
end; {with LogFont}
Alan Lloyd
.
- Follow-Ups:
- Re: Rotated text
- From: Tom de Neef
- Re: Rotated text
- References:
- Rotated text
- From: Tom de Neef
- Rotated text
- Prev by Date: Re: Rotated text
- Next by Date: Re: Access violation for TWebBrowser: fixes didn't work at all
- Previous by thread: Re: Rotated text
- Next by thread: Re: Rotated text
- Index(es):
Relevant Pages
|