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

textLength attribute not handled #345

Open
MattiWheels opened this issue May 20, 2022 · 3 comments
Open

textLength attribute not handled #345

MattiWheels opened this issue May 20, 2022 · 3 comments

Comments

@MattiWheels
Copy link

No errors are thrown but the expected output is not produced.

SVG Document:

<svg version="1.1" id="Design5" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" 
	 viewBox="0 0 600 100" style="enable-background:new 0 0 600 100;" xml:space="preserve">
	<defs>
		<style type="text/css">
			.line1 {
				font-size:120px;
				font-family:"Helvetica";
				fill: #33ffaa;
			}
		</style>
	</defs>
	<text textLength='440' lengthAdjust="spacing" transform="matrix(1 0 0 1 0 90)" class="line1">
		SomeText
	</text>
</svg>

SVG Appearance:
image

Using code based on the documentation:

from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
logo = svg2rlg(svg_file)
renderPM.drawToFile(logo, png_file, fmt='PNG')

Produces this result:
image

Note: The grey background shown in the SVG appearance is just the preview area in VS Code and is not a part of the design. Also, sorry for the cursor appearing in the screenshot.

@github-actions
Copy link

Thank you for raising your first issue! Your help to improve svglib is much appreciated!

@claudep claudep changed the title Attributes ignored when converting to PNG textLength attribute not handled May 20, 2022
@claudep
Copy link
Collaborator

claudep commented May 20, 2022

Confirmed, svglib does not consider the textLength attribute.

reportlab String shape does only support a limited set of attributes. Not sure if svglib could implement that or if we should simply document the limitation.

@MattiWheels
Copy link
Author

@claudep Thanks for your response on this issue. I am finding that Python and JS libraries don't support the use of certain properties like textLength, lengthAdjust, and some transforms. I'm sure there are more unsupported properties, but these are the ones that I am having troubles with.

The solution I have found is to use ExtendScript and make these adjustments using Illustrator actions / automation. I'm hoping to find a replacement, since Python or JS can outpace ExtendScript by a longshot (I'm hoping to generate over 150k images for a database with this technique).

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

No branches or pull requests

2 participants