LazReport: Fix the slow filling of font's combobox so it can now be made on designer opening, this fixes no showing the font in the font list when some object is selected and the report is just loaded.

git-svn-id: trunk@63937 -
This commit is contained in:
jesus 2020-09-29 03:55:35 +00:00
parent b6c3d95216
commit ac50e66e44

View File

@ -3313,8 +3313,7 @@ var
begin
s := StrPas(LogFont.elfLogFont.lfFaceName);
Lst := TStrings(PtrInt(Data));
if Lst.IndexOf(S)<0 then
Lst.AddObject(S, TObject(PtrInt(FontType)));
Lst.AddObject(S, TObject(PtrInt(FontType)));
Result := 1;
end;
@ -3372,64 +3371,73 @@ procedure TfrDesignerForm.GetFontList;
var
DC: HDC;
Lf: TLogFont;
SysList: TStringList;
{$IFDEF USE_PRINTER_FONTS}
Lst: TStrings;
PrnList: TStringList;
i: Integer;
j: PtrInt;
{$ENDIF}
begin
C2.Items.Clear;
DC := GetDC(0);
SysList := TStringList.Create;
SysList.Duplicates := dupIgnore;
SysList.Sorted := true;
try
Lf.lfFaceName := '';
Lf.lfCharSet := DEFAULT_CHARSET;
Lf.lfPitchAndFamily := 0;
EnumFontFamiliesEx(DC, @Lf, @EnumFontsProc, PtrInt(C2.Items), 0);
finally
ReleaseDC(0, DC);
end;
{$IFDEF USE_PRINTER_FONTS}
if not CurReport.PrintToDefault then
begin
// we could use prn.Printer.Fonts but we would be tied to
// implementation detail of list.objects[] encoded with fonttype
// that's why we collect the fonts ourselves here
//
Lst := TStringList.Create;
DC := GetDC(0);
try
EnumFontFamiliesEx(Prn.Printer.Canvas.Handle, @Lf, @EnumFontsProc, PtrInt(Lst), 0);
for i:=0 to Lst.Count-1 do
if C2.Items.IndexOf(Lst[i])<0 then begin
j := PtrInt(Lst.Objects[i]) or $100;
C2.Items.AddObject(Lst[i], TObject(j));
end;
Lf.lfFaceName := '';
Lf.lfCharSet := DEFAULT_CHARSET;
Lf.lfPitchAndFamily := 0;
EnumFontFamiliesEx(DC, @Lf, @EnumFontsProc, PtrInt(SysList), 0);
finally
Lst.free;
ReleaseDC(0, DC);
end;
end;
{$ENDIF}
if (SelNum>0) and (FirstSelected is TfrCustomMemoView) then
begin
// font of selected memo has preference, select it
LastFontname := TfrCustomMemoView(FirstSelected).Font.Name;
LastFontSize := TfrCustomMemoView(FirstSelected).Font.Size;
end else
if C2.Items.IndexOf(LastFontName)>=0 then
// last font name remains valid, keep it together with lastFontSize
else begin
// setup an initial font name and size
if C2.Items.Count>0 then
LastFontName := C2.Items[0]
else
LastFontName := '';
if C2.Items.IndexOf('Arial') <> -1 then
LastFontName := 'Arial'
else if C2.Items.IndexOf('helvetica [urw]')<>-1 then
LastFontName := 'helvetica [urw]'
else if C2.Items.IndexOf('Arial Cyr') <> -1 then
LastFontName := 'Arial Cyr';
LastFontSize := 10;
{$IFDEF USE_PRINTER_FONTS}
if not CurReport.PrintToDefault then
begin
PrnList := TStringList.Create;
PrnList.Duplicates := dupIgnore;
PrnList.Sorted := true;
try
// we could use prn.Printer.Fonts but we would be tied to
// implementation detail of list.objects[] encoded with fonttype
// that's why we collect the fonts ourselves here
//
EnumFontFamiliesEx(Prn.Printer.Canvas.Handle, @Lf, @EnumFontsProc, PtrInt(PrnList), 0);
for i:=0 to PrnList.Count-1 do
if SysList.IndexOf(PrnList[i])<0 then begin
j := PtrInt(PrnList.Objects[i]) or $100;
SysList.AddObject(PrnList[i], TObject(PtrInt(j)));
end;
finally
PrnList.Free;
end;
end;
{$ENDIF}
if (SelNum>0) and (FirstSelected is TfrCustomMemoView) then
begin
// font of selected memo has preference, select it
LastFontname := TfrCustomMemoView(FirstSelected).Font.Name;
LastFontSize := TfrCustomMemoView(FirstSelected).Font.Size;
end else
if SysList.IndexOf(LastFontName)>=0 then
// last font name remains valid, keep it together with lastFontSize
else begin
// setup an initial font name and size
if SysList.Count>0 then
LastFontName := SysList[0]
else
LastFontName := '';
if SysList.IndexOf('Arial') <> -1 then
LastFontName := 'Arial'
else if SysList.IndexOf('helvetica [urw]')<>-1 then
LastFontName := 'helvetica [urw]'
else if SysList.IndexOf('Arial Cyr') <> -1 then
LastFontName := 'Arial Cyr';
LastFontSize := 10;
end;
finally
C2.Items.Assign(SysList);
SysList.Free;
end;
end;
@ -3972,8 +3980,9 @@ begin
Busy := True;
DocMode := dmDesigning;
//if C2.Items.Count=0 then
// GetFontList; // defered to speed loading
if C2.Items.Count=0 then
GetFontList;
LastFontSize := 10;
{$IFDEF MSWINDOWS}
LastFontName := 'Arial';