Skip to content

[fpttf] Windows - fpttf read unwanted (system) subdirs

Original Reporter info from Mantis: af0815 @afriess
  • Reporter name: Andi Friess

Description:

fpTTF read in windows unwated systempath, because it have an recursion in the code. A lot of system directories also searched for font. It waste a lot of time and some of the files are not accessible by default.

See in the attached file FPTTF.txt

The recusion should be deactable by a property, so you can inhibit this unwanted searching.

Steps to reproduce:

Start the following programm:

program TTFWintest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  windows,
  fpTTF

  { you can add units after this };

function GetWinDir: string;
  var
    dir: array [0..MAX_PATH] of Char;
  begin
    GetWindowsDirectory(dir, MAX_PATH);
    Result := StrPas(dir);
  end;

var
  i: Integer;
begin
  writeln('ReadStandardFonts');
  gTTFontCache.ReadStandardFonts;
  writeln('Searchpath');
  for i:= 0 to gTTFontCache.SearchPath.Count-1 do begin
    writeln(gTTFontCache.SearchPath.Strings[i]);
  end;
  writeln('------------------');
  writeln('Windir:'+GetWinDir);
  for i:= 0 to gTTFontCache.Count-1 do begin
    try
      writeln(TFPFontCacheItem(gTTFontCache.Items[i]).HumanFriendlyName +'...'+ TFPFontCacheItem(gTTFontCache.Items[i]).FileName);
    except
      writeln('ERROR in...'+ TFPFontCacheItem(gTTFontCache.Items[i]).FileName)
    end;
  end;
end.

Additional information:

This is a great waste of time for fpreport at startup if you must build the fontchache.

Mantis conversion info:

  • Mantis ID: 32495
  • OS: Win10 / 64 Pro
  • OS Build: Win10 / 64 Pro
  • Build: 37366
  • Platform: Dell XPS
  • Version: 3.1.1
  • Fixed in version: 3.1.1
  • Fixed in revision: 37626 (#04738ff2)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information