Recent

Author Topic: LAMW -*.otf font supports?  (Read 1910 times)

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
LAMW -*.otf font supports?
« on: January 31, 2022, 07:17:58 am »
Has anyone tried parsing font with otf extention on LAMW?

Thank you..

This topic about caching otf fonts on lazarus:
https://forum.lazarus.freepascal.org/index.php?topic=33141.0

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: LAMW -*.otf font supports?
« Reply #1 on: January 31, 2022, 02:26:14 pm »
Based on the thread you linked, it should work. Did you try it?

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: LAMW -*.otf font supports?
« Reply #2 on: February 05, 2022, 06:31:27 am »
Already tried but failed  :-\

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: LAMW -*.otf font supports?
« Reply #3 on: February 06, 2022, 04:54:51 am »
I just tried, and it works!

Here is what I did:
1-I put an otf font file in a folder.
      Copied NotoSansAhom-Regular.otf to /storage/emulated/0/Download/FONTS/

2-Adapted the test from the link you have to:
Code: Pascal  [Select][+][-]
  1. procedure Test_OTF(const APath:String);
  2. var
  3.   CacheList : TFPFontCacheList;
  4.   CacheItem : TFPFontCacheItem;
  5.   i: integer;
  6. begin
  7.   try
  8.     CacheList := TFPFontCacheList.Create;
  9.  
  10.     CacheList.SearchPath.Add(APath);
  11.     CacheList.BuildFontCache;
  12.  
  13.     Log('CacheList.Count: '+CacheList.Count.ToString);
  14.     for i := 0 to CacheList.Count-1 do
  15.       Log(CacheList.Items[i].PostScriptName);
  16.  
  17.     CacheItem := CacheList.Find('NotoSansAhom-Regular');
  18.     if CacheItem<>nil then
  19.       Log('CapHeight: '+IntToStr(CacheItem.FontData.CapHeight))
  20.     else
  21.       Log('CacheItem is NIL');
  22.  
  23.   except
  24.     Log('An error occurred...');
  25.     CacheList.Free;
  26.   end;
  27. end;

of course, don't forget to add unit fpTTF to the uses section.
Log is a simple function to add the text to a jEditText
Call Test_OTF with the correct path. Notice the path is case-sensitive.

3-Gave the app storage permission.

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: LAMW -*.otf font supports?
« Reply #4 on: February 12, 2022, 06:05:04 am »
Thank you  :D

 

TinyPortal © 2005-2018