Selur
29th February 2024, 20:56
I use the following inno setup script: https://pastebin.com/YyibJFk6
Now I want to expand this so that after all the file copying the content of the two files:
{app}\32bit\fonts\local.conf
and
{app}\64bit\fonts\local.conf
which both contain:
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>APPDATA/HybridFonts</dir>
<cachedir>APPDATA/fontconfig/cache</cachedir>
</fontconfig>
get adjusted to:
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>APPDATA/fonts</dir>
<cachedir>APPDATA/fontconfig/cache</cachedir>
</fontconfig>
where APPDATA should be the AddDataFolder of the user (i.e. C:\Users\Selur\AppData\Roaming\.hybrid).
From what I read online extending the Code-section by:
function ReplaceString(const Source, Find, Replace: string): string;
var
PosFind: Integer;
begin
Result := Source;
PosFind := Pos(Find, Result);
while PosFind > 0 do
begin
Delete(Result, PosFind, Length(Find));
Insert(Replace, Result, PosFind);
PosFind := Pos(Find, Result);
end;
end;
function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean;
var
MyFile : TStrings;
MyText : string;
begin
MyFile := TStringList.Create;
try
result := true;
try
MyFile.LoadFromFile(FileName);
MyText := MyFile.Text;
{ Only save if text has been changed. }
if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then
begin;
MyFile.Text := MyText;
MyFile.SaveToFile(FileName);
end;
except
result := false;
end;
finally
MyFile.Free;
end;
end;
function ReplaceLocalConfStrings: Boolean;
var
AppDataPath: string;
LocalConfPath32: string;
LocalConfPath64: string;
begin
Result := True;
// Ersetze %appdata% durch %appdata%/.hybrid
AppDataPath := ExpandConstant('{userappdata}');
AppDataPath := ReplaceString(AppDataPath, '\', '\\');
AppDataPath := ReplaceString(AppDataPath, 'AppData\Roaming', 'AppData\Roaming\\.hybrid');
// Pfade zu den local.conf-Dateien in den entsprechenden Ordnern
LocalConfPath32 := ExpandConstant('{app}\32bit\fonts\local.conf');
LocalConfPath64 := ExpandConstant('{app}\64bit\fonts\local.conf');
// Ersetze die Zeichenfolgen in den Dateien
if not FileReplaceString(LocalConfPath32, '<dir>APPDATA/HybridFonts</dir>', '<dir>' + AppDataPath + '\\.hybrid\\HybridFonts</dir>') then
Result := False;
if not FileReplaceString(LocalConfPath32, '<cachedir>APPDATA/fontconfig/cache</cachedir>', '<cachedir>' + AppDataPath + '\\.hybrid\\fontconfig\\cache</cachedir>') then
Result := False;
if not FileReplaceString(LocalConfPath64, '<dir>APPDATA/fonts</dir>', '<dir>' + AppDataPath + '\\.hybrid\\fonts</dir>') then
Result := False;
if not FileReplaceString(LocalConfPath64, '<cachedir>APPDATA/fontconfig/cache</cachedir>', '<cachedir>' + AppDataPath + '\\.hybrid\\fontconfig\\cache</cachedir>') then
Result := False;
end;
to do what I want, but it doesn't work, after running the installer, the two files are still as they were.
:stupid:
I got no clue how this all works, so any help is appreciated.
Cu Selur
Now I want to expand this so that after all the file copying the content of the two files:
{app}\32bit\fonts\local.conf
and
{app}\64bit\fonts\local.conf
which both contain:
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>APPDATA/HybridFonts</dir>
<cachedir>APPDATA/fontconfig/cache</cachedir>
</fontconfig>
get adjusted to:
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>APPDATA/fonts</dir>
<cachedir>APPDATA/fontconfig/cache</cachedir>
</fontconfig>
where APPDATA should be the AddDataFolder of the user (i.e. C:\Users\Selur\AppData\Roaming\.hybrid).
From what I read online extending the Code-section by:
function ReplaceString(const Source, Find, Replace: string): string;
var
PosFind: Integer;
begin
Result := Source;
PosFind := Pos(Find, Result);
while PosFind > 0 do
begin
Delete(Result, PosFind, Length(Find));
Insert(Replace, Result, PosFind);
PosFind := Pos(Find, Result);
end;
end;
function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean;
var
MyFile : TStrings;
MyText : string;
begin
MyFile := TStringList.Create;
try
result := true;
try
MyFile.LoadFromFile(FileName);
MyText := MyFile.Text;
{ Only save if text has been changed. }
if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then
begin;
MyFile.Text := MyText;
MyFile.SaveToFile(FileName);
end;
except
result := false;
end;
finally
MyFile.Free;
end;
end;
function ReplaceLocalConfStrings: Boolean;
var
AppDataPath: string;
LocalConfPath32: string;
LocalConfPath64: string;
begin
Result := True;
// Ersetze %appdata% durch %appdata%/.hybrid
AppDataPath := ExpandConstant('{userappdata}');
AppDataPath := ReplaceString(AppDataPath, '\', '\\');
AppDataPath := ReplaceString(AppDataPath, 'AppData\Roaming', 'AppData\Roaming\\.hybrid');
// Pfade zu den local.conf-Dateien in den entsprechenden Ordnern
LocalConfPath32 := ExpandConstant('{app}\32bit\fonts\local.conf');
LocalConfPath64 := ExpandConstant('{app}\64bit\fonts\local.conf');
// Ersetze die Zeichenfolgen in den Dateien
if not FileReplaceString(LocalConfPath32, '<dir>APPDATA/HybridFonts</dir>', '<dir>' + AppDataPath + '\\.hybrid\\HybridFonts</dir>') then
Result := False;
if not FileReplaceString(LocalConfPath32, '<cachedir>APPDATA/fontconfig/cache</cachedir>', '<cachedir>' + AppDataPath + '\\.hybrid\\fontconfig\\cache</cachedir>') then
Result := False;
if not FileReplaceString(LocalConfPath64, '<dir>APPDATA/fonts</dir>', '<dir>' + AppDataPath + '\\.hybrid\\fonts</dir>') then
Result := False;
if not FileReplaceString(LocalConfPath64, '<cachedir>APPDATA/fontconfig/cache</cachedir>', '<cachedir>' + AppDataPath + '\\.hybrid\\fontconfig\\cache</cachedir>') then
Result := False;
end;
to do what I want, but it doesn't work, after running the installer, the two files are still as they were.
:stupid:
I got no clue how this all works, so any help is appreciated.
Cu Selur