Mi blog lah! Το ιστολόγιό μου

10May/097

How to type Greek, Greek Polytonic in Linux

Update 2010: Please see the docs.google.com edition of the guide as it has the latest material. See link below.

There is a new guide on how to write Greek and Greek Polytonic in Linux, and in particular using the latest versions of Linux distributions.

https://docs.google.com/View?docID=dccdrjqk_4cqjn9zcj (LATEST VERSION)

The guide shows in detail how to add the Greek keyboard layout to your Linux desktop, and how to write Greek, Greek Polytonic and other Ancient Greek characters.

The guide is also available in both ODT and PDF format. (both files are somewhat obsolete. use google docs URL from above instead)

For a Greek version of the guide, please see http://docs.google.com/Doc?id=dccdrjqk_3gx3bq5f9 (does not update as often as the English version)

We attach the HTML version of the guide in this post. The docs.google.com version is the latest, please read that instead.

Again, you can find the latest version of this document at
http://docs.google.com/Doc?id=dccdrjqk_4cqjn9zcj
15Mar/080

How to easily modify a program in Ubuntu (updated)?

Some time ago we talked about how to modify easily a program in Ubuntu. We gave as an example the modification of gucharmap; we got the deb source package, made the change, compiled, created new .deb files and installed them.

We go the same (well, similar) route here, by modifying the gtk+ library (!!!). The purpose of the modification is to allow us to type, by default, all sort of interesting Unicode characters, including ⓣⓗⓘⓢ , ᾅᾷ, ṩ, and many more.

The result of this exercise is to create replacement .deb packages for the gtk+ library that we are going to install in place of the system libraries. Because these new libraries will not be original Ubuntu packages, the update manager will be pestering us to rollback to the official gtk+ packages. This is actually good in case you want to switch back; you will have the enhanced functionality for as long as you postpone that update.

There is a chance we might screw up our system, so please make backups, or have a few drinks first and come back. I take no responsibility if something bad happens on your system. If you are having any second thoughts, do not follow the next steps; use the safer alternative procedure. You may try however this guide just for the kicks; up to the dpkg command below, no changes are being made to your system.

We use Ubuntu 7.10 here. This should work in other versions, though your mileage may vary.

The compilation procedure takes time (about 30 minutes) and space. Make sure you use a partition with >2GB of free space. We are not going to use up 2GB (a bit less than 1GB), but it’s nice not to fill up partitions.

We are going to use the generic instructions on how to recompile a debian package by ducea.

First of all, install the development packages,

sudo apt-get install devscripts build-essential

Next, we use the apt-get source command to get the source code of the GTK+ 2 library,

cd /home/ubuntu/bigpartition_over2GB/
apt-get source libgtk2.0-0

We then pull in any dependencies that GTK+ may require. They are normally about a dozen packages, but we do not have to worry for the details.

apt-get build-dep libgtk2.0-0

At this stage we need to touch up the source code of GTK+ before we go into the compilation phase. Visit the bug report #321896 – Synch gdkkeysyms.h/gtkimcontextsimple.c with X.org 6.9/7.0 and download the patch (look under the Attachment section). You should get a file named gtk-compose-update.patch. If you have a look at the patch, you will notice that it expects to find the source of gtk+ in a directory called gtk+. Making a link solves the problem,

ln -s libgtk2.0-0 gtk+

We then attempt to apply the patch (perform a dry run), just in case.

patch -p0 --dry-run < /tmp/gtk-compose-update.patch

If this does not show an error message, you can the command again without the –dry-run.

patch -p0 < /tmp/gtk-compose-update.patch

Finally, we are ready to build our fresh GTK+ library.

cd libgtk2.0-0
debuild -us -uc

This will take time to complete, so go and do some healthy cooking.

At the end of the compilation, if all went OK, you should have about a dozen .deb files created. These are one directory higher (do a “cd ..“). To install, use dpkg,

dpkg -i *.deb

If you have any other deb files in this directory, it’s good to move them away before running the command. If all went ok, the .deb files should install without a hitch.

The final step is to restart your system. To test the new support, see the last section at this post. Use Firefox and OpenOffice.org to type those Unicode characters.

If you managed to wade through all these steps, I would appreciate it if you could post a comment.

Good luck!

3Feb/082

Typing squiggles and dots in GNOME and GTK+ applications

Garrett asks how to type squiggles and dots in GNOME; that is, how to type characters such as á à ä ã â ą ȩ ę ő ǰ ǩ ǒ ġ ṅ ȯ ṁ ė.

There are several ways, and one can choose depending on how frequently they need to type them or how much time they need to invest learning.

① One option is to start the Character Map (Applications/Accessories/Character Map), pick the character, copy and paste it. This is good for rare characters and weird situations such as

┏━━━━━━━━━━━━━━━━━━━━━━━┓

⟁⟁⟁⟁♥♀★★▶◀☆♀░░░▒▒▒▓▓▓▙▚▛▙▙▙▞

The Unicode standard, apart from defining characters for languages, it also defines symbols, dingbats and all sort of things. If your distribution is based on the DejaVu fonts (such as Ubuntu), then you are probably covered for many of these symbols. If you do not have a suitable font, or you use Windows, you will be wondering what the hell I am talking about.

② Another option is to use the Character Palette applet which shows an applet on the panel with a configurable small repertoire of characters such as áàéíñó½©ث€. You select one of the characters with the mouse, and wherever you middle-click, this character is typed. This is an improvement over ①, and good when you want to type often rare characters. It is not convenient to type characters found normally on a keyboard layout.

③ To type characters normally found in a specific language(s), it is good to setup a suitable keyboard layout. For this, it is good to add the Keyboard Indicator applet; right click on the panel, click Add to panel… and choose the Keyboard Indicator from the Utilities section. The US English keyboard layout (Default variant) does not provide any interesting characters apart from those shown printed on the keys of a US Keyboard.
Keyboard layout US Intl with dead keys
The US English International (with dead keys) variant might be a better option,

Keyboard layout GB

Or the United Kingdom layout.

You can get a similar image for your layout when you right-click on the Keyboard Indicator applet, then click Show Current Layout.

Each key in the images contain up to four letters. Starting from bottom-left and going clock-wise, these are the keys produced when

ⓐ you press the key

ⓑ you press the key with Shift (or Caps Lock)

ⓒ you press the key with AltGr and Shift (or Caps Lock)

ⓓ you press the key with AltGr

For example, with the UK keyboard layout, the key G produces g, G, Ŋ, ŋ.

If AltGr + Shift + letter does not work for you, see the FDO Bug #2871 Different results for shift-altgr and altgr-shift.

Using the appropriate keyboard layout is the way to go when writing text that require squiggles. You can either choose a layout with dead keys (meaning that some keys lose their normal functionality), or you can pick a layout that still allows you to have dead keys but are available when you press AltGr + key. For example, in the UK Keyboard layout – Default variant, AltGr + ; + a produces á, or AltGr+Shift+]+e produces ē.

OLPC showing the keyboard

Photo by titanas.

The OLPC uses those four level for the keyboard layout. You can see the all the variations printed on the keyboard. Click on the image, choose Large size for the details.

④ Another option to produce more characters on the keyboard is to enable the compose key, and use compose sequences. A compose sequence looks similar to what we described above (i.e. AltGr+Shift+]+e to ē) but the idea is that we use it for characters we want to be available across different keyboard layouts that you may have enabled.
Configuring the compose key
The compose key is very powerful functionality, thus it is not enabled by default, and lays hidden in the Layout Options tab. I prefer to set it to Menu, but every person has their own preference.

For example,

  • Compose key + – + a produces ã,
  • Compose key + < + c produces č
  • Compose key + 1 + s produces ¹ (Superscript on 1. Try to replace 1 with 2.)
  • Compose key + + + – procudes ±

Currently, GTK+ provides 640 such compose sequences involving the Compose key, and hopefully soon it will increase to over 3000.

The Compose key is known as Multi_key in the source code (Xorg, GTK+, etc).

The Compose key compose sequences offer the ability to define smart mnemonics on how to produce characters. It is much easier to type ComposeKey + 1 + s rather than remembering the codepoint value of ¹ (1 superscript). As with many things open-source, there are too many options, and with the Compose key there is the issue of which shall we pick as a sensible default, and how to make it prominent for those who might want to use it.

It appears to me that there should be more effort to promote the functionality that is provided with the standard keyboard layouts (choose a better keyboard layout, produce characters provided in the third and fourth levels, etc). In this respect, Compose key compose sequences should complement after the main discussion on keyboard layouts take place.

⑤ There is a last issue on switching keyboard layouts to cover in a separate post.

30Jan/084

Improving input method support in GTK+-based apps

When a bug report gets long with many comments, it gets more difficult for someone to get the full picture of what is going on. I’ll attempt to summarise here what’s being said in Bug 321896, Synch gdkkeysyms.h / gtkimcontextsimple.c with X.org 6.9/7.0.

GTK+-based applications use by default the GTK+ Input Method in order to let users type in different languages. Some scripts are very complex (such as SE Asian scripts) and in this case SCIM is used, replacing the GTK+ Input Method. One can even disable GTK+ IM altogether and use the basic X Input Method (XIM) which is provided by the Xorg server, by setting GTK_IM_MODULE to xim. However, the majority of the users have GTK+ IM enabled.

Between GTK+ IM and XIM, the keyboard layouts are being managed by the xkeyboard-config project and Sergey Udaltsov. A keyboard layout is simply a mapping of keyboard keys to Unicode characters, but you can also have compose sequences for some characters using what we call dead keys. When you press a dead key nothing appears on screen but when you press a letter immediately afterwards, you can get an á. This functionality is common to add accents, and there is a big table for these compose sequences (1.3MB) and what Unicode characters they produce.

If you change your keyboard layout (System/Preferences/Keyboard/Layout) to something like U.S. English International (with dead keys), then the ‘ key on your keyboard becomes dead_acute, and the compose sequence

<dead_acute> <a>  : "á"   U00E1 # LATIN SMALL LETTER A WITH ACUTE

works when you press and then a.

There is an issue with compose sequences and input methods; XIM maintains the official upstream version of the compose sequences, and projects such as GTK+ and SCIM carry their own copies of that table.

The issue with GTK+ regarding the compose sequences is that it has a very old version compared to what is available upstream. This is what Bug 321896 is about.

The bug would be have been resolved much much earlier if it wasn’t for the insistence of the GTK+ maintainers to cut the fat and reduce the size of the table (~6000 entries) with clever optimisations.

Tor suggested a clever optimisation; a good number of compose sequences (which looks like <dead_acute> <a> : “á”) resemble the decomposed form (a la Unicode) of those characters. Thus, we can let the user type what she wants, and we can try Unicode normalisation to see if the sequence is composed to a single Unicode character. Lets demonstrate in Python,

$ python
>>> import unicodedata
>>> sequence=[65, 0x301]     # That's 'a' and acute
>>> result = unicodedata.normalize('NFC',"".join(map(unichr, sequence)))
>>> result
u'\xc1'
>>> print len(result)
1
>>> print result
Á

That long line above takes the array, applies the unichr() function on each member so that they become Unicode characters and then joins them in a single string. Finally, it normalises the (decomposed) string to a single character. The fact that the resulting string has length 1 (single character) is key to this optimisation. Over 1000 compose sequences can be removed from the compose table through this optimisation. This includes a big chunk of the Latin Unicode blocks, about a few dozens of Cyrillic characters, all of modern Greek and Greek polytonic, some Indic languages (are they actually used?) and other misc sequences.

Matthias laid out the requirements for the optimisation of the remaining compose sequences; ① it has to be static const so a single copy is shared all over the place, ② the first column (out of six) is repeated too often, thus use subtables, and ③ each row ends with a varying number of zeroes, so cut on those zeroes as well. This also required the automatic generation of the optimised table using a script.

The work has not finished yet, and requires testing of the patch. The high priority testing is that keyboard layouts do not get any regressions (that is, compose sequences with dead keys must continue to work along with any new sequences).

With an updated compose table in GTK+, one can write things like ⒼⓃⓄⓂⒺ and all variations of accents on characters, in an easier way.

I’ld like to thank Matthias and Tor for their support in this work. And Jeff for adding this blog to Planet GNOME!

29Mar/070

Convert your legacy font to Unicode

There exist quite a few legacy fonts, from the time that 8-bit-style encodings was the norm. Nowdays, most (if not all) spoken and ancient scripts have been added to the Unicode standard.
Therefore, if you have a legacy font, you can convert to Unicode using a guide by William J Poser. The guide uses Linear B as an example.

The program mentioned in the guide is pfaedit, which is now known as FontForge. FontForge is available in your Ubuntu distribution; simply search using the package manager.

Once you have a Unicode font, the next step is to prepare an input method so that you can write in this script. But that’s another blog post.

2Jun/060

Keyboard updates in Xorg

There have been a few updates in Xorg regarding the multilingual keyboard support.

First, a new dead key has been added for Finish, dead_stroke. It appears that Cyrillic would find it useful as the available dead keys are too few to be reused in this case. The moral of the story is that if you want to add a dead_key, justify the necessity and it can be added.
Second, the Compose file nls/en_US.UTF-8/Compose.pre has been updated so that any Unicode keysyms have a value over 0×100000 (if keysym is Unicode keysym and had value < 0x100000, add 0x100000 to its current value). You will not see the change in the previous URL (which shows that CVS only); the updated Compose file is in git.

Third, there was an addition of the Braille input method which closed bug #6296. Braille is already available in the Unicode standard.

Thanks to Daniel Stone for going through these patches.

To get your daily fix on changes applied to Xorg, see the web-based interface to git.

Update (6Feb07): The new location of the compose file is http://gitweb.freedesktop.org/?p=xorg/lib/libX11.git;a=tree;f=nls

16Feb/061

Ανατομία ενός γράμματος

Με ενδιαφέρον είδα μια συζήτηση (τίτλος upgrade σε ubuntu 5.10 = προβλήματα με τα ελληνικά) στη λίστα συνδρομητών Linux-greek-users για το θέμα της υποστήριξης γραφής ελληνικών σε ελεύθερο λογισμικό.
Ωστόσο, μετά από λίγα γράμματα, στάλθηκε

11Jul/05Off

IOSN: FOSS Guide to Localization (PDF, 10.8MB)

Μετά το Free/Open Source Software Localization Primer, το International Open Source Network (IOSN) εκδίδει το FOSS Guide to Localization.

Ο οδηγός αναλύει την διαδικασία τοπικοποίησης λογισμικού αρχίζοντας από τα απολύτως βασικά όπως locale, κωδικοποιήσεις χαρακτήρων, γραμματοσειρές και δημιουργία γραμματοσειρών, μέχρι περίπλοκες έννοιες όπως Μεθόδους Εισαγωγής (Input Methods) και μεταφράσεις με το σύστημα gettext.

Σελίδα Διάθεσης: FOSS Guide to Localization

Άδεια Διάθεσης: Creative Commons Attribution 2.0

22Jun/05Off

Βοήθεια: Προσθήκη υποστήριξης πολυτονικού σε gtk+

Με τη χρήση του GTK+ Input Method δεν είναι ακόμα δυνατόν να γράψει κάποιος αρχαία ελληνικά, όπως περιγράφει το σφάλμα #167940. Μια κακή λύση είναι να αλλάζει ο χρήστης το σύστημά του και να καθορίζει σε μια μεταβλητή περιβάλλοντος να προσπερνάει το καθεαυτού GTK+ IM και να χρησιμοποιεί το X Input Method (ΧΙΜ).

Η ουσία του προβλήματος είναι στην δήλωση των συνδυασμών πλήκτρων που παράγουν τους χαρακτήρες με τα τονικά σημάδια. Γίνεται χρήση των λεγόμενων νεκρών πλήτρων (δηλαδή πατάς ένα τέτοιο πλήκτρο, δεν εμφανίζεται τίποτα, πατάς το α και εμφανίζεται ά) και αυτοί ακριβώς οι συνδυασμοί πρέπει να καταγραφούν.

Αυτό που χρειάζεται να αλλάξει δεν απαιτεί πολλές προγραμματιστικές γνώσεις. Απλά χρειάζεται να ενημερωθεί
το σχετικό αρχείο cvs://GNOME/gtk+/gtk/gtkimcontextsimple.c,
με τους νέους συνδυασμούς για τονικά σημάδια που υπάρχουν στο πολυτονικό (αρχείο Compose, κάπου στο http://cvs.freedesktop.org/).

Εκτός από την υποστήριξη για πολυτονικό, υπάρχει μια εκρεμμότητα για το μονοτονικό, και συγκεκριμένα με το θέμα της άνω τελείας. Εδώ κανονικά πατάμε ; και μετά . και έχουμε άνω τελεία. Πρέπει να δηλωθεί όμως.

Το πρόβλημα είναι πιο σοβαρό και ουσιαστικό στις εφαρμογές που βασίζονται στο GTK+ και είναι διαθέσιμες σε Windοws. Τέτοια παραδείγματα είναι τα GIMP και Inkscape.

Ένα πολύ όμορφο υπόδειγμα αναφοράς σφάλματος πάνω στο θέμα αυτό είναι η αναφορά σφάλματος #164859 και επίλυση της
από τον Daniel Atallah, που έβαλε τους κατάλληλους συνδυασμούς για το μονοτονικό, για τα ϊ, ϋ, ΐ και ΰ.

Αυτό το έργο είναι διαθέσιμο για όποιον μπορεί να το αναλάβει. Τώρα είναι η κατάλληλη ώρα να γίνει.

22Feb/05Off

Οδηγός Τοπικοποίησης Ελεύθερου Λογισμικού

Το IOSN χρηματοδότησε τη δημιουργία οδηγού για την τοπικοποίηση ελεύθερου λογισμικού.
Ο οδηγός δεν είναι ακόμα έτοιμος αλλά μιας και το Google τον βρήκε, σας αποκαλύπτω τη διεύθυνση του Οδηγού Τοπικοποίησης.

Περιλαμβάνει μιας σειρά από πληροφορίες όπως κωδικοποιήσεις χαρακτήρων, locale, γραμματοσειρές, “input methods” (δείτε για IIIMF!), gettext, τοπικοποίηση GNOME, KDE, Firefox και OpenOffice.org, εργαλεία (KBabel, gtranslator), μεταφραστικές μνήμες, και άλλα.

   

Switch to our mobile site