0

i gave an svg with some custom fonts (embedded via css's font-face) In the browser it works fine, but if i try to make a base64 encoded image from the SVG, the font wont be recognise.

enter image description here

Gere are my codes:

CSS

    svg,text, textPath{
    font-family: 'MyFont';  
    }

@font-face
{
    font-family: MyFont;
    src: src: url(data:application/x-font-ttf;base64,AAEAAAAQA...);
}

JS im using RaphaelJS

//set the text's font
t.attr({"font-family": "MyFont"})

//make the snapshot
    var source = new Image();
    $("body").append(source);
    $('body').click(function(){

        // record start time
        var startTime = new Date();

        var svg = $('#paper').html();

        var mySrc = 'data:image/svg+xml;base64,'+Base64.encode(svg);

        //source.src = base64Path + "?" + mySrc.slice(5);
        source.src = mySrc;

        var endTime = new Date();

        console.log(endTime - startTime);


    });
4

1 回答 1

1

您必须将样式表嵌入 SVG 本身,或在外部引用它。如果 SVG 单独呈现,则不会应用一般页面样式表。

查看有关 SVG 样式的参考以获取更多信息。

于 2013-10-18T15:39:50.817 回答