• 使用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
  • 相关阅读:
    ComparatorUtil 防止空指针异常
    Java resource 读取解释,绝对路径和相对路径
    List -> Map 工具类,list转为map
    Idea debugger 无法启动-unable to open debugger port , java.net.SocketException "socket closed"
    js处理ajax返回的json数组
    ubuntu安装chkconfig.deb系统服务管理工具
    Ubuntu18.04更新源
    IDEA通过Git同步代码到Coding
    解决ERR Client sent AUTH, but no password is set
    PyCharm快捷键
  • 原文地址:https://www.cnblogs.com/maweiwei/p/10081208.html
Copyright © 2020-2023  润新知