ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  ChartDirector5.1 setSearchPath load font not work
Posted by afu on Sep-02-2021 18:50
Drop the font to "windows/fonts" on win10

$font ='BlackoakStd.otf';
$c->setDefaultFonts($font);

Can work

but

In my project folder, "/lib/font"

$c->setSearchPath('lib/font');
$c->setSearchPath(os.path.dirname('lib/font'));

None of them can work

What should I do to read the font file in the project folder

  Re: ChartDirector5.1 setSearchPath load font not work
Posted by Peter Kwan on Sep-03-2021 00:30
Hi afu,

The setSearchPath is only for loading image files. See:

https://www.advsofteng.com/doc_v51/cdphp.htm#BaseChart.setSearchPath.htm

Font loading has its own search path, which can be modified with the FONTPATH environmental variable. See:

https://www.advsofteng.com/doc_v51/cdphp.htm#fontspec.htm

For your case, instead of using an environmental variable, I suggest you just specify the full font path name, like:

$font ='/path/to/lib/font/BlackoakStd.otf';

Note that the path name is a file system path name. It is not a URL. The leading slash '/' refers to the root of the hard disk, not the root of the web document directory. If it is a relative path (like "lib/font/..."), it is relative to the current working directory, which may not be the current URL directory or the current directory of the script.

To avoid confusion, I suggest to use the full absolute path name. You can include code to detect the full path name of your project, then append "lib/font/BlackoakStd.otf" to the path.

Regards
Peter Kwan