Hello,
I have some multilingual translated text I want to render in Inkscape and auto-scale to fit inside a box. Sometimes the text will be very long (think German: "der scheudenfrangenbangendunderkaumpfen" or very short (think Chinese: >^|). Ideally, I'd like NOT to have to manually adjust the sizes, but rather to script the whole process and just replace the text inside the SVG and have it all "just work".
Caveat: I suspect this isn't really a text problem, but rather a "auto-scale a group inside a box" problem. I want multiple text border/outline colors, so I have actually have two text elements stacked up with different border colors and border thicknesses to get the effect I want. I suspect that some methods of auto scaling might scale/position those two text boxes differently, whereas I need to scale them as a group to keep them lined up with each other.
How to auto scale a group to stay constrained within a box?
-
- Posts: 3
- Joined: Sun Jul 19, 2015 1:06 am
Re: How to auto scale a group to stay constrained within a b
Hi there,
As far as I know it's not yet possible with the current tools inside inkscape.
Outside?
Only outside reference is the newly implemented symbol feature -apart linked raster images-, though it doesn't have a relative transformation with it /you don't have the option to define it's size by defining a custom viewbox for it.
Guess it won't make it to the features, would mess up the document structure and the rendering a bit?
Theoretically it is possible to code an svg alike, but I have no idea how to do it.
http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute
As far as I know it's not yet possible with the current tools inside inkscape.
Outside?
Only outside reference is the newly implemented symbol feature -apart linked raster images-, though it doesn't have a relative transformation with it /you don't have the option to define it's size by defining a custom viewbox for it.
Guess it won't make it to the features, would mess up the document structure and the rendering a bit?
Theoretically it is possible to code an svg alike, but I have no idea how to do it.
http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute
-
- Posts: 3
- Joined: Sun Jul 19, 2015 1:06 am
Re: How to auto scale a group to stay constrained within a b
Lazur, are you saying there's a way to do it with linked raster images?
Re: How to auto scale a group to stay constrained within a b
No, probably that wouldn't work either. I'm saying you can use a text editor, to link other svg-s outside your document, through a defined viewbox, but inkscape can not render that right.
Or some similar "hacks", superimposing two svg-s on top of each other.
Not sure if two viewboxes can be defined inside one svg, usual workaround is to have one viewbox/viewport and scale the whole document to be displayed right on screen.
If that's a text element, there should be a more straightforward.html
Or some similar "hacks", superimposing two svg-s on top of each other.
Not sure if two viewboxes can be defined inside one svg, usual workaround is to have one viewbox/viewport and scale the whole document to be displayed right on screen.
If that's a text element, there should be a more straightforward.html
Re: How to auto scale a group to stay constrained within a b
I think you'd have to use SVG and either some javascript and/or possibly with CSS3. There is another recent message about having numbers increment in a similar way that you want the text to change, and the box around it automatically fit. Was that here? Or on LP? Looking.....
Could this help? http://wiki.colivre.net/Aurium/InkscapeGenerator You can search the forum. There are some other topics with similar requests, such as viewtopic.php" onclick="readonly();return false;"postlink-local" href="http://www.inkscapeforum.com/viewtopic.php" onclick="readonly();return false;">viewtopic.php?f=5&t=18387&p=68987&hilit=increment#p68987
Could this help? http://wiki.colivre.net/Aurium/InkscapeGenerator You can search the forum. There are some other topics with similar requests, such as viewtopic.php" onclick="readonly();return false;"postlink-local" href="http://www.inkscapeforum.com/viewtopic.php" onclick="readonly();return false;">viewtopic.php?f=5&t=18387&p=68987&hilit=increment#p68987
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
-
- Posts: 3
- Joined: Sun Jul 19, 2015 1:06 am
Re: How to auto scale a group to stay constrained within a b
@brynn, replacing values in the file is the easy part, the difficulty is in scaling text to fill a rectangle.
I eventually got this to work via a multi step process:
1. Create an SVG of just the text element(s).
2. Have my script modify the text elements SVG to insert my localized text (translated into another language).
3. Export it to a raster PNG at a "really high" resolution.
4. Edit my main SVG to include an "<image>" tag that specifies scaling behavior, and pulls in the raster PNG by reference.
5. Tweak the coordinate values until it is properly scaled and centered for a variety of aspect ratios.
6. Now you can script the whole process and have text automatically expand to fill an area while staying proportional to its proper aspect ratio.
Here's the image tag included in my main SVG. The xMidYMid part does the magic, but you do have to tweak width, height, x, and y to establish the bounding box.
<image
sodipodi:absref="C:\somepath\TextOnlyExport.png"
xlink:href="TextOnlyExport.png"
y="254.70929"
x="594.25323"
id="image20293"
preserveAspectRatio="xMidYMid meet"
height="200"
width="500" />
I eventually got this to work via a multi step process:
1. Create an SVG of just the text element(s).
2. Have my script modify the text elements SVG to insert my localized text (translated into another language).
3. Export it to a raster PNG at a "really high" resolution.
4. Edit my main SVG to include an "<image>" tag that specifies scaling behavior, and pulls in the raster PNG by reference.
5. Tweak the coordinate values until it is properly scaled and centered for a variety of aspect ratios.
6. Now you can script the whole process and have text automatically expand to fill an area while staying proportional to its proper aspect ratio.
Here's the image tag included in my main SVG. The xMidYMid part does the magic, but you do have to tweak width, height, x, and y to establish the bounding box.
<image
sodipodi:absref="C:\somepath\TextOnlyExport.png"
xlink:href="TextOnlyExport.png"
y="254.70929"
x="594.25323"
id="image20293"
preserveAspectRatio="xMidYMid meet"
height="200"
width="500" />