根據字型實現控制項分行

來源:互聯網
上載者:User

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; 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.