打印字体的问题(100分)

Y

yxshi

Unregistered / Unconfirmed
GUEST, unregistred user!
我用Printer.Canvas打印,
SetMapMode设置打印机为0.1mm为单位后
for i:=1 to 10
设Printer.Canvas.fon.size:=i;
发现Printer.canvas.font.height总是不变,我想打印两行,由于不知道
打印字体的高度,而无法换行
哪位大虾帮我解决100
 
PRINTER打印是在canvas上画出打印内容,不是DOS下那样换行的。
 
可以使用:
drawtext(printer.canvas.handle, pchar(some text with LF), -1, ARect, DT_EXTERNALLEADING or DT_WORDBREAK);
代替textout, textout只能打一行文字. drawtext可以自动换行(如果不希望在不是#13#10
的地方换行可以设置ARect的宽度以容纳最长行).

与其你自己计算字体高度, 还不如交给windows完成.
 
Another_yes
drawtext(printer.canvas.handle, pchar(some text with LF),
-1, ARect, DT_EXTERNALLEADING or DT_WORDBREAK);
的函数中some text with LF是什么意思,
另外,我设了映射方式是mm为单位的,ARect如何设置(已知x1,y1,x2,y2),
xy都是mm为单位。
能不能具体一点,分数嘛。。。。
 
some text with LF 就是带有换行符的字符串。

 
width: round(mm /25.4 -> inch*GetDeviceCaps(Printer.canvas.handle, LOGPIXELSX)) -> pixels
height: round(mm/25.4 -> inch*GetDeviceCaps(Printer.canvas.handle, LOGPIXELSY)) -> pixels
 
多谢Another_Eyes
 
顶部