Recent

Author Topic: [Resolved] adding a font path with gTTFontCache  (Read 5659 times)

Nono Reading Activity

  • Jr. Member
  • **
  • Posts: 56
[Resolved] adding a font path with gTTFontCache
« on: April 14, 2024, 08:02:13 am »
Hello,
while searching in forum, i found that i have to use gTTFontCache.SearchPath.Add in my FormCreate if i want to add a path to my font.

Code: Pascal  [Select][+][-]
  1.        gTTFontCache.SearchPath.Add('D:\FONT');
  2.        //gTTFontCache.SearchPath.Add('D:\FONT\');
  3.        gTTFontCache.BuildFontCache;
  4.        ComboBox1.Items.Assign(Screen.Fonts);  
  5.  

but i can't find Caslon in my combo. what is my mistake ?
« Last Edit: April 17, 2024, 06:02:14 am by Nono Reading Activity »

paweld

  • Hero Member
  • *****
  • Posts: 1295
Re: adding a font path with gTTFontCache
« Reply #1 on: April 14, 2024, 08:37:45 am »
The font cache from the fpttf unit has nothing to do with Screen.Fonts. As you use fpttf, you can read the font list as below:
Code: Pascal  [Select][+][-]
  1. uses
  2.   fppdf;
  3.  
  4. var
  5.   g: TFPFontCacheList;
  6.  
  7. procedure TForm1.FormCreate(Sender: TObject);
  8. var
  9.   i: Integer;
  10. begin
  11.   cbfontname.Items.Clear;
  12.   //load fonts
  13.   g := TFPFontCacheList.Create;
  14.   g.SearchPath.Add('C:\Windows\Fonts');
  15.   g.SearchPath.Add('d:\Font\');
  16.   g.BuildFontCache;
  17.   for i := 0 to g.Count - 1 do
  18.   begin
  19.     if cbfontname.Items.IndexOf(g.Items[i].FamilyName) < 0 then
  20.       cbfontname.Items.Add(g.Items[i].FamilyName);
  21.   end;            end;                                
  22.  
Best regards / Pozdrawiam
paweld

Nono Reading Activity

  • Jr. Member
  • **
  • Posts: 56
Re: adding a font path with gTTFontCache
« Reply #2 on: April 14, 2024, 09:04:50 am »
thanks, i can see it now in the combo, but i misunderstood the use of gttfontcache.
Code: Pascal  [Select][+][-]
  1. TMemo(AContainer.Components[I]).Font.Name := ConstPoliceNom;
it does change the font if ConstPoliceNom = "Arial" or "Courier", but not if ConstPoliceNom = "Caslon Antique"

paweld

  • Hero Member
  • *****
  • Posts: 1295
Re: adding a font path with gTTFontCache
« Reply #3 on: April 14, 2024, 12:38:09 pm »
fpttf you can currently only use when exporting to pdf using fppdf - as far as I know
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018