PolygloText 1.0.1 ================= Tamito KAJIYAMA <23 November 2004> Introduction ------------ PolygloText is an experimental add-on script for Skencil (a.k.a. Sketch) that makes it possible to draw multilingual text using the functions of the m17n library. The latest version of this script is available at the following location: http://www.asahi-net.or.jp/~rd6t-kjym/sketch/ Requirements ------------ o The m17n library and database (http://www.m17n.org/m17n-lib/). A working installation of the m17n library and database is essential. PolygloText has been tested using version 1.1.0 of the m17n library and database. o TrueType fonts. The script reads glyph data from TrueType fonts and renders glyph outlines as Bezier curve objects. A number of free TrueType fonts are available on the Net. For more information on free TrueType fonts that can be used with the m17n library, see the comments at the beginning of default.fst in the m17n database. Installation ------------ 1. Build skm17n module as follows: $ python setup.py build_ext -b . -t . 2. Copy polyglotext.py and skm17nmodule.so to ~/.sketch/. 3. Add the following line to ~/.sketch/userhooks.py: import polyglotext How to use PolygloText ---------------------- Select Script -> PolygloText from the menu, and a dialog window opens. In this dialog, you specify the following parameters: - Text: a sequence of characters to be rendered. Press Edit button to launch an external editor. Multilingual text editing in PolygloText's own dialog is quite limited at the moment, so that the script uses "medit" (part of the m17n library) as the default external editor. You can specify a preferred external editor in userhooks.py as follows ("%s" is replaced by a file name): import polyglotext polyglotext.editor = "/usr/bin/yudit %s" (Note: PolygloText assumes that the external editor reads and writes text in UTF-8.) - Lang: a 2-letter language name that indicates the language in which the text is written. For example, "en" is for English, "ar" for Arabic, and "ja" for Japanese. You don't have to specify the language name in most cases, though. The 2-letter language names are defined by ISO 639. See, for example, http://www.unicode.org/onlinedat/languages.html for a list of valid language names. - Family: a name of a font family to be used preferably in the rendering. The name is case-insensitive. - Size: a font size (in points). How to add new fonts -------------------- PolygloText does not have its own mechanism for managing fonts. It fully relies on the m17n library for font management, so that users need to get familiar with the font management in the m17n library. Here is a small tutorial that explains how to install user-specific fonts in PolygloText through the m17n library. We don't assume root privilege in this tutorial. 1. First of all, we create two directories for storing font configuration files and font files. We can freely choose the name and location of one directory. However, the other must be a subdirectory with the name "fonts". We pick up ~/m17n/ as an example. $ mkdir ~/m17n/ $ mkdir ~/m17n/fonts/ 2. We need a font configuration file that describes fonts and related information. The easiest way to create the font configuration file is to copy an existing one and modify it. Find two system-wide font configuration files default.fst and truetype.fst in the m17n database, and copy them into ~/m17n/. $ cd /usr/share/m17n/ $ ls *.fst default.fst truetype.fst xfont.fst $ cp default.fst truetype.fst ~/m17n/ A font configuration file has the extension .fst. We ignore xfont.fst, because PolygloText cannot use X bitmap fonts for rendering. Default.fst is used by the default external editor medit, while truetype.fst is used by PolygloText. 3. Let's suppose that we want to use Arial (arial.ttf) to render English and Arabic texts. Copy the font file to ~/m17n/fonts/. $ cp arial.ttf ~/m17n/fonts/ 4. Edit ~/m17n/default.fst using a text editor. Add two lines as indicated below. (latin (nil ((iso8859-1)) ((iso8859-2)) ((iso8859-15)) ((iso10646-1)) ((iso8859-3)) ((iso8859-4)) ((iso8859-5)) ((iso8859-9)) ((iso8859-10)) ((iso8859-13)) ((iso8859-14)) ((nil arial unicode-bmp)) ;; *** Added *** ((nil freesans unicode-bmp))) : (arabic (nil ((nil arial unicode-bmp) arabic) ;; *** Added *** ((nil riwaj unicode-bmp) arabic-otf) ((nil paktype\ tehreer unicode-bmp) arabic-otf) ((nil paktype\ naqsh unicode-bmp) arabic-otf) ((nil bitstream\ cyberbase unicode-bmp) arabic) ((nil mule iso10646-1) arabic))) 4. Similarly, edit ~/m17n/truetype.fst as follows: (latin (vi ((nil freeserif unicode-bmp)) ((nil freesans unicode-bmp)) ((nil freemono unicode-bmp))) (nil ((nil arial unicode-bmp)) ;; *** Added *** ((nil freesans unicode-bmp)) ((nil freeserif unicode-bmp)) ((nil freemono unicode-bmp)))) : (arabic (nil ((nil arial unicode-bmp) arabic) ;; *** Added *** ((nil riwaj unicode-bmp) arabic-otf) ((nil bitstream\ cyberbase unicode-bmp) arabic))) 5. Define environment variable M17NDIR as follows: $ M17NDIR=$HOME/m17n; export M17NDIR This environment variable tells the m17n library the location in which the user-specific fonts and font configuration files exist. Edit the shell configuration file (e.g. ~/.bashrc) to define the environment variable permanently. 6. Now we can use Arial in PolygloText. Restart Skencil, run the script, and specify the family name "arial" in the dialog window. Both English and Arabic texts are rendered using Arial. If you are less familiar with Arabic, try the next step-by-step instructions: a) Press Edit button and launch medit. b) Select InputMethod -> Arabic. Now you can type in Arabic characters. Change Size if the characters look too small. c) Type "hQgs~QgQhlE uQgQdX;ElX". The sentence to be entered is a greeting in Arabic, meaning "peace be upon you". d) Select File -> Save to store the text, and File -> Quit to go back to the PolygloText dialog. You see some Arabic characters in the Text entry. e) Specify a desired font size (e.g. 100) and press OK button. Voila! You get a group of Bezier curve objects representing the Arabic greeting rendered with Arial. That's it. Enjoy multilingual text drawing in Skencil using PolygloText! History ------- o Version 1.0.1 <23 November 2004> - Fixed a bug that some items at the end of a tuple (created in the skm17n module) were left uninitialized, causing core dump in the Python layer. o Version 1.0 <19 September 2004> - The first public release. License ------- This is free software; you can freely redistribute it and/or modify it under the terms of the GNU General Public License (version 2 or later). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. Use it at your own risk. Author ------ Tamito KAJIYAMA Any comments, suggestions, and/or patches are very welcome. Thank you for using PolygloText!