I am using stroke-dasharrays inside line tags in my SVG file for my cutting plotter to create fold lines.
However, if I use stroke-dashoffset to change where the strokes begin, the plotter can not read the file properly (The file preview is a mess of lines and when cutting it, it just ignores the fold lines).
Are there alternatives for stroke-dasharrays?
One solution which may be of use is to run your SVG through Inkscape (free SVG editor).
It includes an extension that can convert a dashed line to a path consisting of a subpath for each dash segment.
Load the SVG into Inkscape
Adjust the dashoffset now if you haven't already ("Fill and Stroke" panel -> "Stroke style")
Select the dashed line
Select `Extensions -> Modify Path -> Convert to Dashes.
Save the file.
Before
After
Now your line has no dash pattern and your plotter software should be happy. Hopefully.
Related
I want to automate "raster to vector" conversions. PNG to SVG. (most Qs here on SO are the other way around)
I have tried the old command line tool autotrace on Linux, but I could not get it to run. I've tried to install a package, and to compile it from the source. Nope.
Then I've realised that Inkscape has "autotrace" now integrated in its codebase. I'd like to convert simple sketches from PNG to SVG.
And I want to do this in a Bash for-loop , with different autotrace settings (number of passes; ignore Speckles with max X pixels width) etc.
I've tried the "action" command-line option
inkscape --without-gui --actions="file-open:my.png"
and this brings up the small "png bitmap image import" dialog, waiting for me to confirm.
Also I've tried the verb command line option
inkscape --with-gui --verb="FileImport:my.png"
and this opens the large "Select file to import" dialog (ignoring my --verb argument)
At this point I gave up.
I want Inkscape to import a PNG picture, autotrace it with some settings, save it as SVG. Perhaps, beofre saving, duplicate the traced layer, lock the imported background layer, rename the layers from path-12345 to "tracesettings-x-y-z" etc.
(my final goal is to permute the tracing settings, to find good ones for my use-case, but that's not the focus of this question)
Inkscape is using potrace and autotrace to trace bitmap images into vector formats such as SVG and PDF.
Let's assume you have an image: foo.png that you want to trace to SVG using potrace:
First, you need to convert your image to a bitmap format (BMP).
Invoke the potrace command
# I am using ImageMagick convert command to convert PNG to BMP
convert foo.png foo.bmp
# Invoke potrace command with SVG backend
potrace -b svg foo.bmp
The result will be: foo.svg.
I am new to inkscape and I would like to know if there is anyway to increase/change the width of a line without changing its stroke width.
I want the line to have a fill color and a narrow black stroke (preferably 2px).
Thanks
You can convert a thick-stroked curve using the Stroke to path command (in the Path menu): this won't change its aspect, but instead of being defined as a line with a given width, this will give a polygonal shape (a sort of ribbon). Then you can give this ribbon a stroke colour and thickness (Shift-click on the chosen colour).
In the Inkscape version 1.0 there are four buttons on the right side of the toolbar. The first one is responsible for enabling of scaling the stroke while changing the width of an object. Click it to disable this kind of scaling.
There's a small trick to change the width line as Inkscape doesn't provide a mechanism.
Close the current file in Inkscape
Edit your file in a normal ASCII Editor
Find your object (e.g. a spline), it will be a path ... statement
Change the "stroke-width" manually e.g. as
<path style="fill:none;stroke:#80ffff;stroke-width:0.164583px; ....
Tip: If you have a large file, you can assign your object a unique color (here 80FFFF) and you can then search that color code "80FFFF" in your ASCII Editor.
Is it possible to repeat the background in svg path based on the line orientation, like pattern along path in inkspace?
From what I can see, Inkscape does its pattern along path with offline calculations in the editor - there is nothing built into SVG that helps with this.
I'm thinking about using Droid font to create a Ruby-like font for CJK scripts.
However I'm not sure if I can create a script to convert/package multiple SVG files/glyphs into one font file?
"New" glyphs creation
For information, I want to create new glyphs –for CJK glyhs– as follow:
put a Chinese glyph (e.g. 中) into a SVG file ;
add the prononciation (e.g. zhōng) to this SVG.
Once all new CJK glyphs have been created in SVG, I need to package my font
Data would come from Unihan datadase.
Goal
I want something similar to the image below but placing the pronunciation to another place and having different orientation.
FontForge has a Python interface. http://fontforge.org/python.html
A glyph object has methods like export and importOutlines.
My code is untested but reading the FontForge docs the export should go like this:
import fontforge
f = fontforge.open("SomeChineeseFont.ext")
# Not sure if this is the right way to select all glyphs. But you'll get there.
for i in f.selection.select.all():
f[i].export("%s.svg" %i)
Now after weeks of editing SVG's (automate this too). It's time to import:
import fontforge
f = fontforge.open("SomeChineeseFont.ext") # Use the orginal font as base
for i in f.selection.select.all():
# Delete the original glyph or make sure your SVG
# only contains the contours you want to add.
f.clear()
f[i].importOutlines("%s.svg" %i)
f.save("SomeRubyLikeChineeseFont.ext")
Is this what you where looking for?
I know nothing about SVG. Even less about SVG fonts. However, I need to use them in my web project.
I've created a custom font with fontello and analyzed the format of the SVG file in a text editor. Then I opened an SVG file created with Inkscape (saved as plain SVG) and used its d attribute to create a new glyph in the font.
I couldn't believe that it actually worked ... well, almost ... the glyph appears flipped vertically. I have tried flipping it in Inskcape. However, when I save the file, the original d attribute is left as it was. It just adds a transform with a matrix that flips the coordinate system, but which does now work in the <glyph> tag.
Is there any way I could apply this transformation in the font file, or in Inkscape, to change the d attibute?
Thanks.
I found that, in Inkscape, ungrouping and then grouping the object applies the transformation to the coordinates.