From e67e349a0bb0bb0514f1c90baecc44022c73a12b Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 13 Oct 2000 21:00:36 +0000 Subject: [PATCH] More fixes to the tutorial. Added artificial Type 1 pid/eid paors to ttnameid.h. --- docs/tutorial/step1.html | 193 ++++++++++++++++++------------------ docs/tutorial/step2.html | 171 ++++++++++++++++---------------- include/freetype/freetype.h | 5 +- include/freetype/ttnameid.h | 16 +++ src/base/ftobjs.c | 4 +- 5 files changed, 204 insertions(+), 185 deletions(-) diff --git a/docs/tutorial/step1.html b/docs/tutorial/step1.html index fc66b124c..94fa25b3b 100644 --- a/docs/tutorial/step1.html +++ b/docs/tutorial/step1.html @@ -37,7 +37,7 @@ Introduction -

This is the first section of the FreeType 2 tutorial. It will +

This is the first part of the FreeType 2 tutorial. It will teach you to do the following:

As you can see, the function returns an error code, like most others in the FreeType API. An error code of 0 always means that the operation was successful; otherwise, the value describes the error, - and library is set to NULL.

+ and library is set to NULL.


@@ -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 }
@@ -160,24 +161,24 @@
- library + library -

a handle to the FreeType library instance where the face +

A handle to the FreeType library instance where the face object is created

- filepathname + filepathname -

the font file pathname (standard C string).

+

The font file pathname (a standard C string).

- face_index + face_index

Certain font formats allow several font faces to be embedded @@ -191,13 +192,13 @@

- face + face

A pointer to the handle that will be set to describe the new face object.

-

It is set to NULL in case of error.

+

It is set to NULL in case of error.

@@ -232,9 +233,9 @@ if ( error ) { ... } -

As you can see, FT_New_Memory_Face() 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 +

As you can see, FT_New_Memory_Face() 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 FT_New_Face().

@@ -242,14 +243,14 @@

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.

+ in memory is not sufficient. With FreeType 2, it is possible to + provide your own implementation of I/O routines.

This is done through the FT_Open_Face() 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.

+ FreeType 2 API reference in order to learn how to use it.

Note that providing a custom stream might also be used to access a TrueType font embedded in a Postscript Type 42 wrapper.

@@ -267,7 +268,7 @@ @@ -94,7 +94,7 @@ @@ -165,8 +165,8 @@ should not be considered reliable if FT_HAS_VERTICAL(face) is false.

-

The following graphics illustrate the metrics more clearly. First, - for horizontal metrics, where the baseline is the horizontal axis:

+

The following graphics illustrate the metrics more clearly. First + horizontal metrics, where the baseline is the horizontal axis:

linearHoriAdvance is a 16.16 fixed float number that gives the value of the original glyph advance width in - 1/65536th of pixels. It can be use to perform pseudo + 1/65536th of pixels. It can be used to perform pseudo device-independent text layouts.
@@ -250,9 +250,9 @@ glyph image, the previous one is erased from the glyph slot.

There are times, however, where you may need to extract this image - from the glyph slot, in order to cache it within your application, and - even perform additional transformations and measures on it before - converting it to a bitmap.

+ from the glyph slot. For example, you want to cache images within your + application, or you want to apply additional transformations and + measures on it before converting it to a bitmap.

The FreeType 2 API has a specific extension which is capable of dealing with glyph images in a flexible and generic way. To use it, you @@ -297,11 +297,11 @@

  • loaded the glyph image normally in the face's glyph slot. We did not use FT_LOAD_RENDER because we want to grab a scalable - glyph image, in order to transform it later, + glyph image in order to transform it later,
  • copied the glyph image from the slot into a new FT_Glyph - object, by calling FT_Get_Glyph(). This function returns + object by calling FT_Get_Glyph(). This function returns an error code and sets glyph.
  • @@ -313,25 +313,25 @@

    You can access the field glyph->format if you want to know exactly how the glyph is modeled and stored. A new glyph object can - be destroyed with a call to FT_Done_Glyph.

    + be destroyed with a call to FT_Done_Glyph().

    -

    The glyph object contains exactly one glyph image and a 2d vector - representing the glyph's advance in 16.16 fixed float coordinates. - The latter can be accessed directly as glyph->advance.

    +

    The glyph object contains exactly one glyph image and a + 2d vector representing the glyph's advance in 16.16 fixed float + coordinates. The latter can be accessed directly as + glyph->advance.

    Note that unlike other FreeType objects, the library doesn't keep a list of all allocated glyph objects. This means you will need to destroy them yourself, instead of relying on - FT_Done_FreeType() doing all the clean-up.

    + FT_Done_FreeType() to do all the clean-up.

    b. Transforming & copying the glyph image

    If the glyph image is scalable (i.e., if glyph->format is - not equal to ft_glyph_format_bitmap), it is possible to - transform the image anytime by a call to - FT_Glyph_Transform().

    + not ft_glyph_format_bitmap), it is possible to transform the + image anytime by a call to FT_Glyph_Transform().

    You can also copy a single glyph image with FT_Glyph_Copy(). Here some example code:

    @@ -362,18 +362,20 @@ matrix.yx = 0.12 * 0x10000L; matrix.yy = 0x10000L; - FT_Glyph_Transform( glyph2, &lmatrix, 0 ); + FT_Glyph_Transform( glyph2, &matrix, 0 ); -

    Note that the 2x2 transform matrix is always applied to the 16.16 - advance vector in the glyph; you thus don't need to recompute it.

    +

    Note that the 2x2 transformation matrix is always applied to + the 16.16 advance vector in the glyph; you thus don't need to + recompute it.

    c. Measuring the glyph image

    You can also retrieve the control (bounding) box of any glyph image - (scalable or not), using the FT_Glyph_Get_CBox function:

    + (scalable or not), using the FT_Glyph_Get_CBox() + function:

    @@ -386,8 +388,8 @@
     
           

    Coordinates are relative to the glyph origin, i.e. (0,0), using the Y upwards convention. This function takes a special argument, - the bbox mode, to indicate how box coordinates are expressed. - If bbox_mode is set to ft_glyph_bbox_subpixels, the + bbox_mode, to indicate how box coordinates are expressed. If + bbox_mode is set to ft_glyph_bbox_subpixels, the coordinates are returned in 26.6 pixels (i.e. 1/64th of pixels).

    Note that the box's maximum coordinates are exclusive, which means @@ -412,10 +414,10 @@ bbox.yMax = CEILING(bbox.yMax)

    -

    The default value for the bbox mode is +

    The default value for bbox_mode is ft_glyph_bbox_pixels (i.e. integer, grid-fitted pixel - coordinates). Please check the API reference for - FT_Glyph_Get_CBox() other possible values

    + coordinates). Please check the API reference of + FT_Glyph_Get_CBox() for other possible values.

    d. Converting the glyph image to a bitmap @@ -430,7 +432,7 @@ FT_Vector origin; - origin.x = 32; /* 1/2 pixel in 26.26 format */ + origin.x = 32; /* 1/2 pixel in 26.6 format */ origin.y = 0; error = FT_Glyph_To_Bitmap( &glyph, @@ -455,12 +457,12 @@ or ft_render_mode_mono for a 1-bit monochrome bitmap.
  • - The third parameter is a pointer to a 2d vector that is used to - translate the source glyph image before the conversion. Note that - the source image will be translated back to its original position - (and will thus be left unchanged) after the call. If you do not - need to translate the source glyph before rendering, set this - pointer to 0. + The third parameter is a pointer to a 2d vector that is used + to translate the source glyph image before the conversion. Note + that the source image will be translated back to its original + position (and will thus be left unchanged) after the call. If you + do not need to translate the source glyph before rendering, set + this pointer to 0.
  • The last parameter is a Boolean to indicate whether the source @@ -530,13 +532,12 @@

    For scalable formats, all global metrics are expressed in font units in order to be later scaled to device space, according to the rules described in the last chapter of this part of the tutorial. You - can access them directly as simple fields of a FT_Face - handle.

    + can access them directly as fields of an FT_Face handle.

    However, you need to check that the font face's format is scalable - before using them. One can do it by using the macro - FT_IS_SCALABLE(face) which returns true if we have a - scalable format.

    + before using them. This can be done with the macro + FT_IS_SCALABLE(face) which returns true if we have a scalable + format.

    In this case, you can access the global design metrics as

    @@ -659,7 +660,7 @@ b. Scaled global metrics
  • -

    Each size object also contains a scaled versions of some of the +

    Each size object also contains scaled versions of some of the global metrics described above. They can be accessed directly through the face->size->metrics structure.

    @@ -749,7 +750,10 @@ if ( error ) { ... } error = FT_Attach_File( face, "/usr/shared/fonts/cour.afm" ); - if ( error ) { .. could not read kerning and additional metrics .. } + if ( error ) + { + .. could not read kerning and additional metrics .. + }

    Note that FT_Attach_Stream() is similar to @@ -785,10 +789,9 @@ a pointer to a destination vector that receives the corresponding distances.

    -

    The kerning mode is very similar to the bbox mode - described in a previous part. It is an enumeration value that - indicates how the kerning distances are expressed in the target - vector.

    +

    The kerning mode is very similar to bbox_mode described in + a previous part. It is an enumeration value that indicates how the + kerning distances are expressed in the target vector.

    The default value ft_kerning_mode_default (which has value 0) corresponds to kerning distances expressed in 26.6 @@ -808,8 +811,8 @@

    Note that the "left" and "right" positions correspond to the visual order of the glyphs in the string of text. This is - important for bi-directional text, or simply when writing - right-to-left text.

    + important for bidirectional text, or when writing right-to-left + text.


    @@ -817,10 +820,9 @@ 4. Simple text rendering: kerning + centering -

    In order to show off what we have just learned, we will now show how - to modify the example code that was provided in the first part to render - a string of text, and enhance it to support kerning and delayed - rendering.

    +

    In order to show off what we have just learned, we will now modify + the example code that was provided in the first part to render a string + of text, and enhance it to support kerning and delayed rendering.

    a. Kerning support @@ -828,9 +830,9 @@

    Adding support for kerning to our code is trivial, as long as we consider that we are still dealing with a left-to-right script like - Latin. We simply need to retrieve the kerning distance between two - glyphs in order to alter the pen position appropriately. The code - looks like

    + Latin. We need to retrieve the kerning distance between two glyphs in + order to alter the pen position appropriately. The code looks + like

    @@ -913,7 +915,7 @@
             
  • We do not check the error code returned by FT_Get_Kerning(). This is because the function always - set the content of delta to (0,0) when an error occurs. + set delta to (0,0) when an error occurs.
  • @@ -1000,7 +1002,7 @@ }
    -

    As you see, this is a very simple variation of our previous code +

    As you see, this is a very slight variation of our previous code where we extract each glyph image from the slot, and store it, along with the corresponding position, in our tables.

    @@ -1020,7 +1022,7 @@ bbox.xMax = bbox.yMax = -32000; /* for each glyph image, compute its bounding box, */ - /* translateit, and grow the string bbox */ + /* translate it, and grow the string bbox */ for ( n = 0; n < num_glyphs; n++ ) { FT_BBox glyph_bbox; @@ -1111,7 +1113,7 @@ We call FT_Glyph_To_Bitmap() with the destroy parameter set to 0 (false), in order to avoid destroying the original glyph image. The new glyph bitmap is accessed through - image after the call and is typecasted to a + image after the call and is typecast to an FT_BitmapGlyph.
  • @@ -1304,7 +1306,7 @@
  • However, directly transforming the glyphs in our sequence is not a - useful idea if we want to re-use them in order to draw the text string + useful idea if we want to reuse them in order to draw the text string with various angles or transforms. It is better to perform the affine transformation just before the glyph is rendered, as in the following code:

    @@ -1403,8 +1405,8 @@

    It is possible to call this function several times to render the - string width different angles, or even change the way start - is computed in order to move it to different place.

    + string with different angles, or even change the way start + is computed in order to move it to a different place.

    This code is the basis of the FreeType 2 demonstration program named ftstring.c. It could be easily extended to perform @@ -1421,15 +1423,15 @@


    - 6. Accessing metrics in design font units, and scaling them + 6. Accessing metrics in design font units and scaling them

    Scalable font formats usually store a single vectorial image, called - an outline, for each in a face. Each outline is defined in an - abstract grid called the design space, with coordinates + an outline, for each glyph in a face. Each outline is defined + in an abstract grid called the design space, with coordinates expressed in nominal font units. When a glyph image is loaded, the font driver usually scales the outline to device space according to - the current character pixel size found in a FT_Size object. + the current character pixel size found in a FT_Size object. The driver may also modify the scaled outline in order to significantly improve its appearance on a pixel-based surface (a process known as hinting or grid-fitting).

    @@ -1494,10 +1496,10 @@ x_ppem @@ -1505,10 +1507,10 @@ y_ppem @@ -1532,9 +1534,9 @@
    - face->num_glyphs + face->num_glyphs

    Gives the number of glyphs available in the font face. @@ -277,7 +278,7 @@

    - face->flags + face->flags

    A 32-bit integer containing bit flags used to describe some @@ -290,7 +291,7 @@

    - face->units_per_EM + face->units_per_EM

    This field is only valid for scalable formats (it is set @@ -300,7 +301,7 @@

    - face->num_fixed_sizes + face->num_fixed_sizes

    This field gives the number of embedded bitmap strikes @@ -313,7 +314,7 @@

    - face->fixed_sizes + face->fixed_sizes

    This is a pointer to an array of FT_Bitmap_Size @@ -376,7 +377,7 @@

  • The character width and heights are specified in 1/64th of points. A point is a physical distance, equaling 1/72th of an inch; - it's not a pixel. + it is not a pixel.
  • Horizontal and vertical device resolutions are expressed in @@ -397,7 +398,7 @@
  • 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.
  • @@ -409,9 +410,9 @@
         error = FT_Set_Pixel_Sizes(
    -              face,   /* handle to face object            */
    -              0,      /* pixel_width                      */
    -              16 );   /* pixel_height                     */
    + face, /* handle to face object */ + 0, /* pixel_width */ + 16 ); /* pixel_height */

    This example will set the character pixel sizes to 16x16 pixels. @@ -421,7 +422,7 @@

    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 - face->fixed_sizes> array.

    + face->fixed_sizes array.


    @@ -436,7 +437,7 @@

    Usually, an application wants to load a glyph image based on its character code, which is a unique value that defines the character for a given encoding. For example, the character - code 65 represents the `A' in ASCII encoding.

    + code 65 in ASCII encoding represents letter `A'.

    A face object contains one or more tables, called charmaps, that are used to convert character codes to glyph @@ -468,10 +469,10 @@ face.

    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 missing - glyph, which usually is represented as a box or a space.

    + 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 missing + glyph, which usually is represented as a box or a space.

    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 outlines to describe each glyph. Some formats may have - even more exotic ways of representing glyph (e.g. MetaFont). + named outlines, 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.

    @@ -513,10 +514,10 @@
    • 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 FT_LOAD_NO_BITMAP flag)

      + 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 FT_LOAD_NO_BITMAP flag.

    • 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. It is positive to indicate an upwards distance.

      -

      The second part of the tutorial will describe the contents of a - glyph slot and how to access specific glyph information (including +

      The second part of the tutorial describes the contents of a glyph + slot and how to access specific glyph information (including metrics).

      @@ -563,18 +564,18 @@

      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 face->charmap. This field - is NULL if no charmap is selected, which typically happens when you - create a new FT_Face object from a font file that doesn't - contain an ASCII, Latin-1, or Unicode charmap (rare stuff).

      + is NULL if no charmap is selected, which typically happens + when you create a new FT_Face object from a font file that + doesn't contain an ASCII, Latin-1, or Unicode charmap (rare + stuff).

      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 - <freetype/freetype.h>, as ft_encoding_big5. - In this case, you can simply call FT_Select_CharMap() as - in

      + a corresponding enumeration defined in freetype/freetype.h, + as ft_encoding_big5. In this case, you can simply call + FT_Select_CharMap() as in

           error = FT_Select_CharMap(
      @@ -582,12 +583,12 @@
                     ft_encoding_big5 );   /* encoding           */
      -

      Another way is to manually parse the list of charmaps for the face, +

      Another way is to manually parse the list of charmaps for the face; this is accessible through the fields num_charmaps and - charmaps (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 a table of pointers to the charmaps embedded in - the face.

      + charmaps (notice the final 's') of the face object. As + expected, the first is the number of charmaps in the face, while the + second is a table of pointers to the charmaps embedded in the + face.

      Each charmap has a few visible fields used to describe it more precisely. Mainly, one will look at charmap->platform_id and @@ -595,16 +596,20 @@ be used to describe the charmap in a rather generic way.

      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 - <freetype/ftnameid.h> which defines several helpful - constants to deal with them.

      + 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 <freetype/ttnameid.h> which defines + several helpful constants to deal with them.

      + +

      Note that some pid/eid pairs are artificial; such values + have been created by FreeType to identify platforms resp. encodings + not covered by the original TrueType specification.

      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:

      + 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:

      @@ -654,26 +659,26 @@
             
       
             

      This function will set the current transformation for a given face - object. Its second parameter is a pointer to a FT_Matrix - structure that describes a 2x2 affine matrix. The third parameter is - a pointer to a FT_Vector structure that describes a simple 2d - vector that is used to translate the glyph image after the - 2x2 transformation.

      + object. Its second parameter is a pointer to an FT_Matrix + structure that describes a 2x2 affine matrix. The third + parameter is a pointer to an FT_Vector structure that + describes a simple 2d vector that is used to translate the glyph + image after the 2x2 transformation.

      -

      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.

      +

      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.

      -

      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).

      +

      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).

      The transformation is applied to every glyph that is loaded through FT_Load_Glyph() and is completely independent of any hinting process. 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).

      If you ever need to use a non-orthogonal transformation with @@ -692,9 +697,8 @@ 7. Simple text rendering

    -

    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

    +

    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

    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.

  • - The function my_draw_bitmap() 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 my_draw_bitmap() 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 FT_Bitmap descriptor and the position of its top-left corner as arguments.
  • @@ -834,8 +838,8 @@ equivalent.

    Note that you can also specify that you want a monochrome - bitmap instead by using the additional FT_LOAD_MONOCHROME - load flag.

    + bitmap by using the FT_LOAD_MONOCHROME load flag + instead.

    @@ -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.
  • - 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.
  • - 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).
  • @@ -931,13 +935,12 @@ Conclusion -

    In this first section, you have learned the basics of - FreeType 2, as well as sufficient knowledge how to render rotated - text.

    +

    In this first section, you have learned the basics of FreeType 2 + as well as sufficient knowledge how to render rotated text.

    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.

    + you access glyph metrics and images directly, how to deal with scaling, + hinting, kerning, etc.

    The third part will discuss issues like modules, caching, and a few other advanced topics like how to use multiple size objects with a diff --git a/docs/tutorial/step2.html b/docs/tutorial/step2.html index 242546389..1c8c94d73 100644 --- a/docs/tutorial/step2.html +++ b/docs/tutorial/step2.html @@ -37,8 +37,8 @@ Introduction -

    This is the second section of the FreeType 2 tutorial. It will - teach you the following:

    +

    This is the second part of the FreeType 2 tutorial. It will teach + you the following:

    • how to retrieve glyph metrics
    • @@ -69,8 +69,8 @@

      Note that only a few font formats provide vertical metrics. You can test wether a given face object contains them by using the macro - FT_HAS_VERTICAL(face), which is true if has vertical - metrics.

      + FT_HAS_VERTICAL(face), which is true if vertical metrics are + available.

      Individual glyph metrics can be accessed by first loading the glyph in a face's glyph slot, then using the face->glyph->metrics @@ -85,7 +85,7 @@

    This is the width of the glyph image's bounding box. It is - independent of layout direction. + independent of the layout direction.
    This is the height of the glyph image's bounding box. It is - independent of layout direction. + independent of the layout direction.
    - Which stands for "X Pixels Per EM"; this is the size in integer - pixels of the EM square, which also is the horizontal - character pixel size, called pixel_size_x in the - above example. + This is the size in integer pixels of the EM square, which also is + the horizontal character pixel size, called + pixel_size_x in the above example. x_ppem means + "x pixels per EM".
    - Which stands for "Y Pixels Per EM"; this is the size in integer - pixels of the EM square, which also is the vertical character - pixel size, called pixel_size_y in the above - example. + This is the size in integer pixels of the EM square, which also is + the vertical character pixel size, called + pixel_size_y in the above example. y_ppem means + "y pixels per EM".
    -

    Basically, this means that you can scale a distance expressed in - font units to 26.6 pixels directly with the help of the - FT_MulFix() function, as in:

    +

    You can scale a distance expressed in font units to 26.6 pixels + directly with the help of the FT_MulFix() function, as + in:

    @@ -1567,12 +1569,12 @@
             b. Accessing design metrics (glyph & global)
           
     
    -      

    You can access glyph metrics in font units simply by specifying the +

    You can access glyph metrics in font units by specifying the FT_LOAD_NO_SCALE bit flag in FT_Load_Glyph() or FT_Load_Char(). The metrics returned in face->glyph->metrics will then all be in font units.

    -

    You can access unscaled kerning data using the +

    Unscaled kerning data can be retrieved using the ft_kerning_mode_unscaled mode.

    Finally, a few global metrics are available directly in font units @@ -1590,9 +1592,8 @@ render text much more intelligently (kerning, measuring, transforming & caching).

    -

    You have now sufficient knowledge to build a pretty decent text - service on top of FreeType 2, and you could possibly stop there if - you want.

    +

    With this knowledge you can build a pretty decent text service on top + of FreeType 2, and you could possibly stop there if you want.

    The next section will deal with FreeType 2 internals (like modules, vector outlines, font drivers, renderers), as well as a few diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index d3ae75223..dc22eb992 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -359,9 +359,8 @@ /* */ /* face :: A handle to the parent face object. */ /* */ - /* flags :: A set of bit flags used to describe the charmap. */ - /* Each bit indicates that a given encoding is */ - /* supported. */ + /* encoding :: A tag which identifies the charmap. Use this with */ + /* FT_Select_Charmap(). */ /* */ /* platform_id :: An ID number describing the platform for the */ /* following encoding ID. This comes directly from */ diff --git a/include/freetype/ttnameid.h b/include/freetype/ttnameid.h index e76ff6190..6bd08158b 100644 --- a/include/freetype/ttnameid.h +++ b/include/freetype/ttnameid.h @@ -35,6 +35,9 @@ #define TT_PLATFORM_ISO 2 /* deprecated */ #define TT_PLATFORM_MICROSOFT 3 + /* artificial values defined ad-hoc by FreeType */ +#define TT_PLATFORM_ADOBE 7 + /*************************************************************************/ /* */ @@ -118,6 +121,19 @@ #define TT_MS_ID_JOHAB 6 + /*************************************************************************/ + /* */ + /* possible values of the platform specific encoding identifier field in */ + /* the name records of the TTF `name' table if the `platform' identifier */ + /* code is TT_PLATFORM_ADOBE. */ + /* */ + /* These are artificial values defined ad-hoc by FreeType. */ + /* */ +#define TT_ADOBE_ID_STANDARD 0 +#define TT_ADOBE_ID_EXPERT 1 +#define TT_ADOBE_ID_CUSTOM 2 + + /*************************************************************************/ /* */ /* Possible values of the language identifier field in the name records */ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index bfa440e61..f8121101d 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -2230,8 +2230,8 @@ /* decoding. */ /* */ /* */ - /* face :: A handle to the source face object. */ - /* charmap :: A handle to the selected charmap. */ + /* face :: A handle to the source face object. */ + /* charmap :: A handle to the selected charmap. */ /* */ /* */ /* FreeType error code. 0 means success. */