EMF export, zero width line problems

Bug #943487 reported by David Mathog
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
New
Undecided
Unassigned

Bug Description

EMF export has two problems with zero width exported lines:

1. If stroke is disabled createpen is never called but fill is. Other applications that read the EMF can then use a default pen which is not zero width.

Fix to apply to emf-win32-print.cpp_:

Insert this:

//Inkscape is NOT calling create_pen for objects with no border. PPT, and presumably others, pick whatever they want
//for the border if it is not specified, so no border can become border. To avoid this specify "no pen" here if we can determine
//that will not be needed after the fill.
    if (style->stroke.noneSet || style->stroke_width.computed == 0.0){
          if(hpen)destroy_pen();
          hpen = (HPEN) GetStockObject(NULL_PEN);
          hpenOld = (HPEN) SelectObject( hdc, hpen );
    }

after

    flush_fill(); // flush any pending fills

in

    unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/,

2. If stroke is enabled but width is 0 createpen is called, but with width is 1.

Fix to apply to emf-win32-print.cpp_:

change this:
        DWORD linewidth = MAX( 1, (DWORD) (scale * style->stroke_width.computed * PX2WORLD) );

to this

        if(!style->stroke_width.computed){return;} //if width is 0 do not (reset) the pen, it should already be NULL_PEN
        DWORD linewidth = MAX( 1, (DWORD) (scale * style->stroke_width.computed * PX2WORLD) );

The original code was likely supposed to handle the case where the thinnest possible line was desired. However, it also ended up drawing a line when no line (width==0) was intended.

At another level it perhaps should be the case that stroke could not be set when line width is zero.

----------------------------------------

Note, a much better fix would be to repair whichever routine it is that is not calling create_pen when no stroke is indicated. It should instead call create_pen with a zero width. and the 2nd fix above would then be changed to create a NULL_PEN instead of just returning. I did not do that on my copy because I could not figure out which routine was making the original error, and so worked around it at the EMF level. This results in the poorly structured fix of making the pen in the fill section (it had to be made somewhere for each object, and create_pen was not being called).

Revision history for this message
David Mathog (mathog) wrote :
Revision history for this message
David Mathog (mathog) wrote :

This was for trunk + devlib as of 2/29/2012, on Windows XP

su_v (suv-lp)
tags: added: emf exporting win32
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.