Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MeasureString Method (String)
Collapse the table of content
Expand the table of content

SpriteFont.MeasureString Method (String)

Returns the height and width of a given string as a Vector2.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public Vector2 MeasureString (
         string text
)

Parameters

text
The string to measure.

Return Value

The height and width, in pixels, of text, when it is rendered.

Exception typeCondition
ArgumentNullException text cannot be null.
ArgumentException There is a character in text that was not imported by the SpriteFont. You must include all the characters in the character regions in the sprite font file. For more information see How To: Extend the Font Description Processor to Support Additional Characters.

Xbox 360, Windows XP SP2, Windows Vista, Zune

Community Additions

ADD
Show:
© 2015 Microsoft