On Wed, Nov 26, 2008 at 1:11 AM, LukasH wrote:
> I have a problem with properly loading svg doc. I have used
> a2dCanvasDocument and input method of a2dIOHandlerSVGIn to load svg, I
> encountered two problems one is that strokes do not have the colors which
> are set in svg files and second is the size of text which is also not
> correct. I have encountered it based on two svg files 7zipped which I
> attached to the email. Second problem is on svg file Preview.svg also
> attched to the email. The problematic issues could be seen when for example
> loading the files in wxArt2d sample program - editor_vdraws.
> Thank you in advance for helping me with that issues.

For the strokes on, for example, the Xenia SVG: since the paths in the
SVG were not defined with a stroke on them, they use the default layer
stroke in the global layer defaults.  In vdraws, the default strokes,
etc, was defined in a file, in this line:

a2dCanvasGlobals->LoadLayers( wxT("../common/drawings/layersdefault.cvg") );

However, really, the default stroke ought to be invisible when loading
an SVG, as is rendered in Adobe Illustrator or a browser plugin.  I'm
not going to touch the a2dCanvasGlobals constructor to change the
default stroke to a transparent stroke.  However, if you wish to
change the default stroke, here's how it would be done in vdraws:

Add this to the include section at the top of vdraws.cpp:

#include <vector>

Below this line:

a2dCanvasGlobals->LoadLayers( wxT("../common/drawings/layersdefault.cvg") );

add the following:

std::vector<a2dLayerInfoPtr> &globalLayers =
    a2dCanvasGlobals->GetLayerSetup()->GetLayerIndex();
for
(
    std::vector<a2dLayerInfoPtr>::iterator layer = globalLayers.begin();
    layer != globalLayers.end();
    ++layer
)
{
    (*layer)->SetStroke (*a2dTRANSPARENT_STROKE);
}

When I tried simply commenting out the original LoadLayers line and
replacing it with the above, it would segfault on me.  Perhaps the
layers are not initialized fully at that point in time.

For your second SVG, preview.svg, text loading is not as robust as it
should be.  Currently, it relies on using the style tag instead of
inline parameters, for example:

<text style="font-size:12; font-family:Helvetica;stroke:blue;" x="237"
y="103">0</text>

as opposed to what is in preview.svg:

<text font-size="24" font-family="Helvetica" fill="blue" x="237"
y="103">0</text>

Note that the color of the text is its stroke, not fill.
Interestingly enough, at least on my system Illustrator chooses
different font names to map Helvetica to depending on whether the
font-family style parameter is in the tag itself or in a style
parameter.  It must be a bug in Adobe's code.

Another problem I've noticed in wxArt2D, with respect to the SVG input
code, is that new text blocks inherit the style parameters of the
previous text (not nested), which they really should not.

Anyway, for now try using the workarounds above.  You can also look
around in the parsesvg.cpp and see if you can fix these issues.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Wxart2d-users_dev mailing list
Wxart2d-users_dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev

Reply via email to