[PyQt] QGrahics / textItemSize
Philippe Crave
philippe.crave at gmail.com
Wed Feb 9 07:19:26 GMT 2011
sorry to bring this up again.
but I still haven't found what was wrong.
If I draw a rectangle and a text on a QGraphicsScene, and do the same in
inkscape, the rectangles will have same size (like 200x40px) but the text
will be different. the text on the QGraphics will be bigger that the text in
inkscape.
is it a bug ?
I think that I am doing something wrong, but do not find what.
thanks for your help.
2011/2/6 Philippe Crave <philippe.crave at gmail.com>
> Thanks for testing !
>
> I attach a new code with Arial (maybe you're under windows) and a new png.
> this time, I also draw a rectangle. 200x40px, red.
>
> you can check that the scene produced my the pyqt code gives a rectangle
> like the one in the png. I did it in inkscape. a 200x40px red rect.
>
> but for the font, "hello 1" is too big. "hello 2" seems to be of similar
> size. but it was scale.
> I attach the .svg too.
> in the svg (and the png), i wrote "hello" in arial/40
>
> why should I scale the text (with a ratio of .75) to get a correct size ?
>
> 2011/2/6 KONTRA, Gergely <pihentagy at gmail.com>
>
> For me the 2 texts are sized equal if I remove the line, which scales the
>> text.
>>
>> But I guess I do not have the font Norasi (rendered as some
>> sans-serirf font on my PC).
>>
>> Gergo
>> +-[ Gergely Kontra <pihentagy at gmail.com> ]------------------+
>> | |
>> | Mobile:(+36 20)356 9656 |
>> | |
>> +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
>>
>>
>>
>> On Sat, Feb 5, 2011 at 11:14, Philippe Crave <philippe.crave at gmail.com>
>> wrote:
>> > Hello,
>> >
>> > When I add to the Scene some rectangles and texts, rectangles are
>> perfect,
>> > but text are too big.
>> >
>> > If I add a QGraphicsSimpleTextItem with a font_size of 40, it will
>> display
>> > bigger than the same text/font/size if I draw it in inkscape (or
>> anywhere
>> > else).
>> > Seems that I have to scale with a ratio of 0.75 to get a correct size.
>> >
>> > What am I doing wrong ?
>> >
>> > here is my sample (I also attach a png with a text in Norasi with a size
>> of
>> > 40):
>> >
>> > from PyQt4 import QtGui
>> >
>> > import sys
>> >
>> > app = QtGui.QApplication(sys.argv)
>> >
>> > scene = QtGui.QGraphicsScene(0, 0, 400, 400)
>> >
>> > scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))
>> >
>> > t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))
>> >
>> > t.setY(100)
>> >
>> > t.scale(.75, .75)
>> >
>> > view = QtGui.QGraphicsView(scene)
>> >
>> > view.setRenderHint(QtGui.QPainter.Antialiasing)
>> >
>> >
>> view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
>> >
>> > view.show()
>> >
>> > sys.exit(app.exec_())
>> >
>> >
>> >
>> > _______________________________________________
>> > PyQt mailing list PyQt at riverbankcomputing.com
>> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110209/7f87e3d0/attachment.html>
More information about the PyQt
mailing list