Microsoft Sans Serif Font not used in Chinese Localized Windows - c#

Scenario:
A UI Interface element appears to use a different font on US English Windows 7 Enterprise compared to "Chinese" Windows 7 Enterprise even with all localization packs and languages set to English. In the WinForms codebehind, the FontFamily is not explicitly defined and relies on the defaults.
English:
Chinese:
Several questions:
1) What is the font used in the Chinese Windows?
2) What is different about such an install that would cause it to use that font?
3) How do I set up an environment to replicate this? Is it an install time option on Windows 7 that one does not get when switching UI and System Culture on an already installed Windows 7 instance?
FWIW:
I checked C:\Windows\Fonts and it has the same version and size of "Microsoft Sans Serif Regular"

If you haven't done anything to your fonts, default font fall-back mechanism would probably use SimSun as a font replacement for your standard font.
The reason why font is replaced, is that default font on Chinese OS needs to display Chinese characters. And of course due to sheer size, MS Sans Serif does not have Chinese glyphs defined.
To avoid the problem, you might want to "hardcode" font information in resource files – usually simple size modification (i.e. setting 9 instead 8.25) helps. Please be aware, however that if you do that, Chinese characters might appear corrupted – if I recall it correctly it will turn-off font fall-back mechanism completely. It might be appropriate for "static" UI elements that are not going to be translated to Chinese but would be totally unacceptable for text boxes and similar controls which allow users to enter free-form text.
Instead of fighting the rendering issues, it is best to just let it pass. I am sure that Chinese users are simply used to that specific look & feel.

Related

Monospace Fonts for Windows Store App

Are there any monospace fonts that are acceptable for use in Windows Store Apps?? I have read the guidelines, but there isn't mention of anything monospace. Are there some built in fonts on Windows 8 that I can use instead?
The guidelines are just that... guidelines. Microsoft won't reject your app because you don't use the fonts recommended in the docs.
There are many mono-spaced typefaces included in Windows 8.
Consolas
Courier New
Lucida Console
Lucida Sans Typewriter
Segoe UI Mono
Segoe is one of the guideline recommended fonts, so the Segoe UI Mono should be a good pick. Consolas is also a good choice.
You can also embedded other fonts in the application (if you have the license to do so.)
FontSquirrel.com , DaFont.com, 1001FreeFonts.com are some sites offer free, re-distributable fonts.
Just be sure that the font is re-distributable .

Need .NET solution to detect if "East Asian languages" are installed in Windows XP

Environment - C#, .NET 4.0, WPF, VS2010
I have a simple Windows application that supports several cultures/languages. When users select Japanese, Korean, Chinese (Simplified), or Chinese (Traditional), Windows XP will display funny looking "square" or "block" characters in the place of the glyphs. This problem does not occur on Windows Vista, 7 or 8.
As a solution I was advised to go to "Control Panel | Regional and Language Options", select the "Languages" tab, and then check the box to "Install files for East Asian languages".
And that did fix the problem...for my machine. Now I understand that users in Japan who select "Japanese" will most likely already have the necessary resources installed, and they will most likely not experience this problem.
But...I require the ability to detect whether or not the East Asian languages have been installed on any Windows XP machine that is running my app. In such case I will be able to display a message box notifying them to install the languages...or I might decide to hide the Japanese, Korean, Chinese (Simplified) and Chinese (Traditional) culture/language choices.
So...how can I detect if Windows XP has the necessary East Asian language files installed? I prefer a .NET solution, but I am willing to make API calls if necessary.
JP
Instead of checking InputLanguage, you should check CultureInfo using GetCultures function call,
http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.getcultures.aspx
As documented, if InstalledWin32Cultures is used as parameter, this function should return what you want,
http://msdn.microsoft.com/en-us/library/system.globalization.culturetypes.aspx
You could iterate like this:
foreach (System.Windows.Forms.InputLanguage p in System.Windows.Forms.InputLanguage.InstalledInputLanguages)
Console.WriteLine(p.Culture.EnglishName);
it will display what you are looking for.
I haven't tried this but my inclination would be simply to try it--draw something in an East Asian language and examine the result. Did you get a box?
Edit: Apparently some people didn't realize I meant to draw the text and then have the code examine the result. I didn't mean a human eyeball test!

Font Selection for Form Application

I am bit confused about chosing font for my winform application.
I want to chose a font which will go smoothly on Win7/XP/Vista. My application has been designed with windows Office2007 like bluish theme, and also has future requirement about provision for selecting other standard themes.
Currently all my user controls/forms and all other controls have arial fond. But it doesn;t look cool.
Can anybody know any good tricks/tips to chose a smart font for winapp?
Or are there any guidelines to check for cool fonts for your apps?
Please suggest.
Thanks in advance,
Kapil
There's a bug in Winforms [2008] where the default system font is not used. See this question and this post for more info, but the trick is to set the default app font to SystemFonts.MessageBoxFont which will give the correct system font. Make all your forms and controls inherit this, and the app will use the system font.
Use the system default. In Windows Vista and 7 that would be Segoe UI. It makes your app look consistent in the rest of the OS; otherwise, it will just stand out, and not always in a good way.

C# - Create font from image or set of images

The title really says it all. I need help in creating a custom font from either a set of separate image files or from one image with a series of characters setup in a grid fashion in C#. I have searched everywhere and haven't found any useful resources on the subject. If you have any advice, thanks in advance.
As far as I have read, there is nothing within the C# framework that allows for the creation of a font, by the looks of it you will have to implement this on your own. Microsoft of course puts out some tools and a SDK for font creation, here along with other information here There are several tools outside of Microsoft that will allow you to create fonts aswell, for example this. I'm sure this isn't quite what you are looking for but it's a start.
This was something that was done 20 years ago, before freely scalable outline font technologies like TrueType became available. Some of these fonts are still on your machine, the .fon files in c:\windows\fonts. They actually contain bitmaps of the letters in the font, usually around 256 of them for each individual font height supported by the font.
Support for these fonts is not present in .NET so don't consider creating one of them. In general, the disadvantages of not using a TrueType font are:
only available in certain point sizes
no decent Unicode support
different code pages require different fonts
no support for kerning and glyph overhang
no anti-aliasing support
no ClearType support
Tools are available to create your own TrueType font. It is not exactly easy to get right, one of the things that makes TrueType shine is 'hinting', altering the letter shapes when they font is rendered at small point sizes so that they are still legible. Verdana is a exemplary font that is hinted extraordinarily well.
Anyhoo, to pursue your approach you'll need to create a bitmap that contains all the letters that you are willing to support, arranged horizontally for example. The best way to order them is to pick the letters in a code page that's close to you, like Windows 1252 which is common in Western Europa and the Americas.
Things are simple if the font is fixed-pitched, every letter will start at a multiple of the letter width. A proportionally spaced font requires a separate lookup table that specifies at what pixel offset each letter starts. Using System.Drawing for example, you'd use the Graphics.DrawImage(image, rectangle, rectangle, graphicsunit) overload where you setup the rectangles so that the letter you want to render is copied. Use Encoding.GetBytes() to convert the string to render to indices in your font bitmap.

Font linking in the registry

A few years back, I created a WinForms application that has been successfully deployed. The next version of the application must support Chinese and Korean characters. For aesthetic reasons, my client wanted all the text in the application displayed with the Arial font family.
However, Arial doesn't support Chinese and Korean characters. On most platforms, the Windows Uniscribe Font Fallback mechanism adequately chooses a font to display the East Asian characters. But on English Windows XP, the font it picks is terrible.
I've been looking at resolving this problem with Font Linking. This would allow me to specify which font should be used when Arial can't display a character. This seems like a very elegant solution.
The problem is that the article I linked to says that adding font links through the registry is not officially supported. Also, changing the font links in the registry would impact the whole computer and not just my application.
Does anyone have experience with added font links? Did it work? What are the situations that are going to bit me later?
The "not supported" clause in the linked article is telling you that you can't call Microsoft Support and complain because you used Regedit.exe incorrectly and messed up the machine. It doesn't say that font linking isn't supported.
You can't really affect another program negatively by doing this. Font linking doesn't replace glyphs, only substitute missing ones. Such a program would previously not render text correctly. It will show readable text after you're done. They'll buy you a very nice dinner and some dancing girls.
Can you use the font Arial Unicode MS?
That's what I use to display Chinese fonts in charts and PDFs.
So, the problem is that you want to use one font if the characters match some criteria, and another font if they don't, right?
So, why not just write some code that, when the text is updated, checks the criteria and sets the font appropriately? It may be a little bit of busy work, but if it's done all over the place I bet you could encapsulate it in a custom control.
Sometimes it's a lot easier to just do the work than to try and get clever with a bunch of system settings. Not as fun, admittedly, but less likely to cause problems.

Categories

Resources