Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-08

fpReport -> Lazarus reportdsg.lpr

18 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andreas Frieß

I think there ara som issues with the fonts.

frmreportdesignermain.pp around line 395

   if gTTFontCache.SearchPath.Count=0 then
     begin
     {$IFDEF UNIX}
gTTFontCache.SearchPath.Add(ExtractFilePath(ParamStr(0))+'../demos/fonts/');
     gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/');
gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/ubuntu-font-family/');
gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/dejavu/');
     {$ENDIF}
     end;
   if (gTTFontCache.Count=0) then
     gTTFontCache.BuildFontCache;  //  calls directly to fpTTF

in fpTTF

procedure TFPFontCacheList.BuildFontCache;
var
   lPath: String;
   i: integer;
begin
   if FSearchPath.Count < 1 then
     raise ETTF.Create(rsNoSearchPathDefined);  // here is the exception
raised

I think in windows is no searchpath definded by default. The lines in should: because its also true for windows.

   if gTTFontCache.SearchPath.Count=0 then
     begin
gTTFontCache.SearchPath.Add(ExtractFilePath(ParamStr(0))+'../demos/fonts/');
     gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/');
     {$IFDEF UNIX}
gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/ubuntu-font-family/');
gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/dejavu/');
     {$ENDIF}
     end;

---------------------------------

If i say create a new report, another issue is, the DPI settings in Ruler are not initialised or set. So you get un runtimeerror here

procedure TDrawRuler.RecalcParams;
var I:Integer;
begin
   FPPU:=PixelsPerUnit(DPI,FUnits);    // DPI is zero
   FMajorTicks:=(DPI/FPPU);                  //<- FFPPU is zero ->
divison by zero!
   I:=Trunc(FMajorTicks);
   case I of

Fix:

constructor TDrawRuler.Create(ACanvas: TCanvas);
begin
   FCanvas:=ACanvas;
   FFont:=TFont.Create;
   Color:=clWhite;
   FTickColor:=cldkGray;
   FType:=rtTop;
   FUnits:=ruCm;
   FZeroOffset:=0;
   FDPI:=96;        //<--- should be an basic value
   RecalcParams;
end;

Andreas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170821/b22f3a57/attachment.html>

Reply by email

Michael Van Canneyt
to Andreas Frieß
Andreas Frieß wrote 41 lines
I think there ara som issues with the fonts. frmreportdesignermain.pp around line 395 if gTTFontCache.SearchPath.Count=0 then begin {$IFDEF UNIX} gTTFontCache.SearchPath.Add(ExtractFilePath(ParamStr(0))+'../demos/fonts/'); gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/'); gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/ubuntu-font-family/'); gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/dejavu/'); {$ENDIF} end; if (gTTFontCache.Count=0) then gTTFontCache.BuildFontCache; // calls directly to fpTTF in fpTTF procedure TFPFontCacheList.BuildFontCache; var lPath: String; i: integer; begin if FSearchPath.Count < 1 then raise ETTF.Create(rsNoSearchPathDefined); // here is the exception raised I think in windows is no searchpath definded by default. The lines in should: because its also true for windows. if gTTFontCache.SearchPath.Count=0 then begin gTTFontCache.SearchPath.Add(ExtractFilePath(ParamStr(0))+'../demos/fonts/'); gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/'); {$IFDEF UNIX} gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/ubuntu-font-family/'); gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/dejavu/'); {$ENDIF} end; ---------------------------------

I will '../demos/fonts' and other hardcoded values are maybe not really a good idea :)

Show quoted text 27 lines
If i say create a new report, another issue is, the DPI settings in Ruler are not initialised or set. So you get un runtimeerror here procedure TDrawRuler.RecalcParams; var I:Integer; begin FPPU:=PixelsPerUnit(DPI,FUnits); // DPI is zero FMajorTicks:=(DPI/FPPU); //<- FFPPU is zero -> divison by zero! I:=Trunc(FMajorTicks); case I of Fix: constructor TDrawRuler.Create(ACanvas: TCanvas); begin FCanvas:=ACanvas; FFont:=TFont.Create; Color:=clWhite; FTickColor:=cldkGray; FType:=rtTop; FUnits:=ruCm; FZeroOffset:=0; FDPI:=96; //<--- should be an basic value RecalcParams; end;

VERY strange, I never had this error. I patched the code.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
The '../demos/fonts' and other hardcoded values are maybe not really a good idea:)

For the life of me, I couldn't think of another solution. eg: you might have a headless reporting CGI app and needs to look for fonts in a specific location, not the general "fonts" directories of the system.

But yes, the hard-coded paths like....

    gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/....');

isn't ideal. Especially if you consider the inconsistency between Linux distros, and the fact that FreeBSD uses /usr/local/share/fonts/ instead of /usr/share/fonts/

But again, unless we extend the IFDEFs for most used OSes, I couldn't think of a better solution.

What if we introduce a global (or user-defined)
~/.config/fpreport/fpreport.ini file that specifies default font search paths for our specific reporting needs - per system? But then again, isn't that what the standardised $HOME/.fonts/ is for?

Sorry, just thinking out loudly. ;-)

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 23 lines
On 2017-08-21 09:18, Michael Van Canneyt via Lazarus wrote: > The '../demos/fonts' and other hardcoded values are maybe not really > a good idea:) For the life of me, I couldn't think of another solution. eg: you might have a headless reporting CGI app and needs to look for fonts in a specific location, not the general "fonts" directories of the system. But yes, the hard-coded paths like.... gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/....'); isn't ideal. Especially if you consider the inconsistency between Linux distros, and the fact that FreeBSD uses /usr/local/share/fonts/ instead of /usr/share/fonts/ But again, unless we extend the IFDEFs for most used OSes, I couldn't think of a better solution. What if we introduce a global (or user-defined) ~/.config/fpreport/fpreport.ini file that specifies default font search paths for our specific reporting needs - per system? But then again, isn't that what the standardised $HOME/.fonts/ is for?

These problems will only occur if you're using non-standard fonts.

If you recall, I wanted to analyse /etc/fonts/fonts.conf on unix. (not sure if that is used on FreeBSD)

On windows, normally only the windows fonts dir should be needed.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
These problems will only occur if you're using non-standard fonts.

What if you wanted "self contained reports" eg like the demos in fpReport where we use fonts that are not available on all systems. eg: Windows doesn't come standard with DejaVu. Other Linux distros and FreeBSD doesn't come standard with the Ubuntu font.

If you recall, I wanted to analyse /etc/fonts/fonts.conf on unix. (not sure if that is used on FreeBSD)

Yes, FreeBSD uses that too, but again, it is located in the user-installed apps location... /usr/local/etc/fonts/

Looking at that file here (again, not sure how Linux distro compare or differ), but there are <dir>.... </dir> tags in the beginning of the fonts.conf file. Simply adding those to fpTTF's search path should already go a long way. That should be pretty easy to add.

<!-- Font directory list -->

<dir>/usr/local/share/fonts</dir>
<dir>/usr/local/lib/X11/fonts</dir>
<dir prefix="xdg">fonts</dir>
<!-- the following element will be removed in the future --> <dir>~/.fonts</dir>

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
On 2017-08-21 09:54, Michael Van Canneyt via Lazarus wrote: > These problems will only occur if you're using non-standard fonts. What if you wanted "self contained reports" eg like the demos in fpReport where we use fonts that are not available on all systems. eg: Windows doesn't come standard with DejaVu. Other Linux distros and FreeBSD doesn't come standard with the Ubuntu font.

Then you need to add Location+'fonts/' or so, and distribute the font.

If the font isn't there, you can't use it, clearly :)

An idea would be to have aliases for substitution.

Show quoted text 18 lines
> If you recall, I wanted to analyse /etc/fonts/fonts.conf on unix. > (not sure if that is used on FreeBSD) Yes, FreeBSD uses that too, but again, it is located in the user-installed apps location... /usr/local/etc/fonts/ Looking at that file here (again, not sure how Linux distro compare or differ), but there are <dir>.... </dir> tags in the beginning of the fonts.conf file. Simply adding those to fpTTF's search path should already go a long way. That should be pretty easy to add. <!-- Font directory list --> <dir>/usr/local/share/fonts</dir> <dir>/usr/local/lib/X11/fonts</dir> <dir prefix="xdg">fonts</dir> <!-- the following element will be removed in the future --> <dir>~/.fonts</dir>

Should indeed be easy to parse and handle...

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote 8 lines
> <!-- Font directory list --> > > <dir>/usr/local/share/fonts</dir> > <dir>/usr/local/lib/X11/fonts</dir> > <dir prefix="xdg">fonts</dir> > <!-- the following element will be removed in the future --> > <dir>~/.fonts</dir> Should indeed be easy to parse and handle...

I'll make it so. I guess the best option would be to add it as an option API call, so if somebody wants it, simply call
<fpttf>.AddStandardFontPaths(). For those that don't want those font paths, simply do nothing.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Andreas Frieß
to Graeme Geldenhuys

It is possible to use a standard font and give a warning instead of fire an exception.

Eg. Font xxxx not found, using standardfont instead .... ?

Andreas

Graeme Geldenhuys wrote 18 lines
On 2017-08-21 10:18, Michael Van Canneyt wrote: >> <!-- Font directory list --> >> >> <dir>/usr/local/share/fonts</dir> >> <dir>/usr/local/lib/X11/fonts</dir> >> <dir prefix="xdg">fonts</dir> >> <!-- the following element will be removed in the future --> >> <dir>~/.fonts</dir> > Should indeed be easy to parse and handle... I'll make it so. I guess the best option would be to add it as an option API call, so if somebody wants it, simply call <fpttf>.AddStandardFontPaths(). For those that don't want those font paths, simply do nothing. Regards, Graeme

Reply by email

Michael Van Canneyt
to Andreas Frieß
Andreas Frieß wrote
It is possible to use a standard font and give a warning instead of fire an exception. Eg. Font xxxx not found, using standardfont instead .... ?

That is what I meant with introducing aliases.

The problem is of course that you normally do not want this in a reporting engine, where the looks are important. So using aliases should be an option...

Michael.

Reply by email

Graeme Geldenhuys
to Andreas Frieß: It is possible to use a standard font and give a warning instead of fire an exception.…
Andreas Frieß wrote
It is possible to use a standard font and give a warning instead of fire an exception. Eg. Font xxxx not found, using standardfont instead .... ?

I don't like that. First, how are you going to display the warning? Remember fpReport was designed to be able to run from console or headless servers too, not just desktop apps. Secondly, how are you going to substitute the font? Which font will you choose, and how will you make that choice? Using equivalent font metrics values, simply by name, some random standard font that might make your report look crap? My personal opinion - I like to see a report the way I designed it or not at all (until I fixed what was missing or broken).

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Andreas Frieß
to Graeme Geldenhuys: I don't like that. First, how are you going to display the warning? Remember fpReport was…

At first this should for the visual part (Designer eg.)

And should for windows this not added ? Because in windows the fonts should reside in %windir%\Fonts (see MS documentation)

   function GetWinDirFonts: string;
   var
     dir: array [0..MAX_PATH] of Char;
   begin
     GetWindowsDirectory(dir, MAX_PATH);
     Result :=  StrPas(dir)+DirectorySeparator+'Fonts';
   end;

and

   {$ifdef mswindows}
   SearchPath.Add(GetWinDir);
   SearchPath.Add(GetWinDirFonts);
   {$endif}

in fpttf.pp around line 560

Andreas

Graeme Geldenhuys wrote 18 lines
On 2017-08-21 10:35, Andreas Frieß via Lazarus wrote: > It is possible to use a standard font and give a warning instead of fire > an exception. > > Eg. Font xxxx not found, using standardfont instead .... ? I don't like that. First, how are you going to display the warning? Remember fpReport was designed to be able to run from console or headless servers too, not just desktop apps. Secondly, how are you going to substitute the font? Which font will you choose, and how will you make that choice? Using equivalent font metrics values, simply by name, some random standard font that might make your report look crap? My personal opinion - I like to see a report the way I designed it or not at all (until I fixed what was missing or broken). Regards, Graeme

Reply by email

Sven Barth
to Graeme Geldenhuys: I'll make it so. I guess the best option would be to add it as an option API call, so if…

Am 21.08.2017 11:25 schrieb "Graeme Geldenhuys via Lazarus" <

Show quoted text 16 lines
: On 2017-08-21 10:18, Michael Van Canneyt wrote: >> >> <!-- Font directory list --> >> >> <dir>/usr/local/share/fonts</dir> >> <dir>/usr/local/lib/X11/fonts</dir> >> <dir prefix="xdg">fonts</dir> >> <!-- the following element will be removed in the future --> >> <dir>~/.fonts</dir> > > Should indeed be easy to parse and handle... I'll make it so. I guess the best option would be to add it as an option

API call, so if somebody wants it, simply call
<fpttf>.AddStandardFontPaths(). For those that don't want those font paths, simply do nothing.

Why not dynamically load the fontconfig library and ask that instead of manually parsing its config file?
Note: fontconfig doesn't have GUI dependencies either.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170821/3b99827f/attachment.html>

Reply by email

Michael Van Canneyt
to Sven Barth
Sven Barth wrote 23 lines
Am 21.08.2017 11:25 schrieb "Graeme Geldenhuys via Lazarus" < >: > > On 2017-08-21 10:18, Michael Van Canneyt wrote: >>> >>> <!-- Font directory list --> >>> >>> <dir>/usr/local/share/fonts</dir> >>> <dir>/usr/local/lib/X11/fonts</dir> >>> <dir prefix="xdg">fonts</dir> >>> <!-- the following element will be removed in the future --> >>> <dir>~/.fonts</dir> >> >> Should indeed be easy to parse and handle... > > > I'll make it so. I guess the best option would be to add it as an option API call, so if somebody wants it, simply call <fpttf>.AddStandardFontPaths(). For those that don't want those font paths, simply do nothing. Why not dynamically load the fontconfig library and ask that instead of manually parsing its config file?

Because I didn't know such a library existed :)

Note: fontconfig doesn't have GUI dependencies either.

Well, in that case we can try to load it dynamically if it is available, and fall back to parsing if it is not.

Many thanks for the tip !!

Michael.

Reply by email

Andreas Frieß
to Andreas Frieß: At first this should for the visual part (Designer eg.) And should for windows this not…

Is is not better to call the standard fonts of the system in TFPReportDesignerForm.FormCreate(Sender: TObject); ?

   if gTTFontCache.SearchPath.Count=0 then
     begin
gTTFontCache.SearchPath.Add(ExtractFilePath(ParamStr(0))+'../demos/fonts/');
     gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/');
     {$IFDEF UNIX}
gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/ubuntu-font-family/');
gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/dejavu/');
     {$ENDIF}
     end;
   if (gTTFontCache.Count=0) then
     gTTFontCache.BuildFontCache;
   if (gTTFontCache.Count=0) then                // <-------
     gTTFontCache.ReadStandardFonts;        // <-------

Because the standardfonts are not read in the designer.

Andreas

Andreas Frieß wrote 45 lines
At first this should for the visual part (Designer eg.) And should for windows this not added ? Because in windows the fonts should reside in %windir%\Fonts (see MS documentation) function GetWinDirFonts: string; var dir: array [0..MAX_PATH] of Char; begin GetWindowsDirectory(dir, MAX_PATH); Result := StrPas(dir)+DirectorySeparator+'Fonts'; end; and {$ifdef mswindows} SearchPath.Add(GetWinDir); SearchPath.Add(GetWinDirFonts); {$endif} in fpttf.pp around line 560 Andreas Am 21.08.2017 um 11:49 schrieb Graeme Geldenhuys via Lazarus: > On 2017-08-21 10:35, Andreas Frieß via Lazarus wrote: >> It is possible to use a standard font and give a warning instead of >> fire >> an exception. >> >> Eg. Font xxxx not found, using standardfont instead .... ? > > I don't like that. First, how are you going to display the warning? > Remember fpReport was designed to be able to run from console or > headless servers too, not just desktop apps. Secondly, how are you > going to substitute the font? Which font will you choose, and how > will you make that choice? Using equivalent font metrics values, > simply by name, some random standard font that might make your report > look crap? My personal opinion - I like to see a report the way I > designed it or not at all (until I fixed what was missing or broken). > > Regards, > Graeme >

Reply by email

Michael Van Canneyt
to Andreas Frieß
Andreas Frieß wrote 18 lines
Is is not better to call the standard fonts of the system in TFPReportDesignerForm.FormCreate(Sender: TObject); ? if gTTFontCache.SearchPath.Count=0 then begin gTTFontCache.SearchPath.Add(ExtractFilePath(ParamStr(0))+'../demos/fonts/'); gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/'); {$IFDEF UNIX} gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/ubuntu-font-family/'); gTTFontCache.SearchPath.Add('/usr/share/fonts/truetype/dejavu/'); {$ENDIF} end; if (gTTFontCache.Count=0) then gTTFontCache.BuildFontCache; if (gTTFontCache.Count=0) then // <------- gTTFontCache.ReadStandardFonts; // <------- Because the standardfonts are not read in the designer.

Yes.
A patch for this was already provided by Pascal Riekenberg. It has been applied.

Michael.

Reply by email

Unknown author
to Graeme Geldenhuys: I don't like that. First, how are you going to display the warning? Remember fpReport was…
Graeme Geldenhuys wrote 10 lines
On 2017-08-21 10:35, Andreas Frieß via Lazarus wrote: > It is possible to use a standard font and give a warning instead of fire > an exception. > > Eg. Font xxxx not found, using standardfont instead .... ? I don't like that. First, how are you going to display the warning? Remember fpReport was designed to be able to run from console or headless servers too, not just desktop apps. Secondly, how are you going to substitute the font? Which font will you choose

you choose Comic Sans, of course :wink: :wink:

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.*

Reply by email

Sven Barth
to Michael Van Canneyt: Because I didn't know such a library existed :) Well, in that case we can try to load it…
"Michael Van Canneyt" wrote 29 lines
On Mon, 21 Aug 2017, Sven Barth via Lazarus wrote: > Am 21.08.2017 11:25 schrieb "Graeme Geldenhuys via Lazarus" < > >: >> >> >> On 2017-08-21 10:18, Michael Van Canneyt wrote: >>>> >>>> >>>> <!-- Font directory list --> >>>> >>>> <dir>/usr/local/share/fonts</dir> >>>> <dir>/usr/local/lib/X11/fonts</dir> >>>> <dir prefix="xdg">fonts</dir> >>>> <!-- the following element will be removed in the future --> >>>> <dir>~/.fonts</dir> >>> >>> >>> Should indeed be easy to parse and handle... >> >> >> >> I'll make it so. I guess the best option would be to add it as an option > > API call, so if somebody wants it, simply call > <fpttf>.AddStandardFontPaths(). For those that don't want those font

paths,

Show quoted text 8 lines
> simply do nothing. > > Why not dynamically load the fontconfig library and ask that instead of > manually parsing its config file? Because I didn't know such a library existed :)

Ah, in that case: fontconfig is the default library to deal with font configuration on the Open Source *nix systems (Linux, FreeBSD, etc.).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170821/9fb9dc96/attachment-0001.html>

Reply by email