How do I convert my font on a QGraphicsObject
from point size to pixel size? I need to do this so the fonts will look right when I print my QGraphicsScene
using QGraphicsScene::render()
.
A point (pt) is equal to 0.352778 millimeters, 0.0138889 inches, or 1.333 pixels.
Font size specifications may come in points or pixels where: 1 pixel (px) is usually assumed to be 1/96th of an inch. 1 point (pt) is assumed to be 1/72nd of an inch. Therefore 16px = 12pt.
pt is for print, px is for displays but it doesn't change with browser settings so use em/rem.
The em size of a font is equal to its point size. The point size is also used to measure leading (line-height), line length and other elements, apart from font size. In digital typefaces, one point is equal to 1/72 of an inch. Twelve points make one pica. Six picas make one inch.
Probably class QFontMetrics will do the job. Just create your desired QFont, set It's point size. Then create QFontMetrics object on your QFont.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With