How to change style font programmatically ?

edited 11:54AM in FastReport VCL 5
I try to change the font (embedded) in a pdf report depending on the language it contains.
So I assigned styles to memos that are translated and modify the styles font this way:
procedure DoReport(LReportData:TReportData);
var
  LStyle : TfrxStyleItem;
  i:integer;
begin
  with FFastReport do begin
    frxPDFExport.FileName:= LReportData.FDestFile;
    ReportTranslate.Language:= LReportData.FLanguage;
    with frxreport do begin
      LoadFromFile(LReportData.FSrcReport, True); 

      if LReportData.FLanguage='jp' then begin
        for i:=0 to Styles.Count-1 do begin
          LStyle := Styles[i];
          LStyle.Font.Name:='SimSun';
        end;
        // something needed to update styles ?
      end;

      if not PrepareReport(True) then raise Exception.Create('report generation failed');
      if not Export(frxPDFExport) then raise Exception.Create('pdf export failed');
    end;
  end;
end;

however, the .pdf still uses Arial (the font of the styles for other languages)

What should I do to re-apply the style after changing the font ?

Leave a Comment