Skip to content

Bug with WMF/EMF

Hi, we're using Inkscape CLI for converting significant thousands WMF / EMF images containing molecules rendered to SVG. A lot of those have atom letters and some have 2+ letters: Si / Cl / Na, etc.

Steps to reproduce:

  • prepare WMF/EMF file which has two letters written with two sequential U_WMR_TEXTOUT / U_WMR_EXTTEXTOUT commands, having different x, y args (That's based on debugging we did. I can't share molecule images unfortunately).
  • try opening with Inkscape or use CLI for conversion.

What happened?

What we observed is that sometimes letters have the same x,y position. So that S and i or C and l, or N and a in examples above are rendered over each other.

Capture

What should have happened?

Rendering expected to be correct. Si / Cl / Na should have rendered properly.

Inkscape Version and Operating System:

  • Inkscape Version: I've reproduced that on INKSCAPE_1_0 tag.
  • Operating System: Windows
  • Operating System version: Windows 10

So, our debugging has shown that the following code is executed for the problematic files:

if (d->dc[d->level].textAlign & U_TA_UPDATECP) { x1 = d->dc[d->level].cur.x; y1 = d->dc[d->level].cur.y; }

Based on the description from [MS-WMF].PDF for TA_UPDATE_CP

The drawing position in the playback device context MUST be updated after each text output call. It MUST be used as the reference point.

While in this case target coordinates (and not device context position) are updated before (and not after) text output.

I've updated this locally to put the following to the end of case statement and it seems to be working correct for me, but please let me know if I broke something:

if (d->dc[d->level].textAlign & U_TA_UPDATECP) { d->dc[d->level].cur.x = x1; d->dc[d->level].cur.y = y1; }

Meanwhile I'll submit a pull request for this. Feel free to reject if it's not a bug or the solution should look different.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information