hans-t
hans-t

Reputation: 3233

svgexport renders font properly on Mac OS X (10.10.3) but not on Ubuntu 14.04

<svg version="1.1" id="Layer_1" 
  xml:space="preserve"
  xmlns="http://www.w3.org/2000/svg" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  x="0px" y="0px" width="600px" height="600px" viewbox="0 0 600 600">
<style type="text/css" >
    <![CDATA[

      @font-face {
        font-family: uGillSansLocal;
        src: local('Gill Sans');
      }

      @font-face {
        font-family: uGillSansURL;
        src: url('./GillSans.ttf');
      }

    ]]>
</style>
<rect id="Border" x="0" y="0" stroke="#000000" fill="#FFFFFF" width="600" height="600"/>
<text x="100" y="30" font-size="32px" font-family="uGillSansLocal">
    <tspan>uGillSans local</tspan>
    <tspan x="100" dy="40">qwertyuiop[]\asdfghjkl;'</tspan>
    <tspan x="100" dy="40">zxcvbnm,./QWERTYUIOP[]|</tspan>
    <tspan x="100" dy="40">ASDFGHJKL:"ZXCVBNM&lt;>?</tspan>
    <tspan x="100" dy="40">1234567890-=!@#$%^&amp;s*()_+</tspan>
</text>
<text x="100" y="300" font-size="32px" font-family="uGillSansURL">
    <tspan>uGillSans url</tspan>
    <tspan x="100" dy="40">qwertyuiop[]\asdfghjkl;'</tspan>
    <tspan x="100" dy="40">zxcvbnm,./QWERTYUIOP[]|</tspan>
    <tspan x="100" dy="40">ASDFGHJKL:"ZXCVBNM&lt;>?</tspan>
    <tspan x="100" dy="40">1234567890-=!@#$%^&amp;s*()_+</tspan>
</text>
</svg>

This is an SVG file. In ubuntu the rendering looks like this: rendering in ubuntu. Some characters are rendered wrongly.

However in Mac OS X the rendering like this: rendering in mac os x. I used svgexport to render both.

From what I understand, svgexport uses PhantomJS to render SVG. I suspect this is not a problem in PhantomJS, but rather some missing library for font rasterization in Ubuntu.

FYI, Both systems have already the required font installed. Both have latest version of svgexport. How should I go about fixing this? Thanks.

Edit: I've installed libfreetype6 and fontconfig on Ubuntu. Still doesn't work. However, the SVG looks okay on Chrome on both systems.

Upvotes: 0

Views: 217

Answers (1)

RedRoosterMobile
RedRoosterMobile

Reputation: 786

for me it works like that:

@font-face {
          font-family:'FreeSans';
          src: url('http://localhost/fonts/FreeSans.ttf') format('truetype');
        }

Notice that there's a format attached. Maybe it's that?

Upvotes: 1

Related Questions