Amal
Amal

Reputation: 141

Graphics.MeasureString() returns size in Point or Pixel?

I use Graphics.MeasureString to calculate size of a text. EG: 10 pixel = 7.5 Point.

My question: Is the size calculated from Graphics.MeasureString point value or pixel value?

Upvotes: 4

Views: 1909

Answers (2)

Matt Hogan-Jones
Matt Hogan-Jones

Reputation: 3103

From the MSDN page:

This method returns a SizeF structure that represents the size, in the units specified by the PageUnit property, of the string specified by the text parameter as drawn with the font parameter.

The PageUnit is of type GraphicsUnit which is an enum with the following values

Member name Description
Display Specifies the unit of measure of the display device. Typically pixels for video displays, and 1/100 inch for printers.
Document Specifies the document unit (1/300 inch) as the unit of measure.
Inch Specifies the inch as the unit of measure.
Millimeter Specifies the millimeter as the unit of measure.
Pixel Specifies a device pixel as the unit of measure.
Point Specifies a printer's point (1/72 inch) as the unit of measure.
World Specifies the world coordinate system unit as the unit of measure.

Apologies for the terrible formatting!

Upvotes: 4

liamguy165
liamguy165

Reputation: 42

You can use Graphics.PageUnit in order to set the return type of measurement. So it can be either Pixel or Point, it is your choice

Upvotes: 1

Related Questions