[Qt-interest] SVG Questions - more detail

Roopesh Chander roop at forwardbias.in
Tue Feb 24 20:02:29 CET 2009


On Sunday 22 February 2009 10:01 PM, Dan White wrote:
> I opened the SVG file with a text editor and found...
> 
> <text fill="#000000" fill-opacity="1" stroke="none" x="300" y="448"  
> font-family="Blue Highway" font-size="-1pt" font-weight="400" font- 
> style="normal">Title</text>
> 
> !!!?  font-size="-1pt"  ?!!!
> 
> On Feb 21, 2009, at 11:16 PM, Dan White wrote:
> 
>> I am trying to do some simple line drawings with text and have it
>> output to either PDF or SVG.
>>
>> I have managed the PDF with very pleasing results, but the SVG is
>> driving me buggy.
>>
>> I have been unable to get the page size of the SVG document or get my
>> drawing to scale into the page properly.  I get a drawing that looks
>> like what I want, but is about 25 times bigger than what I want.  I
>> get a document page that is about 20 times bigger than what I want,
>> and does not have the same height to width ratio as the drawing.
>> All my text has a font size of -2 and displays rotated 180 degrees
>> and very very tiny.
>>
>> With the PDF, I can just call
>>
>> printer->setOutputFormat ( QPrinter::PdfFormat ) ;
>> and then
>> printer->setPaperSize ( ... ) ;
>>
>> I tried using QSvgGenerator->setSize() in a similar fashion, but it
>> does not give me the results I want.
>>
>> Can anyone point me in the correct direction ?

Maybe you didn't set the resolution?

The svg generated from the following code (with Qt 4.4.3) shows up the 
intended mail icon in Inkscape and EoG perfectly:

int main() {
     QSvgGenerator svggen;
     svggen.setSize(QSize(125, 75));
     svggen.setFileName("/tmp/rect.svg");
     svggen.setResolution(90);
     QPainter painter(&svggen);
     painter.setPen(QPen(Qt::black, 1));
     painter.setBrush(QBrush(QColor(Qt::red).lighter(180)));
     painter.drawRect(10, 10, 60, 40);
     painter.drawLine(QPoint(10, 10), QPoint(40, 30));
     painter.drawLine(QPoint(40, 30), QPoint(70, 10));
}

(Inkscape assumes that 1 SVG user unit == 1 pixel at 90 dpi.)

roop.



More information about the Qt-interest-old mailing list