简体   繁体   English

base64图像中的嵌入式字体

[英]Embedded font in base64 image

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. 我给了一个带有一些自定义字体的svg(通过css的字体嵌入)在浏览器中运行正常,但是如果我尝试从SVG生成base64编码的图像,则该字体将无法识别。

在此处输入图片说明

Gere are my codes: 基尔是我的代码:

CSS 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 JS im使用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);


    });

You have to embed the stylesheet in the SVG itself, or reference it externally. 您必须将样式表嵌入SVG本身,或从外部引用它。 A general page stylesheet won't be applied if the SVG is rendered on its own. 如果单独呈现SVG,则不会应用常规页面样式表。

Check out the reference on SVG styling for more information. 查阅有关SVG样式的参考以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM