fastreport 自动缩小字体以填充

遇到一个新需求当FastReport的Memo框中的文字大于Memo的长度,则自动缩小字体来适应Memo的宽度。找了多种办法,最终选择直接改FastReport的源码一劳永逸。

要修改frxClass单元源码,步骤如下:

1、增加字体调整模式

TfrxScaleFontSize = (sfsWidth, sfsHeight, sfsNone);

2、为TfrxMemoView添加一个属性ScaleFontSize

property ScaleFontSize;

3、为TfrxCustomMemoView增加FScaleFontSize和ScaleFontSize属性

FScaleFontSize:TfrxScaleFontSize;

property ScaleFontSize: TfrxScaleFontSize read FScaleFontSize write FScaleFontSize default sfsNone;

4、修改TfrxCustomMemoView.BeforePrint过程代码如下:

procedure TfrxCustomMemoView.BeforePrint;

begin

inherited;

if not IsDataField then

FTempMemo := FMemo.Text;

case FScaleFontSize of

sfsNone: ;

sfsWidth:

if not WordWrap and not AutoWidth then //按宽度调整时--自动换行时不可用 ; 自动宽度时不可用

while (CalcWidth - Width > 0) do

Font.Size := Font.Size - 1;

sfsHeight:

if (StretchMode = smDontStretch) then //伸展时不能按高度调整

while ((CalcHeight - LineSpacing) - Height > 0) do

Font.Size := Font.Size - 1;

end;

end;

最终效果图如下:


展开阅读全文

页面更新:2024-03-07

标签:字体   效果图   宽度   源码   长度   单元   属性   步骤   多种   高度

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号

Top