|
|
|
@ -37,7 +37,7 @@ |
|
|
|
|
Introduction |
|
|
|
|
</h2> |
|
|
|
|
|
|
|
|
|
<p>This is the first section of the FreeType 2 tutorial. It will |
|
|
|
|
<p>This is the first part of the FreeType 2 tutorial. It will |
|
|
|
|
teach you to do the following:</p> |
|
|
|
|
|
|
|
|
|
<ul> |
|
|
|
@ -55,7 +55,7 @@ |
|
|
|
|
1. Header files |
|
|
|
|
</h3> |
|
|
|
|
|
|
|
|
|
<p>To include the main FreeType header file, simply say</p> |
|
|
|
|
<p>To include the main FreeType header file, say</p> |
|
|
|
|
|
|
|
|
|
<font color="blue"> |
|
|
|
|
<pre> |
|
|
|
@ -64,7 +64,8 @@ |
|
|
|
|
|
|
|
|
|
<p>in your application code. Note that other files are available in the |
|
|
|
|
FreeType include directory, most of them being included by |
|
|
|
|
<tt>freetype.h</tt>. They will be described later in this tutorial.</p> |
|
|
|
|
<tt>freetype.h</tt> and other (internal) files. Some of them will be |
|
|
|
|
described later in this tutorial.</p> |
|
|
|
|
|
|
|
|
|
<hr> |
|
|
|
|
|
|
|
|
@ -104,15 +105,15 @@ |
|
|
|
|
<li> |
|
|
|
|
Load each module that FreeType knows about in the library. This |
|
|
|
|
means that by default, your new <tt>library</tt> object is able to |
|
|
|
|
handle TrueType, Type 1, CID-keyed & OpenType/CFF fonts |
|
|
|
|
gracefully. |
|
|
|
|
handle TrueType, Type 1, Windows FON, CID-keyed & OpenType/CFF |
|
|
|
|
fonts gracefully. |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
|
|
|
|
|
<p>As you can see, the function returns an error code, like most others |
|
|
|
|
in the FreeType API. An error code of 0 <em>always</em> means that |
|
|
|
|
the operation was successful; otherwise, the value describes the error, |
|
|
|
|
and <tt>library</tt> is set to NULL.</p> |
|
|
|
|
and <tt>library</tt> is set to <tt>NULL</tt>.</p> |
|
|
|
|
|
|
|
|
|
<hr> |
|
|
|
|
|
|
|
|
@ -150,7 +151,7 @@ |
|
|
|
|
else if ( error ) |
|
|
|
|
{ |
|
|
|
|
... another error code means that the font file could not |
|
|
|
|
... be opened or read, or simply that it is broken |
|
|
|
|
... be opened or read, or that it is broken |
|
|
|
|
}</pre> |
|
|
|
|
</font> |
|
|
|
|
|
|
|
|
@ -160,24 +161,24 @@ |
|
|
|
|
<table cellpadding=5> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>library</b></tt> |
|
|
|
|
<tt>library</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>a handle to the FreeType library instance where the face |
|
|
|
|
<p>A handle to the FreeType library instance where the face |
|
|
|
|
object is created</p> |
|
|
|
|
</td> |
|
|
|
|
</tr> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>filepathname</b></tt> |
|
|
|
|
<tt>filepathname</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>the font file pathname (standard C string).</p> |
|
|
|
|
<p>The font file pathname (a standard C string).</p> |
|
|
|
|
</td> |
|
|
|
|
</tr> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>face_index</b></tt> |
|
|
|
|
<tt>face_index</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>Certain font formats allow several font faces to be embedded |
|
|
|
@ -191,13 +192,13 @@ |
|
|
|
|
</tr> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>face</b></tt> |
|
|
|
|
<tt>face</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>A <em>pointer</em> to the handle that will be set to describe |
|
|
|
|
the new face object.</p> |
|
|
|
|
|
|
|
|
|
<p>It is set to NULL in case of error.</p> |
|
|
|
|
<p>It is set to <tt>NULL</tt> in case of error.</p> |
|
|
|
|
</td> |
|
|
|
|
</tr> |
|
|
|
|
</table> |
|
|
|
@ -232,9 +233,9 @@ |
|
|
|
|
if ( error ) { ... }</pre> |
|
|
|
|
</font> |
|
|
|
|
|
|
|
|
|
<p>As you can see, <tt>FT_New_Memory_Face()</tt> simply takes a |
|
|
|
|
pointer to the font file buffer and its size in bytes instead of a |
|
|
|
|
file pathname. Other than that, it has exactly the same semantics as |
|
|
|
|
<p>As you can see, <tt>FT_New_Memory_Face()</tt> takes a pointer to |
|
|
|
|
the font file buffer and its size in bytes instead of a file pathname. |
|
|
|
|
Other than that, it has exactly the same semantics as |
|
|
|
|
<tt>FT_New_Face()</tt>.</p> |
|
|
|
|
|
|
|
|
|
<h4> |
|
|
|
@ -242,14 +243,14 @@ |
|
|
|
|
</h4> |
|
|
|
|
|
|
|
|
|
<p>There are cases where using a file pathname or preloading the file |
|
|
|
|
in memory is simply not enough. With FreeType 2, it is possible |
|
|
|
|
to provide your own implementation of i/o routines.</p> |
|
|
|
|
in memory is not sufficient. With FreeType 2, it is possible to |
|
|
|
|
provide your own implementation of I/O routines.</p> |
|
|
|
|
|
|
|
|
|
<p>This is done through the <tt>FT_Open_Face()</tt> function, which |
|
|
|
|
can be used to open a new font face with a custom input stream, select |
|
|
|
|
a specific driver for opening, or even pass extra parameters to the |
|
|
|
|
font driver when creating the object. We advise you to refer to the |
|
|
|
|
FreeType 2 reference manual in order to learn how to use it.</p> |
|
|
|
|
FreeType 2 API reference in order to learn how to use it.</p> |
|
|
|
|
|
|
|
|
|
<p>Note that providing a custom stream might also be used to access a |
|
|
|
|
TrueType font embedded in a Postscript Type 42 wrapper.</p> |
|
|
|
@ -267,7 +268,7 @@ |
|
|
|
|
<table cellpadding=5> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>face->num_glyphs</b></tt> |
|
|
|
|
<tt>face->num_glyphs</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>Gives the number of <em>glyphs</em> available in the font face. |
|
|
|
@ -277,7 +278,7 @@ |
|
|
|
|
</tr> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>face->flags</b></tt> |
|
|
|
|
<tt>face->flags</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>A 32-bit integer containing bit flags used to describe some |
|
|
|
@ -290,7 +291,7 @@ |
|
|
|
|
</tr> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>face->units_per_EM</b></tt> |
|
|
|
|
<tt>face->units_per_EM</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>This field is only valid for scalable formats (it is set |
|
|
|
@ -300,7 +301,7 @@ |
|
|
|
|
</tr> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>face->num_fixed_sizes</b></tt> |
|
|
|
|
<tt>face->num_fixed_sizes</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>This field gives the number of embedded bitmap <em>strikes</em> |
|
|
|
@ -313,7 +314,7 @@ |
|
|
|
|
</tr> |
|
|
|
|
<tr valign="top"> |
|
|
|
|
<td> |
|
|
|
|
<tt><b>face->fixed_sizes</b></tt> |
|
|
|
|
<tt>face->fixed_sizes</tt> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<p>This is a pointer to an array of <tt>FT_Bitmap_Size</tt> |
|
|
|
@ -376,7 +377,7 @@ |
|
|
|
|
<li> |
|
|
|
|
The character width and heights are specified in 1/64th of points. |
|
|
|
|
A point is a <em>physical</em> distance, equaling 1/72th of an inch; |
|
|
|
|
it's not a pixel. |
|
|
|
|
it is not a pixel. |
|
|
|
|
</li> |
|
|
|
|
<li> |
|
|
|
|
Horizontal and vertical device resolutions are expressed in |
|
|
|
@ -397,7 +398,7 @@ |
|
|
|
|
</li> |
|
|
|
|
<li> |
|
|
|
|
The first argument is a handle to a face object, not a size object. |
|
|
|
|
That's normal, and must be seen as a convenience. |
|
|
|
|
This behaviour must be seen as a convenience. |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
|
|
|
|
@ -409,9 +410,9 @@ |
|
|
|
|
<font color="blue"> |
|
|
|
|
<pre> |
|
|
|
|
error = FT_Set_Pixel_Sizes( |
|
|
|
|
face, /* handle to face object */ |
|
|
|
|
0, /* pixel_width */ |
|
|
|
|
16 ); /* pixel_height */</pre> |
|
|
|
|
face, /* handle to face object */ |
|
|
|
|
0, /* pixel_width */ |
|
|
|
|
16 ); /* pixel_height */</pre> |
|
|
|
|
</font> |
|
|
|
|
|
|
|
|
|
<p>This example will set the character pixel sizes to 16x16 pixels. |
|
|
|
@ -421,7 +422,7 @@ |
|
|
|
|
<p>Note that both functions return an error code. Usually, an error |
|
|
|
|
occurs with a fixed-size font format (like FNT or PCF) when trying to |
|
|
|
|
set the pixel size to a value that is not listed in the |
|
|
|
|
<tt>face->fixed_sizes></tt> array.</p> |
|
|
|
|
<tt>face->fixed_sizes</tt> array.</p> |
|
|
|
|
|
|
|
|
|
<hr> |
|
|
|
|
|
|
|
|
@ -436,7 +437,7 @@ |
|
|
|
|
<p>Usually, an application wants to load a glyph image based on its |
|
|
|
|
<em>character code</em>, which is a unique value that defines the |
|
|
|
|
character for a given <em>encoding</em>. For example, the character |
|
|
|
|
code 65 represents the `A' in ASCII encoding.</p> |
|
|
|
|
code 65 in ASCII encoding represents letter `A'.</p> |
|
|
|
|
|
|
|
|
|
<p>A face object contains one or more tables, called |
|
|
|
|
<em>charmaps</em>, that are used to convert character codes to glyph |
|
|
|
@ -468,10 +469,10 @@ |
|
|
|
|
face. |
|
|
|
|
|
|
|
|
|
<p>Note that this is one of the rare FreeType functions that do not |
|
|
|
|
return an error code. However, when a given character code has no |
|
|
|
|
glyph image in the face, the value 0 is returned. By convention, |
|
|
|
|
it always corresponds to a special glyph image called the <b>missing |
|
|
|
|
glyph</b>, which usually is represented as a box or a space.</p> |
|
|
|
|
return an error code. If a given character code has no glyph image in |
|
|
|
|
the face, the value 0 is returned. By convention, it always |
|
|
|
|
corresponds to a special glyph image called the <em>missing |
|
|
|
|
glyph</em>, which usually is represented as a box or a space.</p> |
|
|
|
|
|
|
|
|
|
<h4> |
|
|
|
|
b. Loading a glyph from the face |
|
|
|
@ -481,8 +482,8 @@ |
|
|
|
|
image. The latter can be stored in various formats within the font |
|
|
|
|
file. For fixed-size formats like FNT or PCF, each image is a bitmap. |
|
|
|
|
Scalable formats like TrueType or Type 1 use vectorial shapes, |
|
|
|
|
named <em>outlines</em> to describe each glyph. Some formats may have |
|
|
|
|
even more exotic ways of representing glyph (e.g. MetaFont). |
|
|
|
|
named <em>outlines</em>, to describe each glyph. Some formats may have |
|
|
|
|
even more exotic ways of representing glyphs (e.g. MetaFont). |
|
|
|
|
Fortunately, FreeType 2 is flexible enough to support any kind of |
|
|
|
|
glyph format through a simple API.</p> |
|
|
|
|
|
|
|
|
@ -513,10 +514,10 @@ |
|
|
|
|
<ul> |
|
|
|
|
<li> |
|
|
|
|
<p>If a bitmap is found for the corresponding glyph and pixel |
|
|
|
|
size, it will be loaded into the slot (embedded bitmaps are always |
|
|
|
|
favored over native image formats, because we assume that they are |
|
|
|
|
higher-quality versions of the same glyph. This can be changed by |
|
|
|
|
using the <tt>FT_LOAD_NO_BITMAP</tt> flag)</p> |
|
|
|
|
size, it will be loaded into the slot. Embedded bitmaps are |
|
|
|
|
always favored over native image formats, because we assume that |
|
|
|
|
they are higher-quality versions of the same glyph. This can be |
|
|
|
|
changed by using the <tt>FT_LOAD_NO_BITMAP</tt> flag.</p> |
|
|
|
|
</li> |
|
|
|
|
<li> |
|
|
|
|
<p>Otherwise, a native image for the glyph will be loaded. It |
|
|
|
@ -554,8 +555,8 @@ |
|
|
|
|
position (on the baseline) to the top-most border of the glyph bitmap. |
|
|
|
|
<em>It is positive to indicate an upwards distance</em>.</p> |
|
|
|
|
|
|
|
|
|
<p>The second part of the tutorial will describe the contents of a |
|
|
|
|
glyph slot and how to access specific glyph information (including |
|
|
|
|
<p>The second part of the tutorial describes the contents of a glyph |
|
|
|
|
slot and how to access specific glyph information (including |
|
|
|
|
metrics).</p> |
|
|
|
|
|
|
|
|
|
<h4> |
|
|
|
@ -563,18 +564,18 @@ |
|
|
|
|
</h4> |
|
|
|
|
|
|
|
|
|
<p>As said before, when a new face object is created, it will look for |
|
|
|
|
a Unicode, Latin-1, or ASCII charmap and select it. The currently |
|
|
|
|
a Unicode, Latin-1, or ASCII charmap and select it. The currently |
|
|
|
|
selected charmap is accessed via <tt>face->charmap</tt>. This field |
|
|
|
|
is NULL if no charmap is selected, which typically happens when you |
|
|
|
|
create a new <tt>FT_Face</tt> object from a font file that doesn't |
|
|
|
|
contain an ASCII, Latin-1, or Unicode charmap (rare stuff).</p> |
|
|
|
|
is <tt>NULL</tt> if no charmap is selected, which typically happens |
|
|
|
|
when you create a new <tt>FT_Face</tt> object from a font file that |
|
|
|
|
doesn't contain an ASCII, Latin-1, or Unicode charmap (rare |
|
|
|
|
stuff).</p> |
|
|
|
|
|
|
|
|
|
<p>There are two ways to select a different charmap with |
|
|
|
|
FreeType 2. The easiest is if the encoding you need already has |
|
|
|
|
a corresponding enumeration defined in |
|
|
|
|
<tt><freetype/freetype.h></tt>, as <tt>ft_encoding_big5</tt>. |
|
|
|
|
In this case, you can simply call <tt>FT_Select_CharMap()</tt> as |
|
|
|
|
in</p> |
|
|
|
|
a corresponding enumeration defined in <tt>freetype/freetype.h</tt>, |
|
|
|
|
as <tt>ft_encoding_big5</tt>. In this case, you can simply call |
|
|
|
|
<tt>FT_Select_CharMap()</tt> as in</p> |
|
|
|
|
|
|
|
|
|
<font color="blue"><pre> |
|
|
|
|
error = FT_Select_CharMap( |
|
|
|
@ -582,12 +583,12 @@ |
|
|
|
|
ft_encoding_big5 ); /* encoding */</pre> |
|
|
|
|
</font> |
|
|
|
|
|
|
|
|
|
<p>Another way is to manually parse the list of charmaps for the face, |
|
|
|
|
<p>Another way is to manually parse the list of charmaps for the face; |
|
|
|
|
this is accessible through the fields <tt>num_charmaps</tt> and |
|
|
|
|
<tt>charmaps</tt> (notice the final 's') of the face object. As you |
|
|
|
|
could expect, the first is the number of charmaps in the face, while |
|
|
|
|
the second is <em>a table of pointers to the charmaps</em> embedded in |
|
|
|
|
the face.</p> |
|
|
|
|
<tt>charmaps</tt> (notice the final 's') of the face object. As |
|
|
|
|
expected, the first is the number of charmaps in the face, while the |
|
|
|
|
second is <em>a table of pointers to the charmaps</em> embedded in the |
|
|
|
|
face.</p> |
|
|
|
|
|
|
|
|
|
<p>Each charmap has a few visible fields used to describe it more |
|
|
|
|
precisely. Mainly, one will look at <tt>charmap->platform_id</tt> and |
|
|
|
@ -595,16 +596,20 @@ |
|
|
|
|
be used to describe the charmap in a rather generic way.</p> |
|
|
|
|
|
|
|
|
|
<p>Each value pair corresponds to a given encoding. For example, the |
|
|
|
|
pair (3,1) corresponds to Unicode. A list of such pairs is defined in |
|
|
|
|
the TrueType specification, but you can also use the file |
|
|
|
|
<tt><freetype/ftnameid.h></tt> which defines several helpful |
|
|
|
|
constants to deal with them.</p> |
|
|
|
|
pair (3,1) corresponds to Unicode (on the Windows platform). A list |
|
|
|
|
of such pairs is defined in the TrueType specification, but you can |
|
|
|
|
also use the file <tt><freetype/ttnameid.h></tt> which defines |
|
|
|
|
several helpful constants to deal with them.</p> |
|
|
|
|
|
|
|
|
|
<p>Note that some pid/eid pairs are <em>artificial</em>; such values |
|
|
|
|
have been created by FreeType to identify platforms resp. encodings |
|
|
|
|
not covered by the original TrueType specification.</p> |
|
|
|
|
|
|
|
|
|
<p>To look up a specific encoding you need to find a corresponding |
|
|
|
|
value pair in the specification, then look for it in the charmaps |
|
|
|
|
list. Bear in mind that some encodings correspond to several values |
|
|
|
|
pairs (yes, it's a real mess, but blame Apple and Microsoft on such |
|
|
|
|
stupidity). Here some code to do it:</p> |
|
|
|
|
value pair in the specification, then look for it in the |
|
|
|
|
<tt>charmaps</tt> list. Bear in mind that some encodings correspond |
|
|
|
|
to several values pairs (yes, it's a real mess, but blame Apple and |
|
|
|
|
Microsoft on such stupidity). Here some code to do it:</p> |
|
|
|
|
|
|
|
|
|
<font color="blue"> |
|
|
|
|
<pre> |
|
|
|
@ -654,26 +659,26 @@ |
|
|
|
|
</font> |
|
|
|
|
|
|
|
|
|
<p>This function will set the current transformation for a given face |
|
|
|
|
object. Its second parameter is a pointer to a <tt>FT_Matrix</tt> |
|
|
|
|
structure that describes a 2x2 affine matrix. The third parameter is |
|
|
|
|
a pointer to a <tt>FT_Vector</tt> structure that describes a simple 2d |
|
|
|
|
vector that is used to translate the glyph image <em>after</em> the |
|
|
|
|
2x2 transformation.</p> |
|
|
|
|
object. Its second parameter is a pointer to an <tt>FT_Matrix</tt> |
|
|
|
|
structure that describes a 2x2 affine matrix. The third |
|
|
|
|
parameter is a pointer to an <tt>FT_Vector</tt> structure that |
|
|
|
|
describes a simple 2d vector that is used to translate the glyph |
|
|
|
|
image <em>after</em> the 2x2 transformation.</p> |
|
|
|
|
|
|
|
|
|
<p>Note that the matrix pointer can be set to NULL, in which case the |
|
|
|
|
identity transformation will be used. Coefficients of the matrix are |
|
|
|
|
otherwise in 16.16 fixed float units.</p> |
|
|
|
|
<p>Note that the matrix pointer can be set to <tt>NULL</tt>, in which |
|
|
|
|
case the identity transformation will be used. Coefficients of the |
|
|
|
|
matrix are otherwise in 16.16 fixed float units.</p> |
|
|
|
|
|
|
|
|
|
<p>The vector pointer can also be set to NULL in which case a delta |
|
|
|
|
vector of (0,0) will be used. The vector coordinates are expressed in |
|
|
|
|
1/64th of a pixel (also known as 26.6 fixed floats).</p> |
|
|
|
|
<p>The vector pointer can also be set to <tt>NULL</tt> in which case a |
|
|
|
|
delta vector of (0,0) will be used. The vector coordinates are |
|
|
|
|
expressed in 1/64th of a pixel (also known as 26.6 fixed floats).</p> |
|
|
|
|
|
|
|
|
|
<p><em>The transformation is applied to every glyph that is loaded |
|
|
|
|
through <tt>FT_Load_Glyph()</tt> and is <b>completely independent of |
|
|
|
|
any hinting process.</b> This means that you won't get the same |
|
|
|
|
results if you load a glyph at the size of 24 pixels, or a glyph |
|
|
|
|
at the size at 12 pixels scaled by 2 through a |
|
|
|
|
transformation, because the hints will have been computed differently |
|
|
|
|
transformation, because hints will have been computed differently |
|
|
|
|
(unless hints have been disabled, of course).</em></p> |
|
|
|
|
|
|
|
|
|
<p>If you ever need to use a non-orthogonal transformation with |
|
|
|
@ -692,9 +697,8 @@ |
|
|
|
|
7. Simple text rendering |
|
|
|
|
</h3> |
|
|
|
|
|
|
|
|
|
<p>We will now present you with a very simple example used to render a |
|
|
|
|
string of 8-bit Latin-1 text, assuming a face that contains a Unicode |
|
|
|
|
charmap</p> |
|
|
|
|
<p>We will now present a very simple example used to render a string of |
|
|
|
|
8-bit Latin-1 text, assuming a face that contains a Unicode charmap</p> |
|
|
|
|
|
|
|
|
|
<p>The idea is to create a loop that will, on each iteration, load one |
|
|
|
|
glyph image, convert it to an anti-aliased bitmap, draw it on the target |
|
|
|
@ -764,9 +768,9 @@ |
|
|
|
|
truncated to integer pixels on each iteration. |
|
|
|
|
</li> |
|
|
|
|
<li> |
|
|
|
|
The function <tt>my_draw_bitmap()</tt> is not part of FreeType, |
|
|
|
|
but must be provided by the application to draw the bitmap to the |
|
|
|
|
target surface. In this example, it takes a pointer to a |
|
|
|
|
The function <tt>my_draw_bitmap()</tt> is not part of FreeType but |
|
|
|
|
must be provided by the application to draw the bitmap to the |
|
|
|
|
target surface. In this example, it takes a pointer to an |
|
|
|
|
<tt>FT_Bitmap</tt> descriptor and the position of its top-left |
|
|
|
|
corner as arguments. |
|
|
|
|
</li> |
|
|
|
@ -834,8 +838,8 @@ |
|
|
|
|
equivalent.</p> |
|
|
|
|
|
|
|
|
|
<p>Note that you can also specify that you want a monochrome |
|
|
|
|
bitmap instead by using the additional <tt>FT_LOAD_MONOCHROME</tt> |
|
|
|
|
load flag.</p> |
|
|
|
|
bitmap by using the <tt>FT_LOAD_MONOCHROME</tt> load flag |
|
|
|
|
instead.</p> |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
|
|
|
|
@ -850,7 +854,7 @@ |
|
|
|
|
FT_Matrix matrix; /* transformation matrix */ |
|
|
|
|
FT_UInt glyph_index; |
|
|
|
|
FT_Vector pen; /* untransformed origin */ |
|
|
|
|
int pen_x, pen_y, n; |
|
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. initialize library .. |
|
|
|
@ -896,8 +900,8 @@ |
|
|
|
|
multiplication. The position is expressed in cartesian space. |
|
|
|
|
</li> |
|
|
|
|
<li> |
|
|
|
|
Glyph images are always loaded, transformed, and described in the |
|
|
|
|
cartesian coordinate system in FreeType (which means that |
|
|
|
|
In FreeType, glyph images are always loaded, transformed, and |
|
|
|
|
described in the cartesian coordinate system (which means that |
|
|
|
|
increasing Y corresponds to upper scanlines), unlike the |
|
|
|
|
system typically used for bitmaps (where the top-most scanline has |
|
|
|
|
coordinate 0). We must thus convert between the two systems |
|
|
|
@ -905,8 +909,8 @@ |
|
|
|
|
position of the bitmap. |
|
|
|
|
</li> |
|
|
|
|
<li> |
|
|
|
|
We set the transformation on each glyph to indicate the rotation |
|
|
|
|
matrix, as well as a delta vector that will move the transformed |
|
|
|
|
We apply the transformation matrix on each glyph to indicate |
|
|
|
|
rotation as well as a delta vector that will move the transformed |
|
|
|
|
image to the current pen position (in cartesian space, not bitmap |
|
|
|
|
space). |
|
|
|
|
</li> |
|
|
|
@ -931,13 +935,12 @@ |
|
|
|
|
Conclusion |
|
|
|
|
</h3> |
|
|
|
|
|
|
|
|
|
<p>In this first section, you have learned the basics of |
|
|
|
|
FreeType 2, as well as sufficient knowledge how to render rotated |
|
|
|
|
text.</p> |
|
|
|
|
<p>In this first section, you have learned the basics of FreeType 2 |
|
|
|
|
as well as sufficient knowledge how to render rotated text.</p> |
|
|
|
|
|
|
|
|
|
<p>The next part will dive into more details of the API in order to let |
|
|
|
|
you access glyph metrics and images directly, as well as how to deal |
|
|
|
|
with scaling, hinting, kerning, etc.</p> |
|
|
|
|
you access glyph metrics and images directly, how to deal with scaling, |
|
|
|
|
hinting, kerning, etc.</p> |
|
|
|
|
|
|
|
|
|
<p>The third part will discuss issues like modules, caching, and a few |
|
|
|
|
other advanced topics like how to use multiple size objects with a |
|
|
|
|