Text Width
-
Hi, Does anyone know how to retrieve the width of a string if outputted to the screen in a given font, e.g. Arial 12 and the string "Hello World"? In other words, how many pixels wide would that string (or any given string) be on the screen? Thanks! -- Andrew.
-
Hi, Does anyone know how to retrieve the width of a string if outputted to the screen in a given font, e.g. Arial 12 and the string "Hello World"? In other words, how many pixels wide would that string (or any given string) be on the screen? Thanks! -- Andrew.
The graphics object has a MeasureString method which returns the size of the text. You pass in the string and the font object to measure with. There are a few other parameters that can be used to adjust how the text will be rendered (the StringFormat class). James Simplicity Rules!
-
The graphics object has a MeasureString method which returns the size of the text. You pass in the string and the font object to measure with. There are a few other parameters that can be used to adjust how the text will be rendered (the StringFormat class). James Simplicity Rules!
Thanks mate! Just what I needed :). Now just what I need is some sleep :-D! Thanks again, -- Andrew.