Results 1 to 4 of 4

Thread: SVG rendering problems and doubs

  1. #1
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default SVG rendering problems and doubs

    Hi Guys,

    I am making and example code (for integrate later in my proyect) to print receipts using a SVG as template.

    I have 2 problems:

    1. Does Qt supports very will <tspan> inside <text>?:
    The idea is to let user draft a SVG receipt template using Inkscape. Now, in inkscape when you create a <text> and inside that one newlines are inserted by using <tspan>. Every SVG viewer and browser shows this correctly, having one string under other as expected. Qt does not, it puts the strings one next the other (avoiding the existence of <tspan>). Now, i could fix this by inserting just one string per <text> and not using <tspan>. But the main question is if Qt supports it and if does, what i am doing wrong?.
    2. Another related to rendering, as you can see in the SVG, i have a background in which represents the receipt structure. Well, Qt only is rendering only the backgrond color and the external borders. The lines inside the background, does not appear (which again, it works in all browsers and SVG viewers).

    There is something i am doing wrong?

    Here is my example code:

    Main svn dir: http://websvn.tuxfamily.org/listing....x_SvgTemplate_

    The main code is in mainApp.py and in that folder you have the SVG template too.

    The example is in Spanish, but is just completing anything in the lineEdits and just adding some articles (artÃ*culos) with some values (cantidad, precio = quantity, price) for the testing and then just preview or print it.

    Thanks in advance for any help and tips you guys can give me.
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: SVG rendering problems and doubs

    I've done exactly this myself.
    Quote Originally Posted by GuS View Post
    1. Does Qt supports very will <tspan> inside <text>?:
    QtSvg only supports the static features of SVG Tiny. From that spec on wrapping text:
    Each 'text' element causes a single string of text to be rendered. The 'text' element performs no automatic line breaking or word wrapping. To achieve the effect of multiple lines of text, use one of the following methods:
    * Use the 'textArea' element to specify a rectangular area in which to flow the text.
    * Pre-compute the line breaks (which can be done by the author or authoring tool) and use individual 'text' elements to manually place the lines of text. (Note: this is discouraged for accessibility reasons.)
    * Express the text to be rendered in another XML namespace such as XHTML [XHTML] embedded inline within a 'foreignObject' element. (Note: the exact semantics of this approach are not completely defined at this time.)
    Unfortunately Inkscape does none of these things in its multi-line text. If memory serves it uses an attribute from the draft SVG Full 1.2 (flowRoot and flowRegion). I simply created multiple text objects for multi-line fixed text. For columns of variable text I retrieved a named bounding box and rendered the text within the rectangle after rendering the template. You could try manually using a textarea.
    2. Another related to rendering, as you can see in the SVG, I have a background in which represents the receipt structure. Well, Qt only is rendering only the backgrond color and the external borders. The lines inside the background, does not appear (which again, it works in all browsers and SVG viewers).
    In my application background shading was optional and only rendered when requested (I painted selected SVG objects by id). I had to be careful that the background was painted before the overlying lines or it would obscure them. If you do something similar this is something to watch for.

    When I get to my Qt dev machine I'll try your code and see if I can see the the same problem.

    Edit:
    It does that for me too.
    Last edited by ChrisW67; 4th October 2009 at 09:08.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: SVG rendering problems and doubs

    I took a look at the paths defining the left table and it struck me that it was dictating a lot of moveto (m) commands that don't (shouldn't) draw, and a few lineto (l) and circle (c) commands that do. The line and circle commands are your outer border.
    Qt Code:
    1. <path
    2. id="billBg_original"
    3. style="fill:#f0f0f0;stroke:#000000;stroke-width:1.77165353000000003;
    4. stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;
    5. stroke-opacity:1;stroke-dasharray:none;fill-opacity:1"
    6. d="m 495.27339,970.73588 0,-358.53854
    7. m -71.27008,324.1224 0,-324.21608
    8. m 158.9011,358.77089 -511.991713,0
    9. m 511.991713,-34.25 -511.991713,0
    10. m 511.991713,-324.5625 -511.991713,0
    11. m 511.991713,-22.52773 -511.991713,0
    12. m 511.991713,-69.55806 -511.991713,0
    13. m 511.991713,-54.68568 -511.991713,0
    14. m 255.995853,-139.98177 0,139.96355
    15. M 80.901962,325.27594
    16. l 492.013188,0 c 5.54,0 10,4.46 10,10
    17. l 0,669.17246 c 0,5.54 -4.46,10 -10,10
    18. l -492.013188,0 c -5.54,0 -10,-4.46 -10,-10
    19. l 0,-669.17246 c 0,-5.54 4.46,-10 10,-10 z" />
    To copy to clipboard, switch view to plain text mode 
    (line wrapping is mine)
    When I used the Path/Break Apart option in Inkscape and readjusted the depth the missing lines were drawn. The SVG got a bit bulkier with multiple paths. Inkscape may be doing something odd with these paths when combined

    I drew my complex grids as a collection of rectangles and lines rather than one compound path.

  4. The following user says thank you to ChrisW67 for this useful post:

    GuS (5th October 2009)

  5. #4
    Join Date
    Mar 2006
    Location
    Argentina - CABA
    Posts
    66
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default Re: SVG rendering problems and doubs

    Hi!

    Thanks for the reply. Seems that Qt even have problems rendering lines. I just create from scratch the bg and external borders as a rectangle and the same for the lines, just used thin rectangles and works. As for the text, i will just create separated <text> for the data, which that works.

    Before i was using a html/css template to generate this (with QWebKit for the rendering part) but seems that this QWebKit has problems to render too: i was rendering the template with a more small size... weird... in all browsers (nt webKit based) was good.

    Thanks!
    Gustavo A. DÃ*az
    artistic.gdnet.com.ar

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.