JPgraph font error

僤鯓⒐⒋嵵緔 提交于 2021-01-28 15:01:54

问题


I am using 000webhost.com and trying to draw a graph, but I get this error, JpGraph Error: 25049 Font file "../src/font/verdanab.ttf" is not readable or does not exist. I downloaded all the fonts and uploaded on my host, but I still get this error, probably my root is wrong. I really need help.


回答1:


In case you still need help or someone else finds this useful...

  1. Your host probably has some ttf fonts already, so you should start by finding their path. In my case it was something like /usr/share/fonts/dejavu. Look around, it should be easy to find the one you're looking for. If you can't find or don't want to use your host fonts, you can install new ones. Jpgraph has constants for the most popular packages.

  2. Once you identify the right path, go to file jpg-config.inc.php in your source directory and change the line that defines the ttf dir to the path you found in step 1:

    define('TTF_DIR','/usr/share/fonts/dejavu/');
    

    Note the last '/', make sure you don't forget that.

  3. Now you have to know how to refer to your fonts in the code, e.g. FF_DV_SERIF for the deja vu serif font. Go to file jpgraph_ttf.inc.php. There you'll find the constants for each package. The code is well documented so you should have no problem.

Cheers.

Edit: For MacOS10 (with e.g. MAMP) it might be something like:

define('TTF_DIR','/Library/Fonts/');
define('MBTTF_DIR','/Library/Fonts/');


来源:https://stackoverflow.com/questions/11107113/jpgraph-font-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!