tn0018.txt 2.9 KB

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