Tue 10 Aug 2010 03:31:59 PM UTC, original submission:
I drew the attached SVG file in BKchem, but needed to modify it slightly in order to get it to display properly in wikimedia. A script has been written to fix this (see attached perl script), but I think it would be nice to find some way to make the modifications from within BKchem. I was led to this script by Leyo on wikipedia:
http://en.wikipedia.org/wiki/User_talk:DMacks#Re:_Image_Problem
The modifications I needed to make were as follows:
1) Put <tspan> blocks around any text that followed a font change.
2) Change relative font sizes (75%) into absolute font sizes (16pt) for subscript.
3) Use vertical character shifts (+4) rather than baseline shifts (baseline-shift="sub") for subscript, and then do the inverse shift for the next text element (-4).
Notes on the above:
1) It seems like wikimedia's librsvg (and Emacs', FWIW) puts all the <tspan>s after the other text, so if you have CH_3CH_2COOH, it appears as CHCHCOOH_3_2 when converted. I notice that the git version I downloaded just before submitting this report puts a <tspan> around all the text, but that doesn't seem to change anything.
2-3) It looks like the same is also necessary for superscripts as well.
The script does font substitutions as well (which are merely a template adjustment away, so no code changes necessary), and "removes redundant groups", which doesn't seem all that useful except to save a few bytes in file size.
BTW, it's really excellent that I am able to do this -- change output, but keep the source file compatible with BKchem.
Cheers,
David Eccles (gringer)
|