简体   繁体   English

Fabric JS解析器的SVG文本对齐问题

[英]SVG text alignment issues with Fabric JS parser

I am loading an SVG using the following 我正在使用以下方法加载SVG

fabric.loadSVGFromURL

however when loaded into the canvas the text in the SVG is pushed up rather than be vertically aligned as set when producing the SVG. 但是,当将其加载到画布中时,SVG中的文本将被向上推,而不是像生成SVG时所设置的那样垂直对齐。

The svg code is as follows: svg代码如下:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  <svg version="1.1"
 id="Layer_1" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg"
 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="62.8 -28.2 502.6 480"
 enable-background="new 62.8 -28.2 502.6 480" xml:space="preserve">
    <g id="Layer-border">
        <path id="border" fill="#363F5B" d="M62.8-28.2v480h502.6v-480H62.8L62.8-28.2z"/>
    </g>
    <g id="Layer-main">
        <rect id="main" x="72" y="-19.2" fill="#BF4D9C" width="484.9" height="463.1"/>
    </g>
    <g id="Layer-text">
        <text transform="matrix(1 0 0 1 79.5781 339.4394)" fill="#FFFFFF" font-family="'ApexLake-Regular'" font-size="427.7094">K</text>
    </g>
 </svg>

Link to result in browser: https://db.tt/A2VCCfhm 链接到浏览器中的结果: https : //db.tt/A2VCCfhm

Link to result when loaded to canvas: https://db.tt/RqNeO3Ku 加载到画布时链接到结果: https : //db.tt/RqNeO3Ku

i don't know if you are @rocknpivot on github. 我不知道你是否在github上是@rocknpivot。 Just for the records with the latest version of FabricJs, this alignment issue has been solved. 仅针对FabricJs最新版本的记录,此对齐问题已解决。 It was a misalignment of 1/4 of font size corrected 5 November 2014. Anyway in the question you posted, user can see a beautyfull "K" letter rendered with a particular font. 这是2014年11月5日纠正的1/4字体大小的不对齐。无论如何,在您发布的问题中,用户都可以看到使用特定字体呈现的beautyfull“ K”字母。 The font is not present in the SVG you posted, so this svg will never render as in your screenshot. 该字体在您发布的SVG中不存在,因此该svg将永远不会像您的屏幕截图中那样呈现。

link: http://jsfiddle.net/asturur/vwq7h766/4/ link: http link: //jsfiddle.net/asturur/vwq7h766/4/

Here is a more working example anyway. 无论如何,这是一个更有效的示例。 You see a slightly left offset error, but i think something is changed in the font since the creation of the fiddle, i have no more the original files i cannot reproduce it. 您会看到一个稍微偏左的偏移错误,但是自从创建小提琴以来,我认为字体发生了一些变化,我没有更多的原始文件,无法重现。

Here a screenshot of the working fiddle 这是工作提琴的屏幕截图

https://cloud.githubusercontent.com/assets/1194048/4953012/586b3af8-667b-11e4-93ff-9542f5d61b3d.png https://cloud.githubusercontent.com/assets/1194048/4953012/586b3af8-667b-11e4-93ff-9542f5d61b3d.png

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

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