2000-06-05 07:26:15 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* sfobjs.c */
|
|
|
|
/* */
|
|
|
|
/* SFNT object management (base). */
|
|
|
|
/* */
|
2001-06-28 19:49:10 +02:00
|
|
|
/* Copyright 1996-2001 by */
|
2000-06-05 07:26:15 +02:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "sfobjs.h"
|
|
|
|
#include "ttload.h"
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_INTERNAL_SFNT_H
|
|
|
|
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
|
2001-03-20 15:50:04 +01:00
|
|
|
#include FT_TRUETYPE_IDS_H
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_TRUETYPE_TAGS_H
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
|
|
|
|
#include "sferrors.h"
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-06-12 21:36:41 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_sfobjs
|
|
|
|
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* Get_Name */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Returns a given ENGLISH name record in ASCII. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to the source face object. */
|
|
|
|
/* */
|
|
|
|
/* nameid :: The name id of the name record to return. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-05 07:26:15 +02:00
|
|
|
/* Character string. NULL if no name is present. */
|
2000-05-28 19:15:37 +02:00
|
|
|
/* */
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_String*
|
|
|
|
Get_Name( TT_Face face,
|
|
|
|
FT_UShort nameid )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = face->root.memory;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort n;
|
2000-05-28 19:15:37 +02:00
|
|
|
TT_NameRec* rec;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Bool wide_chars = 1;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
rec = face->name_table.names;
|
|
|
|
for ( n = 0; n < face->name_table.numNameRecords; n++, rec++ )
|
|
|
|
{
|
|
|
|
if ( rec->nameID == nameid )
|
|
|
|
{
|
2000-07-01 16:06:46 +02:00
|
|
|
/* found the name -- now create an ASCII string from it */
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Bool found = 0;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
|
|
|
/* test for Microsoft English language */
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( rec->platformID == TT_PLATFORM_MICROSOFT &&
|
|
|
|
rec->encodingID <= TT_MS_ID_UNICODE_CS &&
|
2000-06-05 07:26:15 +02:00
|
|
|
( rec->languageID & 0x3FF ) == 0x009 )
|
2000-05-28 19:15:37 +02:00
|
|
|
found = 1;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* test for Apple Unicode encoding */
|
2000-05-28 19:15:37 +02:00
|
|
|
else if ( rec->platformID == TT_PLATFORM_APPLE_UNICODE )
|
|
|
|
found = 1;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* test for Apple Roman */
|
2000-05-28 19:15:37 +02:00
|
|
|
else if ( rec->platformID == TT_PLATFORM_MACINTOSH &&
|
|
|
|
rec->languageID == TT_MAC_ID_ROMAN )
|
|
|
|
{
|
|
|
|
found = 1;
|
|
|
|
wide_chars = 0;
|
|
|
|
}
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* found a Unicode name */
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( found )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_String* string;
|
|
|
|
FT_UInt len;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( wide_chars )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt m;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
len = (FT_UInt)rec->stringLength / 2;
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( MEM_Alloc( string, len + 1 ) )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for ( m = 0; m < len; m ++ )
|
2000-06-05 07:26:15 +02:00
|
|
|
string[m] = rec->string[2 * m + 1];
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = rec->stringLength;
|
|
|
|
if ( MEM_Alloc( string, len + 1 ) )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
MEM_Copy( string, rec->string, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
string[len] = '\0';
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Encoding
|
|
|
|
find_encoding( int platform_id,
|
|
|
|
int encoding_id )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
|
|
|
typedef struct TEncoding
|
|
|
|
{
|
|
|
|
int platform_id;
|
|
|
|
int encoding_id;
|
|
|
|
FT_Encoding encoding;
|
|
|
|
|
|
|
|
} TEncoding;
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
static
|
|
|
|
const TEncoding tt_encodings[] =
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-05 07:26:15 +02:00
|
|
|
{ TT_PLATFORM_ISO, -1, ft_encoding_unicode },
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
{ TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode },
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
{ TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman },
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-09-21 16:10:23 +02:00
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, ft_encoding_symbol },
|
Updating to OpenType 1.3.
* include/freetype/internal/tttypes.h (TT_CMap0, TT_CMap2, TT_CMap4,
TT_CMap6): Adding field `language'.
(TT_CMapTable): Removing field `language'.
Type of `length' field changed to FT_ULong.
Adding fields for cmaps format 8, 10, and 12.
(TT_CMapGroup): New auxiliary structure.
(TT_CMap8_12, TT_CMap10): New structures.
* include/freetype/tttables.h (TT_HoriHeader, TT_VertHeader):
Removed last element of `Reserved' array.
* include/freetype/ttnameid.h (TT_PLATFORM_CUSTOM, TT_MS_ID_UCS_4,
TT_NAME_ID_CID_FINDFONT_NAME): New macros.
* src/sfnt/ttcmap.c (TT_CharMap_Load): Updated loading of `language'
field to the new structures.
Fixed freeing of arrays in case of unsuccessful loads.
Added support for loading format 8, 10, and 12 cmaps.
(TT_CharMap_Free): Added support for freeing format 8, 10, and 12
cmaps.
(code_to_index4): Small improvement.
(code_to_index6): Ditto.
(code_to_index8_12, code_to_index10): New functions.
* src/sfnt/ttload.c (TT_Load_Metrics_Header): Updated to new
structure.
(TT_Load_CMap): Ditto.
* src/sfnt/sfobjs.c (tt_encodings): Add MS UCS4 table (before MS
Unicode).
* src/type1/t1driver.c (t1_get_name_index): Fix compiler warning.
2001-08-13 13:44:29 +02:00
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, ft_encoding_unicode },
|
2000-06-05 07:26:15 +02:00
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, ft_encoding_gb2312 },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, ft_encoding_big5 },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, ft_encoding_wansung },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, ft_encoding_johab }
|
2000-05-28 19:15:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const TEncoding *cur, *limit;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
cur = tt_encodings;
|
2000-06-05 07:26:15 +02:00
|
|
|
limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( cur->platform_id == platform_id )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( cur->encoding_id == encoding_id ||
|
|
|
|
cur->encoding_id == -1 )
|
2000-05-28 19:15:37 +02:00
|
|
|
return cur->encoding;
|
|
|
|
}
|
|
|
|
}
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
return ft_encoding_none;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 01:25:46 +02:00
|
|
|
FT_LOCAL_DEF FT_Error
|
|
|
|
SFNT_Init_Face( FT_Stream stream,
|
|
|
|
TT_Face face,
|
|
|
|
FT_Int face_index,
|
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
FT_Library library = face->root.driver->root.library;
|
2000-06-05 07:26:15 +02:00
|
|
|
SFNT_Interface* sfnt;
|
|
|
|
SFNT_Header sfnt_header;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* for now, parameters are unused */
|
2000-07-04 20:12:13 +02:00
|
|
|
FT_UNUSED( num_params );
|
|
|
|
FT_UNUSED( params );
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
sfnt = (SFNT_Interface*)face->sfnt;
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( !sfnt )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( !sfnt )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
2000-05-28 19:15:37 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
face->sfnt = sfnt;
|
|
|
|
face->goto_table = sfnt->goto_table;
|
|
|
|
}
|
|
|
|
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
if ( !face->psnames )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
face->psnames = (PSNames_Interface*)
|
|
|
|
FT_Get_Module_Interface( library, "psnames" );
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check that we have a valid TrueType file */
|
2000-05-29 22:37:41 +02:00
|
|
|
error = sfnt->load_sfnt_header( face, stream, face_index, &sfnt_header );
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( error )
|
2000-06-05 16:32:32 +02:00
|
|
|
goto Exit;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-05-29 22:37:41 +02:00
|
|
|
face->format_tag = sfnt_header.format_tag;
|
|
|
|
face->num_tables = sfnt_header.num_tables;
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
/* Load font directory */
|
2000-05-29 22:37:41 +02:00
|
|
|
error = sfnt->load_directory( face, stream, &sfnt_header );
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-07-19 08:25:56 +02:00
|
|
|
face->root.num_faces = face->ttc_header.count;
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( face->root.num_faces < 1 )
|
|
|
|
face->root.num_faces = 1;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOAD_
|
2000-07-01 16:06:46 +02:00
|
|
|
#define LOAD_( x ) ( ( error = sfnt->load_##x( face, stream ) ) \
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
!= SFNT_Err_Ok )
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
|
2001-06-28 01:25:46 +02:00
|
|
|
FT_LOCAL_DEF FT_Error
|
|
|
|
SFNT_Load_Face( FT_Stream stream,
|
|
|
|
TT_Face face,
|
|
|
|
FT_Int face_index,
|
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
2000-11-07 00:07:51 +01:00
|
|
|
FT_Bool has_outline;
|
|
|
|
FT_Bool is_apple_sbit;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
|
|
|
|
2000-07-04 20:12:13 +02:00
|
|
|
FT_UNUSED( face_index );
|
|
|
|
FT_UNUSED( num_params );
|
|
|
|
FT_UNUSED( params );
|
2000-06-29 05:14:25 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* Load tables */
|
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* We now support two SFNT-based bitmapped font formats. They */
|
|
|
|
/* are recognized easily as they do not include a `glyf' */
|
|
|
|
/* table. */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* The first format comes from Apple, and uses a table named */
|
|
|
|
/* `bhed' instead of `head' to store the font header (using */
|
|
|
|
/* the same format). It also doesn't include horizontal and */
|
|
|
|
/* vertical metrics tables (i.e. `hhea' and `vhea' tables are */
|
|
|
|
/* missing). */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* The other format comes from Microsoft, and is used with */
|
|
|
|
/* WinCE/PocketPC. It looks like a standard TTF, except that */
|
|
|
|
/* it doesn't contain outlines. */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* */
|
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* do we have outlines in there? */
|
2001-06-19 10:28:24 +02:00
|
|
|
has_outline = FT_BOOL( ( TT_LookUp_Table( face, TTAG_glyf ) != 0 ) ||
|
|
|
|
( TT_LookUp_Table( face, TTAG_CFF ) != 0 ) );
|
2000-11-07 00:07:51 +01:00
|
|
|
is_apple_sbit = 0;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
2000-11-07 00:07:51 +01:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* if this font doesn't contain outlines, we try to load */
|
|
|
|
/* a `bhed' table */
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( !has_outline )
|
2001-06-20 01:03:41 +02:00
|
|
|
is_apple_sbit = FT_BOOL( !LOAD_( bitmap_header ) );
|
2000-11-07 00:07:51 +01:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* load the font header (`head' table) if this isn't an Apple */
|
|
|
|
/* sbit font file */
|
|
|
|
if ( !is_apple_sbit && LOAD_( header ) )
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
2000-08-06 21:48:47 +02:00
|
|
|
|
2002-02-08 07:23:50 +01:00
|
|
|
/* the following tables are often not present in embedded TrueType */
|
|
|
|
/* fonts within PDF documents, so don't check for them. */
|
2002-02-06 14:59:25 +01:00
|
|
|
(void)LOAD_( max_profile );
|
|
|
|
(void)LOAD_( charmaps );
|
2001-12-19 15:59:23 +01:00
|
|
|
|
2001-12-19 23:26:12 +01:00
|
|
|
/* the following tables are optional in PCL fonts -- */
|
|
|
|
/* don't check for errors */
|
|
|
|
(void)LOAD_( names );
|
|
|
|
(void)LOAD_( psnames );
|
2000-08-06 21:48:47 +02:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
/* do not load the metrics headers and tables if this is an Apple */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* sbit font file */
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( !is_apple_sbit )
|
2000-08-06 21:48:47 +02:00
|
|
|
{
|
2000-11-07 07:30:29 +01:00
|
|
|
/* load the `hhea' and `hmtx' tables at once */
|
2000-11-07 00:07:51 +01:00
|
|
|
error = sfnt->load_metrics( face, stream, 0 );
|
2000-11-07 07:30:29 +01:00
|
|
|
if ( error )
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* try to load the `vhea' and `vmtx' tables at once */
|
2000-11-07 00:07:51 +01:00
|
|
|
error = sfnt->load_metrics( face, stream, 1 );
|
2000-11-07 07:30:29 +01:00
|
|
|
if ( error )
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
if ( LOAD_( os2 ) )
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
2000-08-06 21:48:47 +02:00
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* the optional tables */
|
|
|
|
|
|
|
|
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
2000-08-06 21:48:47 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* embedded bitmap support. */
|
|
|
|
if ( sfnt->load_sbits && LOAD_( sbits ) )
|
2000-08-06 21:48:47 +02:00
|
|
|
{
|
2000-11-07 00:07:51 +01:00
|
|
|
/* return an error if this font file has no outlines */
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
if ( error == SFNT_Err_Table_Missing && has_outline )
|
|
|
|
error = SFNT_Err_Ok;
|
2000-11-07 00:07:51 +01:00
|
|
|
else
|
2000-08-06 21:48:47 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-06-05 07:26:15 +02:00
|
|
|
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
if ( LOAD_( hdmx ) ||
|
|
|
|
LOAD_( gasp ) ||
|
|
|
|
LOAD_( kerning ) ||
|
|
|
|
LOAD_( pclt ) )
|
2000-05-28 19:15:37 +02:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
if ( ( error = TT_Extension_Create( face ) ) != SFNT_Err_Ok )
|
2000-05-28 19:15:37 +02:00
|
|
|
goto Exit;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
face->root.family_name = Get_Name( face, TT_NAME_ID_FONT_FAMILY );
|
|
|
|
face->root.style_name = Get_Name( face, TT_NAME_ID_FONT_SUBFAMILY );
|
|
|
|
|
|
|
|
/* now set up root fields */
|
|
|
|
{
|
|
|
|
FT_Face root = &face->root;
|
2000-08-06 21:48:47 +02:00
|
|
|
FT_Int flags = 0;
|
2000-05-28 19:15:37 +02:00
|
|
|
TT_CharMap charmap;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
2000-05-28 19:15:37 +02:00
|
|
|
FT_Memory memory;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
memory = root->memory;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Compute face flags. */
|
|
|
|
/* */
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( has_outline == TRUE )
|
2000-08-06 21:48:47 +02:00
|
|
|
flags = FT_FACE_FLAG_SCALABLE; /* scalable outlines */
|
|
|
|
|
|
|
|
flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */
|
|
|
|
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-07-19 19:13:03 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
2000-07-20 08:57:41 +02:00
|
|
|
/* might need more polish to detect the presence of a Postscript */
|
|
|
|
/* name table in the font */
|
2000-07-19 19:13:03 +02:00
|
|
|
flags |= FT_FACE_FLAG_GLYPH_NAMES;
|
|
|
|
#endif
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* fixed width font? */
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( face->postscript.isFixedPitch )
|
|
|
|
flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* vertical information? */
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( face->vertical_info )
|
|
|
|
flags |= FT_FACE_FLAG_VERTICAL;
|
|
|
|
|
|
|
|
/* kerning available ? */
|
|
|
|
if ( face->kern_pairs )
|
|
|
|
flags |= FT_FACE_FLAG_KERNING;
|
|
|
|
|
|
|
|
root->face_flags = flags;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Compute style flags. */
|
|
|
|
/* */
|
2000-05-28 19:15:37 +02:00
|
|
|
flags = 0;
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( has_outline == TRUE && face->os2.version != 0xFFFF )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-11-07 00:07:51 +01:00
|
|
|
/* we have an OS/2 table; use the `fsSelection' field */
|
|
|
|
if ( face->os2.fsSelection & 1 )
|
|
|
|
flags |= FT_STYLE_FLAG_ITALIC;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( face->os2.fsSelection & 32 )
|
|
|
|
flags |= FT_STYLE_FLAG_BOLD;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* this is an old Mac font, use the header field */
|
|
|
|
if ( face->header.Mac_Style & 1 )
|
|
|
|
flags |= FT_STYLE_FLAG_BOLD;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( face->header.Mac_Style & 2 )
|
|
|
|
flags |= FT_STYLE_FLAG_ITALIC;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
2000-07-05 06:32:02 +02:00
|
|
|
root->style_flags = flags;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Polish the charmaps. */
|
|
|
|
/* */
|
|
|
|
/* Try to set the charmap encoding according to the platform & */
|
|
|
|
/* encoding ID of each charmap. */
|
|
|
|
/* */
|
2000-05-28 19:15:37 +02:00
|
|
|
charmap = face->charmaps;
|
|
|
|
root->num_charmaps = face->num_charmaps;
|
|
|
|
|
|
|
|
/* allocate table of pointers */
|
|
|
|
if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( n = 0; n < root->num_charmaps; n++, charmap++ )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int platform = charmap->cmap.platformID;
|
|
|
|
FT_Int encoding = charmap->cmap.platformEncodingID;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
charmap->root.face = (FT_Face)face;
|
2001-06-19 10:28:24 +02:00
|
|
|
charmap->root.platform_id = (FT_UShort)platform;
|
|
|
|
charmap->root.encoding_id = (FT_UShort)encoding;
|
2000-06-05 07:26:15 +02:00
|
|
|
charmap->root.encoding = find_encoding( platform, encoding );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* now, set root->charmap with a unicode charmap */
|
|
|
|
/* wherever available */
|
|
|
|
if ( !root->charmap &&
|
|
|
|
charmap->root.encoding == ft_encoding_unicode )
|
2000-05-28 19:15:37 +02:00
|
|
|
root->charmap = (FT_CharMap)charmap;
|
|
|
|
|
|
|
|
root->charmaps[n] = (FT_CharMap)charmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( face->num_sbit_strikes )
|
|
|
|
{
|
2000-08-06 21:48:47 +02:00
|
|
|
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
|
2000-11-07 00:07:51 +01:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
#if 0
|
|
|
|
/* I don't know criteria whether layout is horizontal or vertical */
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( has_outline.... )
|
2000-08-06 21:48:47 +02:00
|
|
|
{
|
|
|
|
...
|
|
|
|
root->face_flags |= FT_FACE_FLAG_VERTICAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
root->num_fixed_sizes = face->num_sbit_strikes;
|
2000-11-07 00:07:51 +01:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
if ( ALLOC_ARRAY( root->available_sizes,
|
|
|
|
face->num_sbit_strikes,
|
|
|
|
FT_Bitmap_Size ) )
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
|
|
|
|
{
|
2000-07-05 06:32:02 +02:00
|
|
|
root->available_sizes[n].width =
|
2000-06-05 07:26:15 +02:00
|
|
|
face->sbit_strikes[n].x_ppem;
|
2000-11-07 00:07:51 +01:00
|
|
|
|
2000-07-05 06:32:02 +02:00
|
|
|
root->available_sizes[n].height =
|
2000-06-05 07:26:15 +02:00
|
|
|
face->sbit_strikes[n].y_ppem;
|
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
else
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-11-07 00:07:51 +01:00
|
|
|
root->num_fixed_sizes = 0;
|
|
|
|
root->available_sizes = 0;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Set up metrics. */
|
|
|
|
/* */
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( has_outline == TRUE )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-08-06 21:48:47 +02:00
|
|
|
/* XXX What about if outline header is missing */
|
|
|
|
/* (e.g. sfnt wrapped outline)? */
|
|
|
|
root->bbox.xMin = face->header.xMin;
|
|
|
|
root->bbox.yMin = face->header.yMin;
|
|
|
|
root->bbox.xMax = face->header.xMax;
|
|
|
|
root->bbox.yMax = face->header.yMax;
|
|
|
|
root->units_per_EM = face->header.Units_Per_EM;
|
|
|
|
|
2000-08-29 18:03:01 +02:00
|
|
|
|
2000-08-29 20:37:25 +02:00
|
|
|
/* XXX: Computing the ascender/descender/height is very different */
|
|
|
|
/* from what the specification tells you. Apparently, we */
|
|
|
|
/* must be careful because */
|
|
|
|
/* */
|
|
|
|
/* - not all fonts have an OS/2 table; in this case, we take */
|
|
|
|
/* the values in the horizontal header. However, these */
|
|
|
|
/* values very often are not reliable. */
|
|
|
|
/* */
|
|
|
|
/* - otherwise, the correct typographic values are in the */
|
|
|
|
/* sTypoAscender, sTypoDescender & sTypoLineGap fields. */
|
|
|
|
/* */
|
|
|
|
/* However, certains fonts have these fields set to 0. */
|
|
|
|
/* Rather, they have usWinAscent & usWinDescent correctly */
|
|
|
|
/* set (but with different values). */
|
|
|
|
/* */
|
|
|
|
/* As an example, Arial Narrow is implemented through four */
|
|
|
|
/* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */
|
|
|
|
/* */
|
|
|
|
/* Strangely, all fonts have the same values in their */
|
|
|
|
/* sTypoXXX fields, except ARIALNB which sets them to 0. */
|
|
|
|
/* */
|
|
|
|
/* On the other hand, they all have different */
|
|
|
|
/* usWinAscent/Descent values -- as a conclusion, the OS/2 */
|
|
|
|
/* table cannot be used to compute the text height reliably! */
|
|
|
|
/* */
|
2000-08-29 18:03:01 +02:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
/* The ascender/descender/height are computed from the OS/2 table */
|
|
|
|
/* when found. Otherwise, they're taken from the horizontal */
|
|
|
|
/* header. */
|
|
|
|
/* */
|
2000-08-29 18:03:01 +02:00
|
|
|
|
|
|
|
root->ascender = face->horizontal.Ascender;
|
|
|
|
root->descender = face->horizontal.Descender;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-06-19 10:28:24 +02:00
|
|
|
root->height = (FT_Short)( root->ascender - root->descender +
|
|
|
|
face->horizontal.Line_Gap );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-08-29 20:37:25 +02:00
|
|
|
/* if the line_gap is 0, we add an extra 15% to the text height -- */
|
2000-08-29 18:03:01 +02:00
|
|
|
/* this computation is based on various versions of Times New Roman */
|
2000-08-29 20:37:25 +02:00
|
|
|
if ( face->horizontal.Line_Gap == 0 )
|
2001-06-20 01:03:41 +02:00
|
|
|
root->height = (FT_Short)( ( root->height * 115 + 50 ) / 100 );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-08-29 18:03:01 +02:00
|
|
|
#if 0
|
2000-08-29 20:37:25 +02:00
|
|
|
|
2000-08-29 18:03:01 +02:00
|
|
|
/* some fonts have the OS/2 "sTypoAscender", "sTypoDescender" & */
|
|
|
|
/* "sTypoLineGap" fields set to 0, like ARIALNB.TTF */
|
|
|
|
if ( face->os2.version != 0xFFFF && root->ascender )
|
2000-08-06 21:48:47 +02:00
|
|
|
{
|
2000-08-29 18:03:01 +02:00
|
|
|
FT_Int height;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-08-29 20:37:25 +02:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
root->ascender = face->os2.sTypoAscender;
|
|
|
|
root->descender = -face->os2.sTypoDescender;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-08-29 18:03:01 +02:00
|
|
|
height = root->ascender + root->descender + face->os2.sTypoLineGap;
|
2000-08-29 20:37:25 +02:00
|
|
|
if ( height > root->height )
|
2000-08-29 18:03:01 +02:00
|
|
|
root->height = height;
|
2000-08-06 21:48:47 +02:00
|
|
|
}
|
2000-08-29 20:37:25 +02:00
|
|
|
|
|
|
|
#endif /* 0 */
|
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
root->max_advance_width = face->horizontal.advance_Width_Max;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2001-06-19 10:28:24 +02:00
|
|
|
root->max_advance_height = (FT_Short)( face->vertical_info
|
2000-08-06 21:48:47 +02:00
|
|
|
? face->vertical.advance_Height_Max
|
2001-06-19 10:28:24 +02:00
|
|
|
: root->height );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-08-06 21:48:47 +02:00
|
|
|
root->underline_position = face->postscript.underlinePosition;
|
|
|
|
root->underline_thickness = face->postscript.underlineThickness;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-08-29 20:37:25 +02:00
|
|
|
/* root->max_points -- already set up */
|
|
|
|
/* root->max_contours -- already set up */
|
2000-08-06 21:48:47 +02:00
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOAD_
|
|
|
|
|
|
|
|
|
2001-06-28 01:25:46 +02:00
|
|
|
FT_LOCAL_DEF void
|
|
|
|
SFNT_Done_Face( TT_Face face )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = face->root.memory;
|
2000-07-05 06:32:02 +02:00
|
|
|
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
|
|
|
if ( sfnt )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-05 07:26:15 +02:00
|
|
|
/* destroy the postscript names table if it is loaded */
|
|
|
|
if ( sfnt->free_psnames )
|
2000-05-28 19:15:37 +02:00
|
|
|
sfnt->free_psnames( face );
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* destroy the embedded bitmaps table if it is loaded */
|
|
|
|
if ( sfnt->free_sbits )
|
2000-05-28 19:15:37 +02:00
|
|
|
sfnt->free_sbits( face );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* freeing the kerning table */
|
|
|
|
FREE( face->kern_pairs );
|
|
|
|
face->num_kern_pairs = 0;
|
|
|
|
|
|
|
|
/* freeing the collection table */
|
2000-07-19 08:25:56 +02:00
|
|
|
FREE( face->ttc_header.offsets );
|
|
|
|
face->ttc_header.count = 0;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* freeing table directory */
|
|
|
|
FREE( face->dir_tables );
|
|
|
|
face->num_tables = 0;
|
|
|
|
|
|
|
|
/* freeing the character mapping tables */
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( sfnt && sfnt->load_charmaps )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort n;
|
2000-06-05 07:26:15 +02:00
|
|
|
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
for ( n = 0; n < face->num_charmaps; n++ )
|
|
|
|
sfnt->free_charmap( face, &face->charmaps[n].cmap );
|
|
|
|
}
|
|
|
|
|
|
|
|
FREE( face->charmaps );
|
|
|
|
face->num_charmaps = 0;
|
|
|
|
|
|
|
|
FREE( face->root.charmaps );
|
|
|
|
face->root.num_charmaps = 0;
|
|
|
|
face->root.charmap = 0;
|
|
|
|
|
|
|
|
/* freeing the horizontal metrics */
|
|
|
|
FREE( face->horizontal.long_metrics );
|
|
|
|
FREE( face->horizontal.short_metrics );
|
|
|
|
|
|
|
|
/* freeing the vertical ones, if any */
|
|
|
|
if ( face->vertical_info )
|
|
|
|
{
|
|
|
|
FREE( face->vertical.long_metrics );
|
|
|
|
FREE( face->vertical.short_metrics );
|
|
|
|
face->vertical_info = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* freeing the gasp table */
|
|
|
|
FREE( face->gasp.gaspRanges );
|
|
|
|
face->gasp.numRanges = 0;
|
|
|
|
|
|
|
|
/* freeing the name table */
|
|
|
|
sfnt->free_names( face );
|
|
|
|
|
|
|
|
/* freeing the hdmx table */
|
|
|
|
sfnt->free_hdmx( face );
|
|
|
|
|
|
|
|
/* freeing family and style name */
|
|
|
|
FREE( face->root.family_name );
|
|
|
|
FREE( face->root.style_name );
|
|
|
|
|
|
|
|
/* freeing sbit size table */
|
|
|
|
face->root.num_fixed_sizes = 0;
|
|
|
|
if ( face->root.available_sizes )
|
|
|
|
FREE( face->root.available_sizes );
|
|
|
|
|
|
|
|
face->sfnt = 0;
|
|
|
|
}
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
|
|
|
/* END */
|