added a howto for adding a new encoding to wxWin
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26454 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -18,6 +18,7 @@ tn0014.txt XRC resources format specification
|
||||
tn0015.txt How to add new bitmaps to wxWindows UI elements
|
||||
tn0016.txt How to add new files and libraries to wxWindows build system (Bakefile)
|
||||
tn0017.txt How to write unit tests for wxWindows classes
|
||||
tn0018.txt How to add a new font encoding/charset to wxWindows?
|
||||
|
||||
|
||||
Version: $Id$
|
||||
|
68
docs/tech/tn0018.txt
Normal file
68
docs/tech/tn0018.txt
Normal file
@@ -0,0 +1,68 @@
|
||||
How to add a new font encoding to wxWindows
|
||||
===========================================
|
||||
|
||||
I. Introduction
|
||||
---------------
|
||||
|
||||
wxWindows has built in support for a certain number of font encodings (which
|
||||
is synonymous with code sets and character sets for us here even though it is
|
||||
not exactly the same thing), look at include/wx/fontenc.h for the full list.
|
||||
This list is far from being exhaustive though and if you have enough knowledge
|
||||
about an encoding to add support for it to wxWindows, this tech note is for
|
||||
you!
|
||||
|
||||
A word of warning though: this is written out of my head and is surely
|
||||
incomplete. Please correct the text here, especially if you detect problems
|
||||
when you try following it.
|
||||
|
||||
Also note that I completely ignore all the difficult issues of support for
|
||||
non European languages in the GUI (i.e. BiDi and text orientation support).
|
||||
|
||||
|
||||
II. The receipt
|
||||
---------------
|
||||
|
||||
Suppose you want to add support for Klingon to wxWindows. This is what you'd
|
||||
have to do:
|
||||
|
||||
1. include/wx/fontenc.h: add a new wxFONTENCODING_KLINGON enum element, if
|
||||
possible without changing the values of the existing elements of the enum
|
||||
and be careful to now make it equal to some other elements -- this means
|
||||
that you have to put it before wxFONTENCODING_MAX
|
||||
|
||||
2. wxFONTENCODING_MAX must be the same as the number of elements in 3
|
||||
(hopefully) self explanatory arrays in src/common/fmapbase.cpp:
|
||||
a) gs_encodings
|
||||
b) gs_encodingDescs
|
||||
c) gs_encodingNames
|
||||
|
||||
You must update all of them, e.g. you'd add wxFONTENCODING_KLINGON,
|
||||
"Klingon (Star Trek)" and "klingon" to them in this example. The latter
|
||||
name should ideally be understandable to both Win32 and iconv as it is used
|
||||
to convert to/from this encoding under Windows and Unix respectively.
|
||||
Typically any reasonable name will be supported by iconv, if unsure run
|
||||
"iconv -l" on your favourite Unix system. For the list of charsets
|
||||
supported under Win32, look under HKEY_CLASSES_ROOT\MIME\Database\Charset
|
||||
in regedit. Of course, being consistent with the existing encoding names
|
||||
wouldn't hurt neither.
|
||||
|
||||
3. Normally you don't have to do anything else if you've got support for this
|
||||
encoding under both Win32 and Unix. If you haven't, you should modify
|
||||
wxEncodingConverter to support it (this could be useful anyhow as a
|
||||
fallback for systems where iconv is unavailable). To do it you must:
|
||||
a) add a new table to src/common/unictabl.inc: note that this file is auto
|
||||
generated so you have to modify misc/unictabl script instead (probably)
|
||||
b) possibly update EquivalentEncodings table in src/common/encconv.cpp
|
||||
if wxFONTENCODING_KLINGON can be converted into another one
|
||||
(losslessly only or not?)
|
||||
|
||||
4. Add a unit test (see tn0017.txt) for support of your new encoding (with
|
||||
time we should have a wxCSConv unit test so you would just add a case to
|
||||
it for wxFONTENCODING_KLINGON) and test everything on as many different
|
||||
platforms as you can.
|
||||
|
||||
|
||||
=== EOF ===
|
||||
|
||||
Author: VZ
|
||||
Version: $Id$
|
Reference in New Issue
Block a user