Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text property shape-inside not respected #404

Open
TheNextGuy32 opened this issue Dec 12, 2023 · 1 comment
Open

text property shape-inside not respected #404

TheNextGuy32 opened this issue Dec 12, 2023 · 1 comment
Labels

Comments

@TheNextGuy32
Copy link

TheNextGuy32 commented Dec 12, 2023

Problem

My <text> element's shape-inside property is being ignored when I svg2png using cairosvg. https://cairosvg.org/svg_support makes no mention of shape-inside. The shape-inside feature is described here.

What I expected

The text of the At the end of the Round ... Break ties in your favor if... text to wrap before it goes off the card, like so (this is what Inkscape renders and exports):
image

What occurred

The text is not inside the rect and bleeds off the page.
image

Repro:

  • Download the svg file below
  • pip install cairosvg python package
  • Create and run the following python code:
from cairosvg import svg2png

svg2png(
    url="path/to/svg", 
    write_to="path/to/desired/png", 
    dpi=300, 
    output_width=825,
    output_height=1125)

Here is my svg file, you can see that Github/Chrome is observing shape-inside:
assetsCaps-diplomat

You can right click it and download it.

The text element in question is id="text3173" and it shape-inside's rect element id="rect1344". Here's rect 1344 if it was visible:
image

XY Problem Considerations

The svg's are programmatically generated, so I cannot add newlines manually. The text input changes frequently and so the newlines would change frequently. The person responsible for creating the card's rules has no idea the width of the text area and ideally never will have to. I would love to avoid baking newlines that aren't related to emphasis into my card rules.

Currently, I call os.system("inkscape input.svg --export-filename=output.png --export-dpi=300") within my python program in order to render my svgs.

This isn't ideal because this requires my users to have Inkscape installed. I believe an entirely python solution is superior to a python package that requires a separate non-python program. I believe cairosvg may be a good Inkscape replacement if cairo supports text wrapping. So far, svglib and wand have the same issue, but their output has other problems on top of not wrapping text.

@liZe liZe added the feature label Dec 12, 2023
@liZe
Copy link
Member

liZe commented Dec 12, 2023

Hi,

Thanks for the feature request.

CairoSVG doesn’t support much from SVG2, and text wrapping is a complex topic that requires a lot of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants