Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SVG文本到PNG无法使用php和imagemagick呈现字体_Php_Svg_Imagemagick_Png - Fatal编程技术网

SVG文本到PNG无法使用php和imagemagick呈现字体

SVG文本到PNG无法使用php和imagemagick呈现字体,php,svg,imagemagick,png,Php,Svg,Imagemagick,Png,当我尝试使用PHP imagemagick将此svg转换为png时,它仅以默认字体呈现文本 在转换为png时,有没有办法使用相同的google字体来呈现文本 任何帮助都将不胜感激。提前谢谢 带有错误字体的SVG文件正常,但使用imagemagick渲染失败。 我的svg代码是: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type='text/css' href='svg-sty

当我尝试使用PHP imagemagick将此svg转换为png时,它仅以默认字体呈现文本

在转换为png时,有没有办法使用相同的google字体来呈现文本

任何帮助都将不胜感激。提前谢谢

带有错误字体的SVG文件正常,但使用imagemagick渲染失败。 我的svg代码是:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type='text/css' href='svg-stylesheet.css' ?>
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="250" height="100" version="1.1"><text xml:space="preserve" style="font-size:30px;text-shadow: 1px 1px 1px #CCCCCC;-moz-text-shadow:1px 1px 1px #CCCCCC;-webkit-text-shadow:1px 1px 1px #CCCCCC; fill:#999; font-family:Sickness" x="30" y="70" class="test">
<tspan>Sample TEXT</tspan>
</text>
</svg>
我的svg文件在这里

svg结果

带有imagemagick的png结果


对于配置的type.xml之外的自定义字体,您需要更新
$MAGICK\u font\u PATH
环境以包含字体所在的路径。或者只需将字体文件复制到您执行的工作目录。然后,只需定义Imagemagick要使用的
-font
(如果不是自动拾取的话)

//具有环境路径的示例
exec('MAGICK_FONT_PATH=/PATH/to/sick convert-FONT-sick 4.svg-transparent white-quality 100-alpha on 4.png');
//ttf在同一目录中的示例
exec('convert-font.ttf 4.svg-transparent white-quality 100-alpha on 4.png');
其他提示和提示


您好,亲爱的,谢谢,但我需要使用阿拉伯语字体,imagemagick有问题,例如,我的示例文本是,您的命令是否显示了结果图像?请写字体的示例路径,第2行不适合我
exec('convert -verbose 4.svg -transparent white -quality 100 -alpha on 4.png');