svg 中的文本没有环绕在框内

svg 中的文本没有环绕在框内

我正在尝试在 Latex 中包含如下所示的下垂图像。

\begin{figure}[H]
  \centering
  \includesvg[inkscapelatex=false, width=0.7\pdfpagewidth]{figure.svg}
\end{figure}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"...>
 <path d="M 610 300 L 610 363.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" />
        <path d="M 610 368.88 L 606.5 361.88 L 610 363.63 L 613.5 361.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" />
        <path d="M 690 235 L 880 235 L 880 363.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke" />
        <path d="M 880 368.88 L 876.5 361.88 L 880 363.63 L 883.5 361.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all" />
        <path d="M 610 170 L 690 235 L 610 300 L 530 235 Z" fill="#ffffff" stroke="#000000" stroke-miterlimit="10" pointer-events="all" />
        <g transform="translate(-0.5 -0.5)">
            <switch>
                <foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
                    <div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 400px; height: 1px; padding-top: 235px; margin-left: 531px;">
                        <div style="box-sizing: border-box; font-size: 0; text-align: center; ">
                            <div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
                                <span style="color: rgb(26 , 26 , 26) ; font-family: &quot;opensans&quot; , &quot;arial&quot; , sans-serif , &quot;noto sans hebrew&quot; , &quot;noto sans&quot; , &quot;noto sans jp&quot; , &quot;noto sans kr&quot; ; background-color: rgba(255 , 255 , 255 , 0.01)">
                                    <font style="font-size: 12px">This is a very long text that should be wrapped inside the box.</font>
                                </span>
                            </div>
                        </div>
                    </div>
                </foreignObject>
                <text x="610" y="239" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">This is a very long te.../text>
            </switch>
        </g>
</svg>

我遇到的问题是图片中的文字被截断了。有什么方法可以解决这个问题吗?如能提供任何帮助,我将不胜感激。

在此处输入图片描述

答案1

换行的文本位于 SVG 文件的这一部分:

<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
    <div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 400px; height: 1px; padding-top: 235px; margin-left: 531px;">
        <div style="box-sizing: border-box; font-size: 0; text-align: center; ">
            <div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
                <span style="color: rgb(26 , 26 , 26) ; font-family: &quot;opensans&quot; , &quot;arial&quot; , sans-serif , &quot;noto sans hebrew&quot; , &quot;noto sans&quot; , &quot;noto sans jp&quot; , &quot;noto sans kr&quot; ; background-color: rgba(255 , 255 , 255 , 0.01)">
                    <font style="font-size: 12px">This is a very long text that should be wrapped inside the box.</font>
                </span>
            </div>
        </div>
    </div>
</foreignObject>

正如其名称所示,“foreignObject” 不是 SVG 对象。因此,无法被inkscape需要转换为 PDF 的 SVG 对象识别。

因此,您要么必须以与 Inkscape 兼容的方式进行包装(例如,自行包装inkscape),要么应该在绘图程序中以 PDF 格式导出图像。

相关内容