[Mailman] Kevin Corazza

Over Stock overstock at gmail.com
Fri Oct 6 15:23:59 BST 2006


Name: Kevin R. Corazza

Birthdate: March 10, 1983

Education: Graduated from Columbia College [Chicago] in 2005 with a BA
in Film/Video. Currently enrolled in the MS program for Cosmology at
UIC campus. Projected graduation date: [December, 2010].

Bio: Currently employed by the Rod Blagojevich administration.
Volunteers as a facilitator for the loop chapter of the progressive
group, Democracy For America.


Kevin Corazza wrote:
>
> How can I print, on my form, a text with vertical orientation ?
> Thank you.
>
> Kevin Corazza
> Sierra Informatica
> mailto:kcorazza at sierrasoft.com

Here is some code ot get you started....

Rotating fonts is a straigforward process, so long as the Windows font
mapper
can supply a rotated font based on the font you request. Using a
TrueType font
virturally guarentees success.

Here is an example of creating a font that is rotated 45 degrees:

procedure TForm1.Button1Click(Sender: TObject);
var
lf : TLogFont;
tf : TFont;
begin
with Form1.Canvas do begin
Font.Name := 'Arial';
Font.Size := 24;
tf := TFont.Create;
tf.Assign(Font);
GetObject(tf.Handle, sizeof(lf), @lf);
lf.lfEscapement := 450;
lf.lfOrientation := 450;
tf.Handle := CreateFontIndirect(lf);
Font.Assign(tf);
tf.Free;
TextOut(20, Height div 2, 'Rotated Text!');
end;
end;


Q) How can I reliably rotate a font on a printer?

A) Here is some code that will reliably rotate fonts on any printer
providing the
printer supports rotating fonts, and the font is a TrueType or other
rotatable font.

Example:

procedure TForm1.Button1Click(Sender: TObject);
var
lf : TLogFont;
OldFont : hFont;
NewFont : hFont;
begin
Printer.BeginDoc;
Printer.Canvas.Font.Name := 'Arial';
Printer.Canvas.Font.Size := 24;
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);
Windows.TextOut(Printer.Canvas.Handle,
200, 200, 'Rotated Text!', 13);
SelectObject(Printer.Canvas.Handle, OldFont);
DeleteObject(NewFont);
Printer.EndDoc;
end;


Q) Some printers seems to rotate the portrait orientation to achieve
a landscape page differently than others. This seems to affect
the direction of a rotated font. How can I tell what direction a printer
will rotate output on a landscape page, and if landscape mode is
available on a given printer?

A) The following example demonstrates how to call the Windows API
function DeviceCapabilities(), to find out how a portrait page is
rotated
to achieve a landscape page, enabling you to adjust your output
accordingly.

Example:

uses Printers;

{$IFDEF WIN32}
function DeviceCapabilitiesA(pDevice : PAnsiChar;
pPort : PAnsiChar;
fwCapability : Word;
pOutput : PAnsiChar;
DevMode : PDeviceModeA): Integer; stdcall;
stdcall; external 'winspool.drv' name 'DeviceCapabilitiesA';

function DeviceCapabilitiesW(pDevice : PWideChar;
pPort : PWideChar;
fwCapability: Word;
pOutput: PWideChar;
DevMode: PDeviceModeW): Integer; stdcall;
stdcall; external 'winspool.drv' name 'DeviceCapabilitiesW';

function DeviceCapabilities(pDevice : PChar;
pPort : PChar;
fwCapability : Word;
pOutput : PChar;
DevMode: PDeviceMode): Integer;
stdcall; external 'winspool.drv' name 'DeviceCapabilitiesA';
{$ENDIF}

procedure TForm1.Button1Click(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDMode : THandle;
Rotation : integer;
begin
if PrintDialog1.Execute then begin
{Reset the printer}
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
Rotation :=
DeviceCapabilities(Device,
Port,
DC_ORIENTATION,
nil,
nil);
case Rotation of
0 : ShowMessage('This device does not ' +
'support landscape');
90 : ShowMessage('This device rotates the portrait ' +
'orientation 90 degrees ' +
'to support landscape');
270 : ShowMessage('This device rotates the portrait ' +
'orientation 270 degrees ' +
'to support landscape');
end;
end;
end;



More information about the Mailman mailing list