3211:Assuring Proper Font Scaling When Printing
KEYWORDS: scaling, fontsizes, printing, canvas, get device caps AREA: Applicat
When changing printers, be aware that fontsizes may
not always scale properly. To ensure proper scaling,
set the PixelsPerInch property of the font after
changing the printer index property. Be sure not to
make the change until you have started the print job.
Here are two examples:
********************************************************
uses Printers;
var
MyFile: TextFile;
begin
Printer.PrinterIndex := 2;
AssignPrn(MyFile);
Rewrite(MyFile);
Printer.Canvas.Font.Name := 'Courier New';
Printer.Canvas.Font.Style := [fsBold];
Printer.Canvas.Font.PixelsPerInch:=
GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY);
Writeln(MyFile, 'Print this text');
System.CloseFile(MyFile);
end;
******************************************************
uses Printers;
begin
Printer.PrinterIndex := 2;
Printer.BeginDoc;
Printer.Canvas.Font.Name := 'Courier New';
Printer.Canvas.Font.Style := [fsBold];
Printer.Canvas.Font.PixelsPerInch:=
GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY);
Printer.Canvas.Textout(10, 10, 'Print this text');
Printer.EndDoc;
end;
<end of ti>
TI