I have written a WinForms program in C# and left the default font for all form controls (labels, checkboxes…) (The font is Tahoma I think, not sure though). When I compile the program and then run it on a Japanese language computer, all the fonts switch to “MS UI Gothic” (a Japanese font).
Is there anyway I can force the font to be the same on all platforms? Currently it messes up the layout a lot, as the characters have a different width depending on the font…
As has already been mentioned in the comments, the real solution is to make sure that your form layout can handle different fonts and font sizes. After all, even English users will sometimes change the font size in their Control Panel.
That said, you can force a font by setting the
Fontproperty on the form. Most (if not all) controls will inherit the font from the Form if they don’t have an explicit font of their own set. Thus, you could set aFontexplicitly in the forms designer, or — if you want the exact font determined at run-time — in the constructor after the call toInitializeComponent(). But when you do this, be aware that ① this will cause an exception if the font doesn’t exist on another machine; and ② you are making it harder for your software to be internationalised in the future.