]>
Commit | Line | Data |
---|---|---|
775a998e VZ |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: tfontenc.tex | |
3 | %% Purpose: font encoding overview | |
4 | %% Author: Vadim Zeitlin | |
5 | %% Modified by: | |
6 | %% Created: 03.11.99 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) Vadim Zeitlin | |
8795498c | 9 | %% License: wxWindows license |
775a998e VZ |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
11 | ||
12 | \section{Font encoding overview}\label{wxfontencodingoverview} | |
13 | ||
fc2171bd | 14 | wxWidgets has support for multiple font encodings starting from release 2.2. |
775a998e VZ |
15 | By encoding we mean here the mapping between the character codes and the |
16 | letters. Probably the most well-known encoding is (7 bit) ASCII one which is | |
17 | used almost universally now to represent the letters of the English alphabet | |
18 | and some other common characters. However, it is not enough to represent the | |
f6bcfd97 | 19 | letters of foreign alphabets and here other encodings come into play. Please |
775a998e VZ |
20 | note that we will only discuss 8-bit fonts here and not |
21 | \helpref{Unicode}{unicode}. | |
22 | ||
f70c0443 | 23 | Font encoding support is ensured by several classes: |
775a998e VZ |
24 | \helpref{wxFont}{wxfont} itself, but also |
25 | \helpref{wxFontEnumerator}{wxfontenumerator} and | |
26 | \helpref{wxFontMapper}{wxfontmapper}. wxFont encoding support is reflected by | |
27 | a (new) constructor parameter {\it encoding} which takes one of the following | |
28 | values (elements of enumeration type {\tt wxFontEncoding}): | |
29 | ||
30 | \begin{twocollist} | |
31 | \twocolitem{wxFONTENCODING\_SYSTEM}{The default encoding of the underlying | |
32 | operating system (notice that this might be a "foreign" encoding for foreign | |
33 | versions of Windows 9x/NT).} | |
34 | \twocolitem{wxFONTENCODING\_DEFAULT}{The applications default encoding as | |
35 | returned by \helpref{wxFont::GetDefaultEncoding}{wxfontgetdefaultencoding}. On | |
36 | program startup, the applications default encoding is the same as | |
37 | wxFONTENCODING\_SYSTEM, but may be changed to make all the fonts created later | |
38 | to use it (by default).} | |
39 | \twocolitem{wxFONTENCODING\_ISO8859\_1..15}{ISO8859 family encodings which are | |
40 | usually used by all non-Microsoft operating systems} | |
f6bcfd97 | 41 | \twocolitem{wxFONTENCODING\_KOI8}{Standard Cyrillic encoding for the Internet |
775a998e VZ |
42 | (but see also wxFONTENCODING\_ISO8859\_5 and wxFONTENCODING\_CP1251)} |
43 | \twocolitem{wxFONTENCODING\_CP1250}{Microsoft analogue of ISO8859-2} | |
44 | \twocolitem{wxFONTENCODING\_CP1251}{Microsoft analogue of ISO8859-5} | |
45 | \twocolitem{wxFONTENCODING\_CP1252}{Microsoft analogue of ISO8859-1} | |
46 | \end{twocollist} | |
47 | ||
f6bcfd97 | 48 | As you may see, Microsoft's encoding partly mirror the standard ISO8859 ones, |
775a998e VZ |
49 | but there are (minor) differences even between ISO8859-1 (Latin1, ISO encoding |
50 | for Western Europe) and CP1251 (WinLatin1, standard code page for English | |
51 | versions of Windows) and there are more of them for other encodings. | |
52 | ||
f6bcfd97 | 53 | The situation is particularly complicated with Cyrillic encodings for which |
775a998e | 54 | (more than) three incompatible encodings exist: KOI8 (the old standard, widely |
f6bcfd97 | 55 | used on the Internet), ISO8859-5 (ISO standard for Cyrillic) and CP1251 |
775a998e VZ |
56 | (WinCyrillic). |
57 | ||
2b5f62a0 | 58 | This abundance of (incompatible) encodings should make it clear that using |
775a998e | 59 | encodings is less easy than it might seem. The problems arise both from the |
f6bcfd97 | 60 | fact that the standard encodings for the given language (say Russian, which is |
2edb0bde | 61 | written in Cyrillic) are different on different platforms and because the |
775a998e | 62 | fonts in the given encoding might just not be installed (this is especially a |
2edb0bde | 63 | problem with Unix, or, in general, non-Win32 systems). |
775a998e | 64 | |
2b5f62a0 | 65 | To clarify, the \helpref{wxFontEnumerator}{wxfontenumerator} |
775a998e VZ |
66 | class may be used to enumerate both all available encodings and to find the |
67 | facename(s) in which the given encoding exists. If you can find the font in | |
68 | the correct encoding with wxFontEnumerator then your troubles are over, but, | |
69 | unfortunately, sometimes this is not enough. For example, there is no standard | |
2b5f62a0 | 70 | way (that I know of, please tell me if you do!) to find a font on a Windows system |
775a998e VZ |
71 | for KOI8 encoding (only for WinCyrillic one which is quite different), so |
72 | \helpref{wxFontEnumerator}{wxfontenumerator} will never return one, even if | |
73 | the user has installed a KOI8 font on his system. | |
74 | ||
cd77c085 | 75 | To solve this problem, a \helpref{wxFontMapper}{wxfontmapper} class is provided. |
775a998e | 76 | This class stores the mapping between the encodings and the font face |
cd77c085 | 77 | names which support them in \helpref{wxConfig}{wxconfigoverview} object. Of |
775a998e | 78 | course, it would be fairly useless if it tried to determine these mappings by |
f70c0443 | 79 | itself, so, instead, it (optionally) asks the user and remembers his answers |
775a998e VZ |
80 | so that the next time the program will automatically choose the correct font. |
81 | ||
2b5f62a0 | 82 | All these topics are illustrated by the \helpref{font sample}{samplefont}; |
775a998e VZ |
83 | please refer to it and the documentation of the classes mentioned here for |
84 | further explanations. | |
85 |