At Last! Pango Fix (which breaks compatibility)
Friday, June 10th, 2005Wow… after what seemed like 10 hours in front of the monitor non-stop, I’ve actually "fixed" it! What’s the problem? It’s that text is not rendered correctly by Pango (well, at least IMO). So, text like:
123
will be rendered with the Chinese font (which is ugly for non-Chinese characters), but
123abc
will be rendered with the English font. It’s VERY ANNOYING when you type a lot of smilies (hint: I’m on YM), because the first characters used in most smilies happen to be in the same category as "numbers", that is, they are in the "Common" script in the Unicode table. So for example for the smily :-P, the ‘:-’ will be rendered in the Chinese font at first, until I type ‘P’, which makes it ‘:-P’, which then has a derived_lang of "en" (because ‘P’ is in the "Latin" script), and then the whole thing would be rendered in English. Staring at animated cursors (back when I was using Windows) wasn’t exactly my favourite pastime, so looking at changing-font-text isn’t either.
According to the Unicode documents, to determine the language of (a block of) characters in the "Common" script, we look at the surrounding characters. So, when we type:
a1;"(#@
we actually get the Vera font (which is nice for English characters). But if we type:
a啊1;"(#@
the ‘a’ at the start of the line is rendered in Vera, but the rest of the line is in FireflySung (the Chinese font). Also, since I use LC_CTYPE=zh_CN, the default language would be zh-cn, which means that characters in the "Common" script are rendered as Chinese characters, even when they really are supposed to be English.
I don’t know why the Unicode Consortium put part of the ASCII characters in the "Common" script (all of ASCII except for a-z and A-Z are in "Common"), but I don’t like it. It’s just ugly.
So here’s the patch (feel free to try it, and tell me (just comment or send me a message or email or whatever) whether you like it or not):
--- pango-1.8.0/pango/pango-script-table.h 2003-08-04 05:57:33.000000000 +0800+++ pango-1.8.0/pango/pango-script-table.h 2005-06-11 03:59:21.000000000 +0800@@ -10,8 +10,21 @@ guint16 chars; guint16 script; /* PangoScript */ } pango_script_table[] = { +/* So we're INCOMPATIBLE with the rest of the world,+ but so what? The rest of the world is UGLY */+/* Let's be somewhat courteous with #ifdef's */+#define PRETTY_BUT_INCOMPATIBLE 1+#if PRETTY_BUT_INCOMPATIBLE+ { 0x0020, 33, PANGO_SCRIPT_LATIN },+#endif { 0x0041, 26, PANGO_SCRIPT_LATIN },+#if PRETTY_BUT_INCOMPATIBLE+ { 0x005b, 6, PANGO_SCRIPT_LATIN },+#endif { 0x0061, 26, PANGO_SCRIPT_LATIN },+#if PRETTY_BUT_INCOMPATIBLE+ { 0x007b, 4, PANGO_SCRIPT_LATIN },+#endif { 0x00aa, 1, PANGO_SCRIPT_LATIN }, { 0x00b5, 1, PANGO_SCRIPT_GREEK }, { 0x00ba, 1, PANGO_SCRIPT_LATIN },
By the way, if the patch looks garbled or you can’t apply it cleanly, just type the changes in yourself, it’s not that much. Screenshots to come.
Update: I’ve uploaded the screenshots. They’re all here as thumbnails because I just can’t figure out how to display the whole images (maybe it’s a problem my browser). Clicking on one the images should give you a popup, though.




