[PyQt] QGrahics / textItemSize
Philippe Crave
philippe.crave at gmail.com
Sun Feb 6 15:54:41 GMT 2011
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/20110206/aea37448/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: application/octet-stream
Size: 588 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110206/aea37448/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rect2820.png
Type: image/png
Size: 1588 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110206/aea37448/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_font_size.svg
Type: image/svg+xml
Size: 2670 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110206/aea37448/attachment.svg>
More information about the PyQt
mailing list