# cd /root/Desktop # cp msyh.ttf msyhbd.ttf /usr/share/fonts/win/
4. 建立字型索引資訊,更新字型緩衝:
代碼如下:
# cd /usr/share/fonts/win # mkfontscale (如果提示 mkfontscale: command not found,需自行安裝 # yum install mkfontscale ) # mkfontdir # fc-cache (如果提示 fc-cache: command not found,則需要安裝# yum install fontconfig )
至此,字型已經安裝完畢!
<?php if (isset($_GET['url'])) { set_time_limit(0); $url = trim($_GET['url']); $filePath = md5($url).'.png'; if (is_file($filePath)) { exit($filePath); } //如果不加這句就會報錯“Fatal: [Errno 2] No such file or directory; did you install phantomjs?”,詳情參考http://mengkang.net/87.html putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs"); $command = "phantomjs phantomjs.js {$url} {$filePath}"; @exec($command); exit($filePath); } ?> 快照產生
var page = require('webpage').create(); var args = require('system').args; var url = args[1]; var filename = args[2]; page.open(url, function () { page.render(filename); phantom.exit(); });