Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to calculate qfont pixel size from point size

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().

like image 524
David Burson Avatar asked Sep 13 '10 15:09

David Burson


People also ask

How many pixels is a point size?

A point (pt) is equal to 0.352778 millimeters, 0.0138889 inches, or 1.333 pixels.

How many pixels is a 12 point font?

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.

What is the difference between px and pt?

pt is for print, px is for displays but it doesn't change with browser settings so use em/rem.

Is point size the same as font size?

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.


1 Answers

Probably class QFontMetrics will do the job. Just create your desired QFont, set It's point size. Then create QFontMetrics object on your QFont.

like image 90
Kamil Klimek Avatar answered Sep 27 '22 18:09

Kamil Klimek