Code Monkey home page Code Monkey logo

Comments (2)

jcoliz avatar jcoliz commented on September 24, 2024

One theory is that PowerPoint doesn't keep style attributes on tags within the SVG file.

Here is an example tag from the source file:

    <text
       xml:space="preserve"
       style="font-size:6.35px;font-family:'Segoe UI';-inkscape-font-specification:'Segoe UI';text-align:center;letter-spacing:0px;text-anchor:middle;fill:#ffffff;stroke:#ff0000;stroke-width:0"
       x="43.506058"
       y="40.64146"
       id="text1"><tspan
         sodipodi:role="line"
         id="tspan1"
         style="font-size:6.35px;fill:#ffffff;stroke-width:0"
         x="43.506058"
         y="40.64146">1x1</tspan></text>

When adding this to a presentation manually using the client app, the SVG is altered to this:

        <text id="text1" stroke="#FF0000" stroke-width="0" fill="#FFFFFF" font-family="Segoe UI"
            font-size="6.35" text-anchor="middle" xml:space="preserve" x="43.5061" y="40.6415">
            <tspan font-size="6.35" x="43.5061" y="40.6415">1x1</tspan>
        </text>

Thus, the relevant components of the style attribute are brought out into their own attributes.

SVG library has a FlushStyles method, which might be helpful.

In the meantime, just commit your text to paths before you add SVGs with text.

from shapecrawler.

jcoliz avatar jcoliz commented on September 24, 2024

Ah, the problem is that there is a bug in the SVG library's Write() method. It incorrectly renders a text element thusly:

    <text x="43.50606" y="40.64146" letter-spacing="0px" id="text1" xml:space="preserve" stroke-width="0" text-anchor="middle" font-family="&quot;Segoe UI&quot;" font-size="6.35px" style="-inkscape-font-specification:&quot;Segoe UI&quot;;text-align:center;fill:white;stroke:red;">
      <tspan x="43.50606" y="40.64146" id="tspan1" stroke-width="0" font-size="6.35px" sodipodi:role="line">1x1</tspan>
    </text>

That's wrong because everything inside the tag should be rendered, INCLUDING the white space.

Solution is to not ask the Svg library to write the stream back out. Instead, use user-supplied stream.

from shapecrawler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.