[PyQt] QGrahics / textItemSize

Philippe Crave philippe.crave at gmail.com
Wed Feb 9 19:54:00 GMT 2011


thank you !!
it works well now.

2011/2/9 KONTRA, Gergely <pihentagy at gmail.com>

> Maybe because you set the font size in POINTs.
>
> See:
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qfont.html#QFont-2
>
> and also
>
>
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qfont.html#setPixelSize
> +-[ Gergely Kontra <pihentagy at gmail.com> ]------------------+
> |                                                           |
> | Mobile:(+36 20)356 9656                                   |
> |                                                           |
> +- "Olyan lángész vagyok, hogy poroltóval kellene járnom!" -+
>
>
>
> On Sun, Feb 6, 2011 at 16:54, Philippe Crave <philippe.crave at gmail.com>
> wrote:
> > 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
> >> >
> >
> >
> > _______________________________________________
> > PyQt mailing list    PyQt at riverbankcomputing.com
> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> >
> _______________________________________________
> 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/7883cbd1/attachment.html>


More information about the PyQt mailing list