在字符打印模式下如何控制字体(100分)

X

xiaoshu

Unregistered / Unconfirmed
GUEST, unregistred user!
在写pos机程序的时候,需要打印,考虑速度问题,用字符打印
但不知如何控制字体?(不能通过Tprinter或Textout之类的函数)

下面是字符打印的程序的一个片断,当然也可以用汇编
的中断编写。

procedure TForm2.BitBtn1Click(Sender: TObject);
var
F: TextFile;
s: String;
begin

s := memo1.text;
AssignFile(F, 'LPT1');
Rewrite(F);
printer.Canvas.Font.Size := 20 ;
Writeln(F,chr(27)+'@');
Writeln(F, s);
//有些打印机要输入换页符才开始打印,此行可以删除
CloseFile(F);
end;





请大虾赐教!
 

printer.Canvas.Font.Assign(Memo1.Font);
 
不能用 printer.Canvas.Font.Assign(Memo1.Font);
这种方法打印,打印一段后会把一张纸走完,我试着改变纸张的大小,也没用.
 
字体的设置与走纸无关吧。
 

用vc中的(DC)或Delphi中的(Tprinter)打印都会出现打印完一行字后,打印机走纸
一页的现象,改变纸张大小也没用,因为打印机好像是按默认纸张大小来走纸。

在NT下用两种方法不会走纸,而且也可以打印“打印机的控制码”,如 ESC @
(writefile函数不能打印控制码)
1.writleln 函数。
2。writeprinter函数.

但是,这用这两种方法打印,却不知如何控制字体的大小,打印的控制码中好像也没有
改变字体大小的控制码。

请赐教,急用!
 
TestInt := PASSTHROUGH;
if Escape(Printer.Handle,
QUERYESCSUPPORT,
sizeof(TestInt),
@TestInt,
nil) > 0 then
begin


{ Start the printout }

Printer.begin
Doc;

{ Make a string to passthrough }
s := ' A Test String ';

{ Copy the string to the buffer }
StrPCopy(Buff.Buffer, s);

{ Set the buffer length }
Buff.BuffLength := StrLen(Buff.Buffer);

{ Make the escape}
Escape(Printer.Canvas.Handle,
PASSTHROUGH,
0,
@Buff,
nil);

{ End the printout }
Printer.EndDoc;
 
接受答案了.
 
顶部