Has anybody been successful with rotating a font on the printer using
Delphi 2?
The approaches which worked well under Delphi 1 (Creating a logical
font with escapement setting) do NOT work under Delphi 2, because when
Printer.Canvas.Font.Handle is a assigend the handle which was created
by using CreateFontIndirect it switches to some standard setting.
An example:
{///////////////////////////////////////////////}
program Project1;
uses
Forms, graphics, Windows, Printers;
{$R *.RES}
procedure MyRotatePrint (CV: TCanvas; sText: String; X, Y, Angle:
integer);
var LogFont : TLogFont;
begin
GetObject(CV.Font.Handle, SizeOf(TLogFont), @LogFont);
LogFont.lfEscapement := Angle*10;
CV.Font.Handle := CreateFontIndirect(LogFont);
CV.TextOut(X, Y, sText);
end;
var Printer : TPrinter;
begin
Printer := TPrinter.Create;
Printer.BeginDoc;
Printer.Canvas.Font.Name := 'Arial';
Printer.Canvas.Font.Size := 20;
MyRotatePrint(Printer.Canvas, 'Test', 1300, 1300, 450);
Printer.EndDoc;
Printer.Free;
end.
{///////////////////////////////////////////////}
This does NOT result into printing of "Test" in 45 degrees angle in 20
point, but in a simple horizontal 12 point line.
Does anyone know of an approach, that works reliably under Delphi 2?
Best Regards,
N. Hartkamp
----
Adress:
Dr.N.Hartkamp
Klinik fuer Psychotherapie der Universitaet
P.O.Box 12 05 10
40605 Duesseldorf
Phone: ++49-211-922-4722
FAX: ++49-211-922-4707
e-Mail:hart...@uni-duesseldorf.de (office)
MBX: N-HAR...@NADESHDA.GUN.DE (private)
>Has anybody been successful with rotating a font on the printer using
>Delphi 2?
>
>
When I rotated a font on Delphi 1 (I know it works OK for you) I read
somewhere that lfOrientation should be set the same as lfEscapement for
unknown reasons, although in another context ii,ve read that lfOrientation
is ignored by Windows.
Worth a try anyway
Alan Lloyd
alang...@aol.com
>Hello:
>
>Has anybody been successful with rotating a font on the printer using
>Delphi 2?
[...]
Hello:
at first: Thanks to everyone who offered help wirth my problem.
The solution came from xav...@xap.cnchost.com (Xavier Pacheco (TeamB))
in the borland.public.delphi.winapi News-Group and was based on some
code of Joe C. Hecht from Borland.
------------------- Cut -----------------------
program Project1;
uses
graphics,
WinDows,
Printers;
var
lf : TLogFont;
OldFont : hFont;
NewFont : hFont;
s : string;
begin
Printer.BeginDoc;
Printer.Canvas.Font.Name := 'Arial';
Printer.Canvas.Font.Size := 24;
Printer.Canvas.textout( 100, 100, 'This is normal Text' );
Printer.Canvas.Font.PixelsPerInch:=
GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY);
GetObject(Printer.Canvas.Font.Handle, sizeof(lf), @lf);
lf.lfEscapement := 450;
lf.lfOrientation := 450;
{Check here that lf is properly filled out!}
NewFont := CreateFontIndirect(lf);
OldFont := SelectObject(Printer.Canvas.Handle, NewFont);
s := 'This is rotated Text';
Windows.TextOut(Printer.Canvas.Handle,
100, 1500, PChar(s), Length(s));
SelectObject(Printer.Canvas.Handle, OldFont);
DeleteObject(NewFont);
Printer.EndDoc;
end.
------------------- Cut -----------------------
As I understand it, the point is to (1.) use the font to obtain a
valid Pribter.Canvas.Handle, and then NOT to use Delphi's
TextOut-function but the Windows32.API.TextOut-function.
I hope this soulution is helpful to others too.
Thanks, but I am no longer "officially" with Borland.
Joe
--
Joe C. Hecht
joeh...@gte.net
http://home1.gte.net/joehecht/index.htm