Fontforge: Export a glyph to SVG with fontforge command line - svg

How to export a glyph (from its unicode) to SVG with Fontforge command line ?
I also need to specify the font size and keep the original margins it has in the font.

You may have found your answer already, but I just had to do this with the latest build of FontForge. The old answer of this command:
fontforge -lang=ff -c 'Open($1); SelectWorthOutputting(); foreach Export("svg"); endloop;' font.ttf
From a command prompt didn't want to work on Windows10 (I assume a permission issue), but you could give it a try. A quick work-around is to do it via the GUI Execute Script.
Run FontForge (For Windows10 installed in the Program Files (x86) directory, you may need to right-click "run_fontforge.exe" --> Run As Administrator).
Open the font you want to export.
Go to File > Execute Script
Paste: SelectWorthOutputting(); foreach Export("svg"); endloop;
Select "FF" radial button.
Hit OK
It'll save to the FontForge folder (where run_fontforge.exe is located).

On Windows os (Tested on win10)
this is from inside a BATCH file:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%%e_%%f_%%n_%%u.eps'); endloop;" %1
this is directly on the command line:
c:\Programs\FontForge\bin\fontforge.exe -lang=ff -c "Open($1); SelectWorthOutputting(); foreach Export('%e_%f_%n_%u.eps'); endloop;" font-file.ttf
note - the color is not exported. And I don't know if it's unimplemented, or a bug.

Related

Converting svg to png with inkscape command line failing

I feel like I must be doing something silly wrong, but I just can't get this to work. This is the command I am running from cmd:
inkscape.com "C:\path\ship.svg" -e --export-png="C:\Path\ship.png" --without-gui
In return, I get:
WARNING: File path "--export-png=C:\path\ship.png" includes directory that doesn't exist.
It does exist. What am I missing?
You should have used either -e or --export-png, not both, since they mean the same thing.
But According to the docs, -e and --export-png are no longer available. You should use -o or --export-filename=FILENAME instead. And still, you can use only one of them since -o is just the shortcut for --export-filename.
inkscape "C:\path\ship.svg" -o "C:\path\ship.png"
or
inkscape "C:\path\ship.svg" --export-filename="C:\path\ship.png"
Just an update for 2021 (it should be typed in oneline - broken down for readability only)
inkscape
--export-width=128
--export-type=png
--export-filename="C:\path\ship.png" "C:\path\build.svg"
or if you want transparent PNGs, add --export-background-opacity=0 to invocation arguments:
inkscape
--export-background-opacity=0
--export-width=128
--export-type=png
--export-filename="C:\path\ship.png" "C:\path\build.svg"
In inkscape version 1.0.2 following command will work:
inkscape --export-type="png" myfile.svg --export-filename=myfile.png

wkhtmltopdf doesn't show desktop size page in pdf

I have been trying to set up wkthmltopdf to convert html to pdf documents on-the-fly on my linux web server. I've looked around for solutions around the default 800x600 issue and found this:
/usr/bin/xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltopdf --use-xserver http://domain.com /home/location/apps/test1.pdf
However, this STILL gives the resulting pdf a width of 800. What am I missing?
I've tried to run xvfb-run from the ssh command line and it works flawlessly. It also creates the pdf with a normal output.. it's just that the width is NOT being recognized...
Just a guess, but you might need another set of quotes around "0, 1024x768x24' so that it's considered a single argument after being passed on. So something like this:
/usr/bin/xvfb-run --server-args="-screen \"0, 1024x768x24\"" wkhtmltopdf --use-xserver http://domain.com /home/location/apps/test1.pdf
They are escaped with \ so that the xvfb-run command does not consider them argument delimiters, but rather passes them on to wkhtmltopdf.
(I don't know about xvfb-run, but assume that it is in turn building a wkhtmltopdf command line.)

add a permitted path to ghostscipt running configuration

I use a program which create me postscript file before using ps2pdf to make it a readable pdf, i've made a program which add some string to overwrite the company new logo. (The first program can't import image file itself).
I add the string before the before-last line of the file (" showpage").
While running my program to add the logo there is no error.
With the option -dNOSAFER everything is fine, but by default it's set to -dSAFER, and an invalidfileaccess error pop, the files are 6 jpg images alone in their directory.
I don't want to make it run with the -dNOSAFER option on. As it will fully open the file system.
In the documentation I've seen that there is a "permitted path" setting, but i can't find nowhere to set this up. Is it just a command line option to set in the command launching the program ? Or is there a config file for GhostScript / ps2pdf where i can put the path to this directory as permitted path.
in this documentation :
http://www.ghostscript.com/doc/current/Use.htm
I only find
-dTTYPAUSE
Causes Ghostscript to read a character from /dev/tty, rather than
standard input, at the end of each page. This may be useful if input
is coming from a pipe. Note that -dTTYPAUSE overrides -dNOPAUSE. Also
note that -dTTYPAUSE requires opening the terminal device directly,
and may cause problems in combination with -dSAFER. Permission errors
can be avoided by adding the device to the permitted reading list
before invoking safer mode
gs -dTTYPAUSE -dDELAYSAFER -c '<< /PermitFileReading [ (/dev/tty)] >> setuserparams .locksafe' -dSAFER
The quote is just for the context but is this a way to put the permitted path ?
As gs automatically launch with the full system as readOnly there will be no difference ? There is no other find result for PermitFile in this page.
Try adding the required path to the search path with -I (Include) See Use.htm, section 8 How Ghostscript finds files. This should only be a problem if you are using 'run' or similar to read files from another location.
The section on TTYPAUSE is not relevant.

Programmatically convert SVG shapes to paths (lineto, moveto)

I have an SVG file coming from Inkscape, Illustrator, or any other application. I want to convert the shapes to lineto, moveto, curveto format.
What I want is something like:
./Appname svgfile outfilewithpath
I will give the SVG file as an argument, then my application will convert the object into the respective paths.
Inkscape has a command-line interface. Use the Inkscape man page along with the verb source for reference:
The ObjectToPath verb converts an object to a path:
inkscape filename.svg --select=myobject --verb=ObjectToPath --export-plain-svg=filename_to_path.svg
The export-text-to-path argument converts text nodes to paths:
inkscape filename.svg --export-eps=filename.eps --export-text-to-path
These are related questions on how to run InkScape from Perl, Ruby, PHP or Python:
Using the Inkscape shell from perl
Run inkscape in PHP
Calling Inkscape in Python
Inkscape Merge Ruby Gem
This is what finally worked for me:
inkscape -f filename.svg --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb ObjectToPath --verb FileSave --verb FileQuit
It takes about 9 seconds to run and briefly opens the inkscape gui, which becomes the active application, so it's not ideal, but it's the only answer I could find that actually works.

"Unable to open image" error when using ImageMagick's Filename References

I'm using ImageMagick to do some image processing from the commandline, and would like to operate on a list of files as specified in foo.txt. From the instructions here: http://www.imagemagick.org/script/command-line-processing.php I see that I can use Filename References from a file prefixed with #. When I run something like:
montage #foo.txt output.jpg
everything works as expected, as long as foo.txt is in the current directory. However, when I try to access bar.txt in a different directory by running:
montage /some_directory/#bar.txt
output2.jpg
I get:
montage: unable to open image
/some_directory/#bar.txt: No such file
or directory # blob.c/OpenBlob/2480.
I believe the issue is my syntax, but I'm not sure what to change it to. Any help would be appreciated.
Quite an old entry but it seems relatively obvious that you need to put the # before the full path:
montage #/some_directory/bar.txt output2.jpg
As of ImageMagick 6.5.4-7 2014-02-10, paths are not supported with # syntax. The # file must be in the current directory and identified by name only.
I haven't tried directing IM to pull the list of files from a file, but I do specify multiple files on the command line like this:
gm -sOutputFile=dest.ext -f file1.ppm file2.ppm file3.ppm
Can you pull the contents of that file into a variable, and then let the shell expand that variable?

Resources