c# - How can I force a winforms app to use the fonts/fontsizes I specify on every machine? -


How do I implement a Winform app to specify fonts / fonts on every machine? I have a C # app where the font resizes on different machines, and this is not a resolution thig. Is it a way to force the font size on Windows 7 with a C # app, or does the user always reverse the OS fonts?

The font size is specified in the number one point is 1/72 inches The problem is that it is the rest of the Windows form There is a need to live with, where almost a few pixels are specified. The problem is that how many pixels make a point depends on your video adapter's dot-per-inch setting.

The traditional setting is 96 dots per inch so if you ask for 9 point fonts, you get a 9/72 * 96 = 12 pixels high. Unless the control client's area is at least 12 pixels high, the text displayed in it will not be cut.

The DPI setting of the video adapter can be changed however. They made it difficult in XP, you had to go to the advanced settings of the display applet to do this. It has become very easy in Vista, there is a direct link with a good ruler and whatnot.

The next common setting is 120 dpi, 125% more per inch dots that 9 point font now requires 9/72 * 120 = 15 pixels if the original control that displays that text, then now Even at 12 pixels, the text will be knit. In fact, those who land off are closed.

To do this, control. It is necessary to change the properties of control in the form. They should be scaled to accommodate large DPI settings The form of windows that easily supports this form. AutoScaleMode is available from .NET 2.0. When you set it to something other than anyone, then kicks in the automated code within the form of a window which compensates for the difference between the machine that designed the form and the machine to display the form. In 120 dpi case, this will make the form and control larger. So that they can display the clips without text.

But, there is a complexity. The DPI setting is very good for changing fonts TrueType is great technology, capable of providing good looks type on any size. But reciprocating lines do not work very well for art pictures, they take extra pixels of disorientation or become fuzzy when you save them.

Back to the fonts: Clearly, if you change the monitor's DPI setting, then the user expects that follow the fonts suite. This definitely worked in XP days like this. If you change the DPI setting of the video adapter, you receive a prompt to reboot the operating system. This was important, because there were so many programs that used device fonts, were not true-type fonts. Non-scalable fonts New fonts have been activated which match the DPI settings. The larger value of the video DPI corresponds to the larger system base font size.

At about the same time, some kind of genius in Microsoft, since the murder, really came with good ideas, people living in East Asia have a writing system based on letters complex glyphs To display details, lots of pixels are required. 12px at 96 dpi not leaving a lot of room to make a good looking Chinese or Korean glyph. Increasing the DPI clearly improved, but at the expense of fuzzy images. Idea: Increase the base font size of the system, but not replace the video DPI.

Now there is a new problem: How to automatically scale the UI. You can see it back in the values ​​that you can assign to AutoScaleMode property, either fonts or dpi. The one that is right for the target machine is not easily guessable. Font is normally a better option because you want to make sure that the text is not cut. However, if you want to make sure the images are displayed at the right size, then you want the DPI to be both in the middle of a rock and a difficult place, when you want both of them, depending on the basis of the system Font size can not match the video dpi setting.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -