2

私の Ubuntu 14.04 ラップトップには、GraphicsMagick と PHP 拡張機能 (GMagick) がインストールされています。コマンドラインから以下を実行すると、

gm convert -font /usr/share/fonts/truetype/google-fonts/RockSalt.ttf svg_file.svg jpeg_file.jpg

必要に応じて、フォントを使用して JPEG をレンダリングします。ただし、このPHPコード

$gm = new Gmagick();
$draw = new GmagickDraw();
$draw->setfont("/usr/share/fonts/truetype/google-fonts/RockSalt.ttf");
$gm->readImageBlob($svg);
$gm->setImageFormat("jpeg");
$gm->drawimage($draw);
$gm->writeImage($jpgFile);
$gm->clear();

同じことができず、デフォルトのフォントで JPEG を作成します。ここで何が問題になる可能性がありますか?

これは SVG です。

<?xml version="1.0"?><svg xmlns="http://www.w3.org/2000/svg"    xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="737" height="521"><defs/> <g class="main">  <title>Main</title>  <rect fill="#ffffff" stroke-width="0" x="27.24188" y="429.44421" width="682.51626" height="68.18413" id="svg_2" class="element" opacity="0.75" stroke="#000000"/>  <g text-anchor="start" font-family="Rock Salt" fill="#000" font-size="20" class="element textarea" id="svg_3">   <rect opacity="0"  stroke-width="0" x="27.24188" y="429.44421" width="682.51626" height="68.18413" id="svg_4"/>   <g class="textGroup">    <text class="eol" y="470.98331" x="44.46314" xml:space="preserve">Your&#xA0;memories&#xA0;will&#xA0;last&#xA0;forever</text>   </g>  </g> </g></svg>
4

1 に答える 1

0

フォントが読み込まれるように、GraphicMagick の type.mkg ファイルを編集する必要があります。 https://sourceforge.net/p/graphicsmagick/discussion/250738/thread/5c00e815/

必要な形式の例を次に示します: https://github.com/CliffsDover/graphicsmagick/blob/master/config/type-windows.mgk.in

<?xml version="1.0"?>
<typemap>
  <type
    name="Arial"
    fullname="Arial"
    family="Arial"
    weight="400"
    style="normal"
    stretch="normal"
    glyphs="@windows_font_dir@arial.ttf"
    />
  <type
    name="Arial-Black"
    fullname="Arial Black"
    family="Arial"
    weight="900"
    style="normal"
    stretch="normal"
    glyphs="@windows_font_dir@ariblk.ttf"
    />
  <type
    name="Arial-Bold"
    fullname="Arial Bold"
    family="Arial"
    weight="700"
    style="normal"
    stretch="normal"
    glyphs="@windows_font_dir@arialbd.ttf"
    />
于 2015-12-11T04:02:22.593 に答える