Page 1 of 1

Garbled rendering of TppDBRichview

Posted: Wed Apr 28, 2021 5:02 pm
by msimmons15
I am using TRichview 19, Delphi XE3, Firebird 3 and Report builder 20.04

Please see the attached images. Any idea why this is happening?

Thanks,
Mike Simmons

Re: Garbled rendering of TppDBRichview

Posted: Wed Apr 28, 2021 5:27 pm
by Sergey Tkachenko
Can you create a simple project where I can reproduce the problem?

Re: Garbled rendering of TppDBRichview

Posted: Thu Apr 29, 2021 6:37 pm
by msimmons15
I've attached a zipped sample project which includes a small Firebird 3 DB. This is a Delphi 10.4 project using Firebird 3 and ReportBuilder 20.04.

When you open up the project you will need to adjust the Database location in FDConnection1.
You may need to adjust the VendorLib property in FDPhysFBDriverLink1
To test;
1. Set FDConnection1 to Connected
2. Set FDQuery1 to Active
3. Double click ppReport1 to bring up the designer. From there, switch between the Design and Preview windows to see the issue.

Thanks,
Mike

Re: Garbled rendering of TppDBRichview

Posted: Wed May 05, 2021 4:46 pm
by Sergey Tkachenko
This text has font size = 0. When this font is applied to a canvas, results may be different.

(
I have a guess why this font size may appear.
A very old code of ActionTest demo used rvActionFontEx.Font.Size to implement a font size combobox.
In newer version of RichViewActions, rvActionFontEx.Font.Size must not be used, rvActionFontEx.FontSizeDouble must be used instead. Also, a font size combobox now works automatically, but some users continued to use that code fragment, resulting zero font size in documents.
In the newest version of RichViewActions, both rvActionFontEx.Font.Size and rvActionFontEx.FontSizeDouble can be used, but this fix came too late.
)

I can suggest a workaround for such documents.
Open RVStyle.pas, find procedure TCustomRVFontInfo.Apply.
At the beginning of this procedure, add

Code: Select all

  if SizeDouble <= 0 then
    SizeDouble := 20;
So 10pt will be used instead of zero font size.

Re: Garbled rendering of TppDBRichview

Posted: Thu May 06, 2021 8:17 pm
by msimmons15
The code changes you suggested did fix the error. Thanks!

The font size combobox (first created many years ago) does not even use actions. Here is the code just so you know what was used.
procedure TElementEditor.cmbFontSizeChange(Sender: TObject);
begin
if RVE = nil
then Exit;
if UpdatingCombos then
exit;
try
FontSize := StrToInt(cmbFontSize.Text);
with rvActionFontEx1 do begin
UserInterface := False;
ValidProperties := [rvfimSize];
Font.Size := FontSize;
Execute;
UserInterface := True;
end;
except
Beep;
end;
RVE.SetFocus;
end;


I will spend some time to convert over to use the latest actions.

Is there a way I could load each BLOB field, locate any text having a 0 size font, and then adjust to a non-zero size and re-save. Is there any sample code of how this mighty be done?

Re: Garbled rendering of TppDBRichview

Posted: Sat May 08, 2021 2:21 pm
by Sergey Tkachenko
In the new version of RichViewActions, this event can be removed.
Use TRVFontSizeComboBox.
Assign its properties:
RVFontSizeComboBox1.ActionFont = rvActionFontEx1;
RVFontSizeComboBox1.Editor = RichViewEdit;
And it will do all the work automatically.
The same is for font names, use TRVFontComboBox without assigning events.

As for adjusting all font sizes after loading.
Let you have DBRichViewEdit1: TDBRichViewEdit linked to a dataset Table1 (of TFDQuery or TFDTable type).
Use the code like this.

Code: Select all

  Table1.First;
  while not Table1.Eof do
  begin
    if DBRichViewEdit1.CanChange then
    begin
      for i := 0 to DBRichViewEdit1.Style.TextStyles.Count - 1 do
        if DBRichViewEdit1.Style.TextStyles[i].Size = 0 then
          DBRichViewEdit1.Style.TextStyles[i].Size = 10;
      DBRichViewEdit1.Change;
      Table1.Post;
    end;
    Table1.Next;
  end;

Re: Garbled rendering of TppDBRichview

Posted: Tue May 11, 2021 2:13 pm
by msimmons15
Thank you Sergey!