Inkscape.org
Beginners' Questions Batch font to path
  1. #1
    Dissonance Dissonance @Dissonance

    Hello!

    I'm making music theory quizzes to run in an LMS. My LMS administrator requires we use svg files. I make my svg images with music notation software, but they only display corretly on systems with the music fonts installed. I can convert the fonts to paths with Inkscape to solve this problem, but I have thousands of images to convert. Is there a way to batch convert fonts to paths?

    Thanks!

  2. #2
    brynn brynn @brynn

    Welcome to the forum!

    (Hhmm.... LMS -- Learning Management System, Library Management System, Labelled Magnitude Scale, LMS Color Space ???)

    If the text can be all one object, you could select all the text in the file, and do Path menu > Union.  All the text will be converted to path, and combined into a whole extremely complex,  compound path.  So you could do one file, all at once.

    As for doing that over many files, I think you'd have to use a script, or maybe Inkscape's commandline tools (or both, I'm not sure about the details).

  3. #3
    Dissonance Dissonance @Dissonance

    LMS is learning management system. I know how to convert the text to path in Inkscape, but since I have thousands of files to do, I would need a script. But first, I would need to learn how to write one.

    I learned that I can use CCS so that browsers can display a WOFF version of the music font. I'm currently tring to find a WOFF that will work with my music notation program.

     

  4. #4
    brynn brynn @brynn

    Interesting.  Never heard of WOFF, but I looked it up.  I hope it will work for you.

  5. #5
    Dissonance Dissonance @Dissonance

    I discovered that there is no WOFF version of the music font I use. I'm back to needing a batch conversion. Is there someone who can help me write a script that will batch convert fonts to paths in SVG files?

  6. #6
    brynn brynn @brynn

    I can't say for sure, but it's possible.  Be patient.

  7. #7
    Maren Hachmann Maren Hachmann @Moini

    Have you had a look at the man page for Inkscape which details the command line options?

  8. #8
    Dissonance Dissonance @Dissonance

    I found the command line options, and I learned how to write a loop in BAT files. From the directory where the file is located

    c:\"Program Files"\Inkscape\Inkscape.exe -T file001.svg

    just opens the GUI. How do I run Inkscape through the command line?

  9. #9
    Dissonance Dissonance @Dissonance

    I figured it out. I wrote this script to do it. The code runs in a batch file.

     

    @Echo off

    set "inkscapePath=C:\Program Files\Inkscape\inkscape.exe"

    echo This script converts texts to paths in all files in this folder and outputs them to plain svg.

    md output

    set /a count=0

    :: Running through all files found with the defined ending
    for %%i in (.\*.svg) do (
        set /a count=count+1
        echo %%i
        "%inkscapePath%" --without-gui --file="%%i" --export-text-to-path --export-plain-svg="output\%%i"
    )
       
    echo %count% file(s) converted.
       
    pause

  10. #10
    brynn brynn @brynn

    Congrats for working it out.

    Good luck with your project!

  11. #11
    fancyaluminum fancyaluminum @fancyaluminum
    👍

    This post is high in google search results and helped me so I'll update it a little:

    The  --without-gui option has been deprecated and can be omitted.
    Here are some excerpts from the manpages for the options used
           -l, --export-plain-svg
                   Export document(s) to plain SVG format, without sodipodi: or inkscape: namespaces and without RDF metadata.
                   Use the --export-filename option to specify the filename.
           -T, --export-text-to-path
                   Convert text objects to paths on export, where applicable (for PS, EPS, PDF and SVG export).
    The form --export-plain-svg=filename.svg has also been deprecated.



     

  12. #12
    Dissonance Dissonance @Dissonance

    @fancyaluminum Thanks for the update!