Getting all of the localized names of a font[.NET]

by Michael S. Kaplan, published on 2007/01/22 03:01 -05:00, original URI:

It was not quite a year ago that I delved into the OpenType standard to look into Getting all of the localized names of a font.

If you are trying to solve the problem from .NET, it turns out the problem is a bit easier to solve since GDI+ is doing most of the heavy lifting for you. Something simple like this?

using System;
using System.Text;
using System.Drawing;
using System.Globalization;

namespace Testing {
    class test {
        static void Main(string[] args) {
            if(args.Length == 0) {
                Console.WriteLine("You must pass a font name.");
            } else {
                foreach(string st in args) {

        static string DumpFontNames(string stFontName) {
            StringBuilder sb = new StringBuilder();
            FontFamily ff = new FontFamily(stFontName);

            foreach(CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) {
                string st = ff.GetName(ci.LCID);
                if(! ff.Name.Equals(st, StringComparison.OrdinalIgnoreCase)) {

Now before you run it you'll want to "chcp 65001" in your console window, but once you do that you'll be able to get all of the localized names that are available in the font, without having to dig into OpenType tables.

It is hard to deny that this is a lot less work....

Special things to note -- the use of OrdinalIgnoreCase comparisons to find the unique names (this is okay given the case insensitivity of font names following the OS casing rules, though is likely not completely necessary given the lack of font name localizations that only vary in case!) as I have never seen, as well as the FontFamily.GetName method that is doing the hard work here.

On the other hand, writing this code wasn't as much fun as the code in the original sample, if you know what I mean. Not sure I want to see the analysis of the reasons for that! :-)


This post brought to you by ゴ (U+30b4, a.k.a. KATAKANA LETTER GO)
(A character used in the font name MS ゴシック)

no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2011/09/13 "It was an honest mistake -- I'm not running NT4; I'm just in Hong Kong!"

2008/07/11 On installing and removing fonts, Part 4: The easiest part is the addition!

go to newer or older post, or back to index or month or day