freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freetype] Re: FreeType


From: Pavel Kankovsky
Subject: [Freetype] Re: FreeType
Date: Fri, 30 Mar 2001 23:04:52 +0200 (MET DST)

On Wed, 28 Mar 2001, Wolfgang Esterbauer wrote:

> Whe have tried to create an application using FreeType Library,
> but we have heavy Problems whith language-dependent Characters, like
> aumlaut, oumlaut, ssharp [replaced chars with their names]
> On Your Online-Demo,as far as we've seen, you solved this problem.

Well, the demo does not really solve the problem because it makes an
implicit assumption that its input is a sequence of bytes with each byte
representing a single ISO 8859-1 character (or a single Unicode (or ISO
10646-1) character because codes 0-255 in Unicode have the same meaning as
in ISO 8859-1).

This is a real evergreen. You have a string in some encoding, and you want
to draw it. In order to draw it, you need to translate the string into a
sequence of glyphs. If you want to be typographically correct, you may
even need additional information about the placement of glyphs (e.g.
kerning), and the correspondence between characters of the original string
and the glyphs may be nontrivial (e.g. ligatures). Sometimes, the script
itself mandates some special way how certain characters must be written
under certain conditions (e.g. its actual shape depends on whether it
appears at the beginning of a word, inside a word or at the end of a
word).

For the sake of simplicity, let's assume a situation with one-to-one
correspondence between characters and glyphs and no typographical nuances
(e.g a Latin-like script with no ligatures and no kerning).

FreeType (both version 1 and version 2) represents represents glyphs by
their indexes. The indexes are font specific (i.e. index 34 can denote a
completely different glyph in two different fonts). In order to load and
draw a glyph, you must determine its index for the given font--this is
done by querying a character map translating the codes of a specific
character encoding to glyph indexes (the map is loaded from the font
file directly (e.g. TTF) or computed from the data found there (e.g.
Type 1)).

The base encoding of the map (or the maps, a font can provide more than
one map) depends on the given font: most sane TT fonts for MS Windows use
Unicode (with the exception of symbol fonts that use a special "Windows
Symbol" encoding), Latin Type 1 fonts have a (synthetic, generated by FT2
itself) Unicode map too, Macintosh TT fonts have Apple Roman encoding,
fonts for East Asia scripts may use one of their special encodings
(e.g. BIG5).

As long as you want to draw texts in the Latin script--and as long as you
do not use Macintosh-only TT fonts, you can probably assume a Unicode map
is available. This means your string must be in Unicode or you need to
translate the character codes to Unicode before using them. For ISO 8859-1
the translation is trivial (discussed at the beginning of this mail), for 
other encodings you will have to recode them using a table or something.

I suggest you read chapter 6 of the 1st part of the FreeType 2 tutorial
(see www.freetype.org). It describes the technical details (for version 2
but the things are quite similar in version 1--only some functions have
slightly different names and arguments and you have to find a suitable
character map manually; nevertheless, you should use version 2 if you work
on a new piece of code).

--Pavel Kankovsky aka Peak  [ Boycott Microsoft--http://www.vcnet.com/bms ]
"Resistance is futile. Open your source code and prepare for assimilation."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]