RSVG Custom Fonts
Posted: 2015-07-20T17:40:17-07:00
In several places about bad ImageMagick SVG output, it was recommended to use RSVG instead. I have compiled ImageMagick and Imagick with RSVG successfully, and it does indeed make everything look much better. My problem is I had a little hack to get Google fonts to work with Imagick that now does not appear to be working. I was:
1) downloading the font from google as a tff, saving it to a file under /tmp.
2) Saving a custom types.xml file like:
3) Updating system cache:
4) Updating Imagick font dir:
This worked great when using Imagick when the renderer was the internal one (XML 2.9 I believe). But now after switching to RSVG it no longer works and it is reverting back to the standard ones. I needed it to be something dynamic like this because I can't edit the system fonts on Heroku. I can't seem to find any decent documentation about RSVG, or anyone else having asked this question before. Do you know how to update RSVG to use custom downloaded fonts similar to this?
1) downloading the font from google as a tff, saving it to a file under /tmp.
2) Saving a custom types.xml file like:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE typemap [
<!ELEMENT typemap (type)+>
<!ELEMENT type (#PCDATA)>
<!ELEMENT include (#PCDATA)>
<!ATTLIST type name CDATA #REQUIRED>
<!ATTLIST type fullname CDATA #IMPLIED>
<!ATTLIST type family CDATA #IMPLIED>
<!ATTLIST type foundry CDATA #IMPLIED>
<!ATTLIST type weight CDATA #IMPLIED>
<!ATTLIST type style CDATA #IMPLIED>
<!ATTLIST type stretch CDATA #IMPLIED>
<!ATTLIST type format CDATA #IMPLIED>
<!ATTLIST type metrics CDATA #IMPLIED>
<!ATTLIST type glyphs CDATA #REQUIRED>
<!ATTLIST type version CDATA #IMPLIED>
<!ATTLIST include file CDATA #REQUIRED>
]>
<typemap>
<type
format="ttf"
name="crafty girls"
fullname="crafty girls"
family="crafty girls"
glyphs="/tmp/crafty girls.ttf"
style="normal"
stretch="normal"
weight="400"/>
</typemap>
Code: Select all
exec('fc-cache -v ' . $this->fontDir);
Code: Select all
putenv('MAGICK_FONT_PATH=' . $this->fontDir);
Code: Select all
$convert --version
Version: ImageMagick 6.8.9-10 Q16 x86_64 2015-07-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pangocairo png rsvg tiff x xml zlib
$convert -list format | grep SVG
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (RSVG 2.40.2)
SVGZ rw+ Compressed Scalable Vector Graphics (RSVG 2.40.2)