Hello Everybody!
I am developing an online game with typography, dealing with crash testing letters. This implies to create an hit of each letter. I am using paper.js to manage all kinds of vector geometry computation and rendering, what is actually doing a very nice job so far. I have written a little svg parser, because i would like to load whole fonts from the server. These fonts are converted via the apache batik font converter. This all working fine but there is one problem left which really drives me nuts.
I have to remove all the counters from the glyphs which have one. paper.js does not provide a method for boolean operations with paths yet, so i googled around and found out that the implementation of this operations is quiet complicated.
So finally i had the idea of coding an inkscape extension which should do the following things:
1. getting all <font> - tags.
2. cloning it, setting an appropriate id and adding a namespace attribute to it.
3. iterating over each glyph, taking its data from the d attribute
4. using this string to construct a bezier curve
------------------------------------------------------
!!! 5. running a boolean union command over all subpaths !!!
------------------------------------------------------
6. converting the curve back to a string and set it to the cloned glyphs d attribute.
done.
here is a little illustration of the problem:
At the moment i have a basic script with an *.inx - file and a *.py file which includes a class the extends inkex. But for now i cannot find any reference that could give me an overview of the inkscape object, the methods and so on. I don't think that this script might become very difficult, but i where can i find an Object reference and some coding hints??
Greetings philipp
dublicating a font and remove counters
Re: dublicating a font and remove counters
Your effect extension runs independent from inkscape (beyond it's input and output). If you don't want to implement the union on your own, you might look into running inkscape from the command line to access that functionality: http://inkscape.org/doc/inkscape-man.html. I suppose that support for something like this could be generalized and packed into a class like inkex (which I haven't used), but I doubt it's currently in there.
Re: dublicating a font and remove counters
Hello!
Running Inkscape from the commandline to make the necessary work is even better, because than i can do the overall process of removing all the counters from a font in one script. But I do not think that i did fully understand the way i should start this. In the documentation above i could not find any specific command for i.e: »clone an element«, or »path union«. So if I get that right, I have to awake Inkscape from the commandline and let it open the font file. Than, with a second command i have to run an extension, that actually clones the font , removes the counters, writes it to the document and saves it. Is this right, or can i run the »clone« and »union« commands straight from the commandline?
Greetings philipp
***************************************************************
Ok i just went on searching the commandline documentation and found the thing called »verb-list«. In this list the extension U started to code appeared two, and i also found verbs like: »SelectionUnion« which suggests me to union paths, if i have them selected. So for now the questions remains n this way:
Do I have to open the font from the command line like this:
which opens the file and runs the extension, or is it this way:
???
Does the verbs have options - may be with an documentation??
Running Inkscape from the commandline to make the necessary work is even better, because than i can do the overall process of removing all the counters from a font in one script. But I do not think that i did fully understand the way i should start this. In the documentation above i could not find any specific command for i.e: »clone an element«, or »path union«. So if I get that right, I have to awake Inkscape from the commandline and let it open the font file. Than, with a second command i have to run an extension, that actually clones the font , removes the counters, writes it to the document and saves it. Is this right, or can i run the »clone« and »union« commands straight from the commandline?
Greetings philipp
***************************************************************
Ok i just went on searching the commandline documentation and found the thing called »verb-list«. In this list the extension U started to code appeared two, and i also found verbs like: »SelectionUnion« which suggests me to union paths, if i have them selected. So for now the questions remains n this way:
Do I have to open the font from the command line like this:
Code: Select all
inkscape --file=path/to/my/svg/font.svg --verb=com.myverb
which opens the file and runs the extension, or is it this way:
Code: Select all
inkscape --verb=FileOpen --shell -z
--verb=...
--verb=...
--verb=FileSave
???
Does the verbs have options - may be with an documentation??
Re: dublicating a font and remove counters
Sorry that I can not be of more help. I am still learning too. Best.
Re: dublicating a font and remove counters
So just because it is so difficult to find any kind of documentation or reference about the extension development, i plan to solve the problem on another way, using the commandline, or better the powershell of windows. So my script will go the following steps:
-----powershell
1. convert the font
2. iterating over all glyphs
3. creating a new svg with only one path in it and copying the path data from the actual glyph
4. save this new temporarily svg
-----inkscape
5. open the file
6. selecting all
7. spiting the paths
8. union them
9. saving
----powershell
10. opening the svg font file
11. inserting a new font
12. insert the new glyph with the path data from the temporarily svg
13. delete the temp file
14. saving the font file
All in all it will be a lot of xml and file open-close-save fun.
Mixing up the scripts like this is horror, but I just could not figure out how to use a single extension, but time is running and this is a solution.
If there is somebody outside who knows, or has a good documentation, please feel free to post it!!
Greetings
Philipp
-----powershell
1. convert the font
2. iterating over all glyphs
3. creating a new svg with only one path in it and copying the path data from the actual glyph
4. save this new temporarily svg
-----inkscape
5. open the file
6. selecting all
7. spiting the paths
8. union them
9. saving
----powershell
10. opening the svg font file
11. inserting a new font
12. insert the new glyph with the path data from the temporarily svg
13. delete the temp file
14. saving the font file
All in all it will be a lot of xml and file open-close-save fun.
Mixing up the scripts like this is horror, but I just could not figure out how to use a single extension, but time is running and this is a solution.
If there is somebody outside who knows, or has a good documentation, please feel free to post it!!
Greetings
Philipp
Re: dublicating a font and remove counters
I recently wrote a walk through about writing extensions in languages other than the supported scripting languages. I suspect that once you get your powershell script working, you should be able to execute it from an inkscape extension in a similar way. Here's the link: http://sugarpillstudios.com/wp/?p=142. Best.