Recent

Author Topic: (SOLVED) Font style in exported PDF  (Read 2845 times)

vertnik

  • New Member
  • *
  • Posts: 31
(SOLVED) Font style in exported PDF
« on: June 12, 2019, 01:05:12 pm »
Hi!

In report designer, I am using some Memos with bold font style.
When I export the report into PDF with lrFclPDFExport, the text
is not bold.
Is there any solution for this problem?

Thanks
« Last Edit: June 17, 2019, 09:13:41 am by vertnik »

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: Font style in exported PDF
« Reply #1 on: June 12, 2019, 09:07:19 pm »
I use TfrTNPDFExport and don't have this issue.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

vertnik

  • New Member
  • *
  • Posts: 31
Re: Font style in exported PDF
« Reply #2 on: June 17, 2019, 09:12:36 am »
Hi!

I found the problem in file lr_e_fclpdf.pas, in the following function TExportFonts.AddItem(AFontName: string; AFontStyle: TFontStyles ): TExportFontItem
in the line
Result.FPdfFont:=FOwner.FPDFDocument.AddFont(S2, S3);
where S3 is font name.
AddFont function is defined in fpPDF unit. This function first checks, if the font with S3 (font name) value already
exists in the font list. If we already add normal font with the same as the bold one, AddFont function will not
add the bold one.

I change the function TExportFonts.AddItem to
Code: Pascal  [Select][+][-]
  1. function TExportFonts.AddItem(AFontName: string; AFontStyle: TFontStyles
  2.   ): TExportFontItem;
  3. var
  4.   S1, S2, S3: String;
  5.   ext: string; // added by me
  6. begin
  7.   Result:=FindItem(AFontName, AFontStyle);
  8.   if Assigned(Result) then exit;
  9.  
  10.   if Assigned(gTTFontCache.Find(AFontName, Graphics.fsBold in AFontStyle, Graphics.fsItalic in AFontStyle)) then
  11.   begin
  12.     Result:=TExportFontItem.Create(Self, AFontName, AFontStyle);
  13.     S1:=ExtractFileDir(Result.FTTFFontInfo.FileName);
  14.     S2:=ExtractFileName(Result.FTTFFontInfo.FileName);
  15.     S3:=AFontName;
  16.  
  17.     // added - start
  18.     ext:='';
  19.     if (Graphics.fsBold in AFontStyle) then
  20.       ext:=ext+'b';
  21.     if (Graphics.fsItalic in AFontStyle) then
  22.       ext:=ext+'i';
  23.     S3:=S3+ext;
  24.     // added - end
  25.  
  26.     FOwner.FPDFDocument.FontDirectory:=S1;
  27.     Result.FPdfFont:=FOwner.FPDFDocument.AddFont(S2, S3);
  28.   end
  29.   else
  30.     Result:=FDefaultFontNormal;
  31. end;
  32.  

And now, it works.

by

Robert

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: (SOLVED) Font style in exported PDF
« Reply #3 on: June 17, 2019, 09:51:31 pm »
Hi @vertnik may you submit a patch o report this bug?
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

 

TinyPortal © 2005-2018