When developing a user interface for mobile applications, varying screen sizes and resolutions can cause many challenges. If you are creating an internal corporate line of business application, you may have some control over the devices that are used and can then limit the applications’ supported screen resolutions. However, in some cases you cannot control the target device for your application. If you have a commercial product that you want to run on phones, you will have no control over which particular devices are used with the application. (Microsoft Windows Mobile, for example, is supported on many devices with differing screen resolutions.) You would undoubtedly want your application to be available to the widest possible audience in order to maximize its success, and that means making your application suitable for a number of different screen resolutions. Drawing graphics that fit the screen is one of the challenges of supporting such a wide variety of device screen resolutions.
You may think that you would only utilize strings generated with GDI+ for drawing charts, graphs, or other graphical data visualization. You can, however, use graphics combined with Windows Form (WinForm) controls to provide an enhanced user experience by accommodating different resolutions. Graphic strings are also useful if you want to display text in a format where the user cannot copy the text and paste it elsewhere.
In the Microsoft .NET Compact Framework and the full Microsoft .NET Framework, the MeasureString method is provided for developers who want to find out if their graphic string is going to fit into available space when displayed. The use of MeasureString by itself does not accomplish what a developer would require to adapt graphic strings to a variable screen resolution. You must do a little extra work if you want to effectively adapt graphic text fonts to a given amount of screen real estate.
In order to solve this problem, you will need a simple method for dynamically resizing a text graphic based upon its container size.