使用FastReport报表时,如何根据字体实现控件分行?

使用FastReport报表时,如何根据字体实现控件分行?

来源:   发布时间:2016-08-08   浏览:1917次

使用FastReport报表时,根据字体实现控件分行,代码如下:

function HeightOfByte(var Font:TFont):Extended;
var
  con:Extended; 
  num:Integer; 
begin
  if Font.Size >=3 then
  begin 
    num:=(Font.Size-1) div 10; 
    Result:=6.0743+1.32284*(Font.Size-3)+num*0.0945; 
  end 
  else 
  begin 
    if Font.Size=2 then 
    begin 
      Result:=5.7969; 
    end 
    else 
    begin 
      Result:=3.3071; 
    end; 
  end; 
end;
function WidthOfByte(var Font:TFont):Extended;
var
  con:Extended; 
  num:Integer; 
begin
  num:=0; 
  if Font.Size >=2 then
    num:=(Font.Size-2) div 6 + 1; 
  Result:=0.0378+0.65252*Font.Size+num*0.1512; 
  if Font.Style <<fsBold> then
    Result:=Result+0.0756; 
end;
function GetLength(var Font:TFont;Width:Extended):Integer;
var
  BW:Extended; 
begin
  BW:=WidthOfByte(Font); 
  Result:=0; 
  while Result*BW <Width do
  begin 
    Result:=Result+1; 
  end; 
end;
procedure DisposeString(var pString:String;pLen:Integer;WS:TWideStrings);
var
  Data,CurData:String; 
  varXX:Variant; 
  Len,Len_Y:Integer; 
  BW:Extended; 
begin
  WS.Clear(); 
  Data:=pString; 
  varXX.bstrVal:=Data; 
  Len:=Length(varXX); 
  while pLen <Len do
  begin 
    Len_Y:=1; 
    while Len_Y <pLen do
    begin 
      if Ord(Data[Len_Y]) >127 then
        Len_Y:=Len_Y+1; 
      Len_Y:=Len_Y+1; 
    end; 
    CurData:=Copy(Data,1,Len_Y); 
    WS.Add(CurData); 
    Data:=Copy(Data,Len_Y+1,Len-Len_Y); 
    Len:=Len-Len_Y; 
  end; 
  WS.Add(Data); 
end;

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [http://www.fastreportcn.com/]
本文地址:http://www.fastreportcn.com/post/1176.html
posted @ 2018-12-07 09:48  绿水青山777  阅读(249)  评论(0编辑  收藏  举报