]> git.saurik.com Git - wxWidgets.git/blob - docs/tech/tn0018.txt
extracted the part of ProcessEvent() which is repeated multiple times during the...
[wxWidgets.git] / docs / tech / tn0018.txt
1 How to add a new font encoding to wxWidgets
2 ===========================================
3
4 I. Introduction
5 ---------------
6
7 wxWidgets has built in support for a certain number of font encodings (which
8 is synonymous with code sets and character sets for us here even though it is
9 not exactly the same thing), look at include/wx/fontenc.h for the full list.
10 This list is far from being exhaustive though and if you have enough knowledge
11 about an encoding to add support for it to wxWidgets, this tech note is for
12 you!
13
14 A word of warning though: this is written out of my head and is surely
15 incomplete. Please correct the text here, especially if you detect problems
16 when you try following it.
17
18 Also note that I completely ignore all the difficult issues of support for
19 non European languages in the GUI (i.e. BiDi and text orientation support).
20
21
22 II. The receipt
23 ---------------
24
25 Suppose you want to add support for Klingon to wxWidgets. This is what you'd
26 have to do:
27
28 1. include/wx/fontenc.h: add a new wxFONTENCODING_KLINGON enum element, if
29 possible without changing the values of the existing elements of the enum
30 and be careful to now make it equal to some other elements -- this means
31 that you have to put it before wxFONTENCODING_MAX
32
33 2. wxFONTENCODING_MAX must be the same as the number of elements in 3
34 (hopefully) self explanatory arrays in src/common/fmapbase.cpp:
35 a) gs_encodings
36 b) gs_encodingDescs
37 c) gs_encodingNames
38
39 You must update all of them, e.g. you'd add wxFONTENCODING_KLINGON,
40 "Klingon (Star Trek)" and "klingon" to them in this example. The latter
41 name should ideally be understandable to both Win32 and iconv as it is used
42 to convert to/from this encoding under Windows and Unix respectively.
43 Typically any reasonable name will be supported by iconv, if unsure run
44 "iconv -l" on your favourite Unix system. For the list of charsets
45 supported under Win32, look under HKEY_CLASSES_ROOT\MIME\Database\Charset
46 in regedit. Of course, being consistent with the existing encoding names
47 wouldn't hurt neither.
48
49 3. Normally you don't have to do anything else if you've got support for this
50 encoding under both Win32 and Unix. If you haven't, you should modify
51 wxEncodingConverter to support it (this could be useful anyhow as a
52 fallback for systems where iconv is unavailable). To do it you must:
53 a) add a new table to src/common/unictabl.inc: note that this file is auto
54 generated so you have to modify misc/unictabl script instead (probably)
55 b) possibly update EquivalentEncodings table in src/common/encconv.cpp
56 if wxFONTENCODING_KLINGON can be converted into another one
57 (losslessly only or not?)
58
59 4. Add a unit test (see tn0017.txt) for support of your new encoding (with
60 time we should have a wxCSConv unit test so you would just add a case to
61 it for wxFONTENCODING_KLINGON) and test everything on as many different
62 platforms as you can.
63
64
65 === EOF ===
66
67 Author: VZ
68 Version: $Id$