function EnterPrint(Str:WideString;Left,Top,LineLength,tBetween:integer;FontName:String;FontSize:Integer):boolean;
//Str:要输出的字符、Left:左边距、Top:上边距、LineLength:文字长度、tBetween:行间距、FontName:字体、FontName:字号
var
i,A:integer;
HeaderLen,TextLen,LineHeight,dpix:integer;
tStr,HeaderText,copyText,tEnter:WideString;
begin
i:=0;
A:=0;
LineHeight:=0;
TextLen:=Length(Str);
tEnter:=char(13) + char(10);
tStr:=Str;
while A<=Length(Str)do
begin
inc(i);
inc(A);
CopyText:=copy(tStr,i+1,TextLen);
HeaderText:=copy(tStr,1,i);
HeaderLen:=Printer.Canvas.TextWidth(WIDESTRING(HeaderText));
dpix:=GetDeviceCaps(Printer.Handle,LogPixelsX);
Printer.Canvas.Font.Name:=FontName;
Printer.Canvas.Font.Size:=FontSize;
if ((HeaderLen>Round(LineLength/254*dpix)) or (pos(tEnter,HeaderText)<>0)) then
begin
if (pos(tEnter,HeaderText)<>0) then
HeaderText:=Copy(HeaderText,1,Length(HeaderText)-2);
TTextOut(Left,Top+tBetween*LineHeight,WIDESTRING(HeaderText),FontName,FontSize);
inc(LineHeight);
i:=0;
tStr:=copyText;
end;
end;
TTextOut(Left,Top+tBetween*LineHeight,WIDESTRING(HeaderText),FontName,FontSize);
result:=true;
end;
代码写得不好看!呵呵……乱了一点![
][
]
今天解决英文排版问题![8D]