1999-11-03 18:51:07 -05:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%% Name: tfontenc.tex
|
|
|
|
%% Purpose: font encoding overview
|
|
|
|
%% Author: Vadim Zeitlin
|
|
|
|
%% Modified by:
|
|
|
|
%% Created: 03.11.99
|
|
|
|
%% RCS-ID: $Id$
|
|
|
|
%% Copyright: (c) Vadim Zeitlin
|
2000-07-15 15:51:35 -04:00
|
|
|
%% License: wxWindows license
|
1999-11-03 18:51:07 -05:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
\section{Font encoding overview}\label{wxfontencodingoverview}
|
|
|
|
|
|
|
|
wxWindows has support for multiple font encodings starting from release 2.2.
|
|
|
|
By encoding we mean here the mapping between the character codes and the
|
|
|
|
letters. Probably the most well-known encoding is (7 bit) ASCII one which is
|
|
|
|
used almost universally now to represent the letters of the English alphabet
|
|
|
|
and some other common characters. However, it is not enough to represent the
|
2000-07-15 15:51:35 -04:00
|
|
|
letters of foreign alphabets and here other encodings come into play. Please
|
1999-11-03 18:51:07 -05:00
|
|
|
note that we will only discuss 8-bit fonts here and not
|
|
|
|
\helpref{Unicode}{unicode}.
|
|
|
|
|
|
|
|
Font encoding support is assured by several classes:
|
|
|
|
\helpref{wxFont}{wxfont} itself, but also
|
|
|
|
\helpref{wxFontEnumerator}{wxfontenumerator} and
|
|
|
|
\helpref{wxFontMapper}{wxfontmapper}. wxFont encoding support is reflected by
|
|
|
|
a (new) constructor parameter {\it encoding} which takes one of the following
|
|
|
|
values (elements of enumeration type {\tt wxFontEncoding}):
|
|
|
|
|
|
|
|
\begin{twocollist}
|
|
|
|
\twocolitem{wxFONTENCODING\_SYSTEM}{The default encoding of the underlying
|
|
|
|
operating system (notice that this might be a "foreign" encoding for foreign
|
|
|
|
versions of Windows 9x/NT).}
|
|
|
|
\twocolitem{wxFONTENCODING\_DEFAULT}{The applications default encoding as
|
|
|
|
returned by \helpref{wxFont::GetDefaultEncoding}{wxfontgetdefaultencoding}. On
|
|
|
|
program startup, the applications default encoding is the same as
|
|
|
|
wxFONTENCODING\_SYSTEM, but may be changed to make all the fonts created later
|
|
|
|
to use it (by default).}
|
|
|
|
\twocolitem{wxFONTENCODING\_ISO8859\_1..15}{ISO8859 family encodings which are
|
|
|
|
usually used by all non-Microsoft operating systems}
|
2000-07-15 15:51:35 -04:00
|
|
|
\twocolitem{wxFONTENCODING\_KOI8}{Standard Cyrillic encoding for the Internet
|
1999-11-03 18:51:07 -05:00
|
|
|
(but see also wxFONTENCODING\_ISO8859\_5 and wxFONTENCODING\_CP1251)}
|
|
|
|
\twocolitem{wxFONTENCODING\_CP1250}{Microsoft analogue of ISO8859-2}
|
|
|
|
\twocolitem{wxFONTENCODING\_CP1251}{Microsoft analogue of ISO8859-5}
|
|
|
|
\twocolitem{wxFONTENCODING\_CP1252}{Microsoft analogue of ISO8859-1}
|
|
|
|
\end{twocollist}
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
As you may see, Microsoft's encoding partly mirror the standard ISO8859 ones,
|
1999-11-03 18:51:07 -05:00
|
|
|
but there are (minor) differences even between ISO8859-1 (Latin1, ISO encoding
|
|
|
|
for Western Europe) and CP1251 (WinLatin1, standard code page for English
|
|
|
|
versions of Windows) and there are more of them for other encodings.
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
The situation is particularly complicated with Cyrillic encodings for which
|
1999-11-03 18:51:07 -05:00
|
|
|
(more than) three incompatible encodings exist: KOI8 (the old standard, widely
|
2000-07-15 15:51:35 -04:00
|
|
|
used on the Internet), ISO8859-5 (ISO standard for Cyrillic) and CP1251
|
1999-11-03 18:51:07 -05:00
|
|
|
(WinCyrillic).
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
This abundance of (incompatible) encoding:w
|
|
|
|
s should make it clear that using
|
1999-11-03 18:51:07 -05:00
|
|
|
encodings is less easy than it might seem. The problems arise both from the
|
2000-07-15 15:51:35 -04:00
|
|
|
fact that the standard encodings for the given language (say Russian, which is
|
|
|
|
written in Cyrillic) are different on differe nt platforms and because the
|
1999-11-03 18:51:07 -05:00
|
|
|
fonts in the given encoding might just not be installed (this is especially a
|
|
|
|
problem with Unix, or, in general, not Win32, systems).
|
|
|
|
|
|
|
|
To allow to see clearer in this, \helpref{wxFontEnumerator}{wxfontenumerator}
|
|
|
|
class may be used to enumerate both all available encodings and to find the
|
|
|
|
facename(s) in which the given encoding exists. If you can find the font in
|
|
|
|
the correct encoding with wxFontEnumerator then your troubles are over, but,
|
|
|
|
unfortunately, sometimes this is not enough. For example, there is no standard
|
|
|
|
way (I know of, please tell me if you do!) to find a font on a Windows system
|
|
|
|
for KOI8 encoding (only for WinCyrillic one which is quite different), so
|
|
|
|
\helpref{wxFontEnumerator}{wxfontenumerator} will never return one, even if
|
|
|
|
the user has installed a KOI8 font on his system.
|
|
|
|
|
1999-11-04 15:43:52 -05:00
|
|
|
To solve this problem, a \helpref{wxFontMapper}{wxfontmapper} class is provided.
|
1999-11-03 18:51:07 -05:00
|
|
|
This class stores the mapping between the encodings and the font face
|
1999-11-04 15:43:52 -05:00
|
|
|
names which support them in \helpref{wxConfig}{wxconfigoverview} object. Of
|
1999-11-03 18:51:07 -05:00
|
|
|
course, it would be fairly useless if it tried to determine these mappings by
|
1999-11-04 15:43:52 -05:00
|
|
|
itself, so, instead, it (optionally) ask the user and remember his answers
|
1999-11-03 18:51:07 -05:00
|
|
|
so that the next time the program will automatically choose the correct font.
|
|
|
|
|
|
|
|
All these topics are illustrated by the \helpref{font sample}{samplefont},
|
|
|
|
please refer to it and the documentation of the classes mentioned here for
|
|
|
|
further explanations.
|
|
|
|
|