Rhymes with Amharic (a.k.a. How about a little breakfast embed, dear?)

by Michael S. Kaplan, published on 2007/04/14 03:40 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2007/04/14/2128198.aspx


I have a lot of ideas for blog posts that are on my generic "to do" list.

In fact, any time someone suggests a potential topic these days, I already had the topic on my list of things to cover some day....

I was looking at my blog summary page a moment ago and I realized that this is going to be blog post #1708.

Apropos of nothing, you might be thinking. But I'll explain why this was interesting to me.

You see, I tend to think that there are a few core posts that I do which have a lot more to do with real influencing/assistance, like The jury will give this string no weight or the Converting a project to Unicode series or the Private fonts: for members only post or the Getting all you can out of a keyboard layout series.

I have been building this one up in my mind for a while now -- in fact, since I first talked about it last year in Font embedding -- the intro: a sample that really shows how font embedding can work. I hadn't gotten to it yet, but it was on the list.

Then a few days ago Scott Hanselman asked me:

I’ve seen the Custom Culture stuff, but I’m wondering if anyone’s done a sample (and with what font) showing Amharic on Vista? I’d like to post about it and enable some Ethiopians.

I had to remind him that we actually added Amharic as a locale to Vista (as I sometimes have to do with Scott!), and it did suggest to him something that really might be important:

Hm…I’ll try making a WinForms app in Amharic…I’ll let you know. Since Vista [h]as am-ET I guess we don’t need it…although, it’d be nice to talk about how to write a WinForms app that is ONE SOURCE, TWO OS’s. Meaning, it would know what to do on XP vs. Vista. Can we copy the font over to XP?

That “straddling” sample would be VERY valuable for those languages that were added in Vista.

Now copying the font file for Nyala is indeed a violation of the EULA, even to another Windows box. But it suddenly occurred to me that this might be the perfect time to provide a font embedding sample!

After a bunch of work between other work and meetings and email and such (and by the way special thanks to Sergey Malkin and David Brown for their assistance here!).

Warning: do not violate the license for any font file from Microsoft or any other source. You can use the licensing information in the Font Properties Extension to find out if you are allowed to do it!

First a few gratuitous screen shots of the sample, on Vista (with higher DPI settings):

and on Server 2003 (which does not have the font or the locale or anything, and with ClearType turned off):

and on XP SP2 (again without the font or the locale or anything, and with ClearType turned on):

Notice how the bottom TextBox control does not show the text on the platforms that do not have the font, while all of them can display the text in that one on top.

And in fact if you used a custom culture to add am-ET, also known as Amharic (Ethiopia) or አማርኛ (ኢትዮጵያ), one can get even more of the support running on both platforms, just as Scott was hoping for!

Ok, enough with the build-up, let's jump in....

You can download the project from here. It basically relies on a few of the font embedding API functions:

The sample was a bit more involved as it had to make use of the PrivateFontCollection class to load the font within WinForms, because the load is only valid within the process but GDI+ does not load any font that is not known to it at the time it has started up. Luckily, by using a technique similar to the one I used in Private fonts: for members only, you can load up the font that is ready to go in GDI/Uniscribe and cause it to be available to your managed application controls as well!

The logic is:

NOTE: The sample download does NOT include the binary file containing the embedded font file. To get that file you have to run the sample on Vista and it will create a ~150kb file named "NyalaSIAO.bin" in the same directory as the EXE. From there you can put the EXE and the .BIN file on the downlevel machine and display Amharic in your application to your heart's content, provided you are just using it in your application.

In the real world you probably would not set up your application the way I did the sample -- you would probably embed the font as a resource like that font about private fonts did, and you'd likely only create it during development, not on the user's machine later. But it should be enough to get you started....

I will talk more about the code soon (and the embedding support and what happens with it) in an upcoming post. :-)

And I'll probably do an unmanaged sample too, at some point. Because I knew even 15 years ago that when someone at Microsoft talks about how easy something is to use, if they provide no samples for it, even after years pass, that we might well be full of crap and that it is hard.

 

This post brought to you by (U+12a2, a.k.a. ETHIOPIC SYLLABLE GLOTTAL I)


# orcmid on 14 Apr 2007 2:08 PM:

This is fascinating.  It is a great example of the dependence of successful transformations on small details too (like comparing resampled GIFs that were produced by different apps from the same vector-graphic original).

I notice two things here.  First, the impact of Cleartype is amazing.  Secondly, the Vista rendering seems fuzzy somehow and not as crisp as the XP SP2 Cleartype.  I realize the sizes are different, with different assumed resolutions, but the subjective experience at scale is important.  (I think I see this on my Vista-equipped Tablet PC too, so I really wonder ... )

If you use the same DPI, how well does Vista match the XP Cleartype case?

# Michael S. Kaplan on 14 Apr 2007 3:02 PM:

Well, the Vista machine happened to be running at 134 DPI, which does warp the perspective a bit. :-)

(I was looking at a dfifferent issue at the time!)

When they match, the results are actually about the same to the untrained eye....

# Scott Hanselman on 14 Apr 2007 3:10 PM:

Great stuff...just an FYI, the code download is missing a number of resource files and what not, and I had to manually edit the csproj to remove those in order to get it to build.

Thanks for doing this series, Michael.

Thanks...Betam amessagganalehugn...አመስግናለሁ

# Michael S. Kaplan on 14 Apr 2007 3:18 PM:

Whoops, forgot that pesky property dir. Fixed now....

Always a pleasure. :-)

# Yosias on 24 May 2007 7:38 AM:

Greetings here in Addis we have heard of Vista but very few use it. So what is the use ny friends? XP is what most have loaded but we want the Vista feature of locale and Ethiopic font back loaded into XP. Otherwise it is loading another keyboard software such as Keyman etc...Is it possible I do not know much about Locales and all but whatever that wachamacallit in Vista that does all the Ethiopic stuf to be ripped out from VIsta and loaded into XP? HELP

# Michael S. Kaplan on 24 May 2007 7:54 AM:

Hi Yosias,

I hate to say it, but upgrading does have its privileges. And support of custom locales was a ton of work which as far as I know there are no plans to backport. Maybe it is worth looking into a copy of Vista?

# Yosias on 30 May 2007 5:10 AM:

Greeting Michael

Thank you for your response. Yes definitely I agree with you in that upgrading to Vista does have its privileges. But upgrading is not an option for most here in Addis (Ethiopia). I invite you to come and see for yourself what I mean, the hardware situation in Addis and elsewhere unless it is some big business most common folks at least 70% use XP and the rest use Win 95, 98, Win2k, seriously. So if Microsoft really wants to serve the needs of folks here in Addis (Ethiopia) they definitely have to plan according to these numbers, I would say. Do you agree? It sure would be nice if they thougt about backporting.

Thanks again!

# Michael S. Kaplan on 30 May 2007 12:33 PM:

I am not on the NLS team anymore, so I can't say what the backport decision would be, for sure. But I know what the cost would be, so I know it is unlikely....

Given what it would break to add things like collation support downlevel, I can't say I agree (breaking active directory worldwide to enable a small market to not have to buy a new OS is a high price to pay!).

But the whole point of this post is that a developer can use the knowledge to create an application that uses a script such as Ethiopic and propely display the strings -- it is an enabling post!

# abebe on 1 Dec 2009 4:42 AM:

i have give to the letter ih amharic.

doron on 30 Apr 2011 11:19 AM:

why so much A strive! write your amharic pages in any editor and save it as image file and upload it to your web server!that is it!it worked perfectly to me so long! every body with windows and with out windows ,all will see the selected font.what is wrong with this method and,why people search for WEFT!i like to hear from you.i donot see any reason for one e-mail even!my pages download with out any delay!!!

no need  EULA UVULA OR ANY thing ELSE.

thank you

Michael S. Kaplan on 30 Apr 2011 11:48 AM:

Images are not search-able, and they do not scale as well. They do not allow one to copy/paste text or edit it. Consigning a language to images only is to make a language a second-class citizen. And I simplyu can't support that as anything but an interim plan.


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

2013/10/23 I finally got to meet ali eteraz in person...

2007/12/12 SiaO as The Red Carpet (aka Characters just want to be seen)

2007/04/15 Rhymes with Amharic #5 (a.k.a. [Sub]setting up this code where it can do the most good?)

2007/04/14 Rhymes with Amharic #4 (a.k.a. we're all [sub]set so turning out the lights and going to [em]bed!)

2007/04/14 Rhymes with Amharic #3 (a.k.a. Read and write a language w/o even getting out of my [em]bed? Kewl!)

2007/04/14 Rhymes with Amharic #2 (a.k.a. Before you embed, you have build something to embed)

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