* include/freetype/internal/ftobjs.h,

src/sfnt/Jamfile, src/sfnt/rules.mk,
          src/sfnt/sfnt.c, src/sfnt/sfobjs.c,
          src/sfnt/ttload.c, src/sfnt/ttcmap0.c, src/sfnt/ttcmap0.h:

            updated the SFNT charmap support to use FT_CMaps
This commit is contained in:
David Turner 2002-03-22 15:02:38 +00:00
parent d6c9e0c806
commit 24abcf885b
9 changed files with 332 additions and 235 deletions

View File

@ -1,5 +1,13 @@
2002-03-22 David Turner <david@freetype.org>
* include/freetype/internal/ftobjs.h,
src/sfnt/Jamfile, src/sfnt/rules.mk,
src/sfnt/sfnt.c, src/sfnt/sfobjs.c,
src/sfnt/ttload.c, src/sfnt/ttcmap0.c, src/sfnt/ttcmap0.h:
updated the SFNT charmap support to use FT_CMaps
* include/freetype/config/ftheader.h, include/freetype/fterrors.h:
modified "fterrors.h" to include the error definitions list found
in "fterrdef.h"

View File

@ -157,16 +157,20 @@ FT_BEGIN_HEADER
#define FT_INVALID(_error) ft_validator_error( valid, _error )
/* called when a broken table is detected */
#define FT_INVALID_TOO_SHORT FT_INVALID( FT_Err_Invalid_Format )
#define FT_INVALID_TOO_SHORT FT_INVALID( FT_Err_Invalid_Table )
/* called when an invalid offset is detected */
#define FT_INVALID_OFFSET FT_INVALID( FT_Err_Invalid_Offset )
/* called when an invalid format/value is detected */
#define FT_INVALID_FORMAT FT_INVALID( FT_Err_Invalid_Format )
#define FT_INVALID_FORMAT FT_INVALID( FT_Err_Invalid_Table )
/* called when an invalid glyph index is detected */
#define FT_INVALID_GLYPH_ID FT_INVALID( FT_Err_Invalid_Glyph_Id )
#define FT_INVALID_GLYPH_ID FT_INVALID( FT_Err_Invalid_Glyph_Index )
/* called when an invalid field value is detected */
#define FT_INVALID_DATA FT_INVALID( FT_Err_Invalid_Table )
/*************************************************************************/

View File

@ -10,7 +10,7 @@ SubDirHdrs [ FT2_SubDir src sfnt ] ;
if $(FT2_MULTI)
{
_sources = sfobjs sfdriver ttcmap ttpost ttload ttsbit ;
_sources = sfobjs sfdriver ttcmap ttcmap0 ttpost ttload ttsbit ;
}
else
{

View File

@ -28,6 +28,7 @@ SFNT_COMPILE := $(FT_COMPILE) $I$(SFNT_DIR)
#
SFNT_DRV_SRC := $(SFNT_DIR_)ttload.c \
$(SFNT_DIR_)ttcmap.c \
$(SFNT_DIR_)ttcmap0.c \
$(SFNT_DIR_)ttsbit.c \
$(SFNT_DIR_)ttpost.c \
$(SFNT_DIR_)sfobjs.c \

View File

@ -21,6 +21,7 @@
#include <ft2build.h>
#include "ttload.c"
#include "ttcmap.c"
#include "ttcmap0.c"
#include "sfobjs.c"
#include "sfdriver.c"

View File

@ -40,7 +40,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* Get_Name */
/* tt_face_get_name */
/* */
/* <Description> */
/* Returns a given ENGLISH name record in ASCII. */
@ -54,7 +54,7 @@
/* Character string. NULL if no name is present. */
/* */
static FT_String*
Get_Name( TT_Face face,
tt_face_get_name( TT_Face face,
FT_UShort nameid )
{
FT_Memory memory = face->root.memory;
@ -155,8 +155,8 @@
static FT_Encoding
find_encoding( int platform_id,
int encoding_id )
sfnt_find_encoding( int platform_id,
int encoding_id )
{
typedef struct TEncoding
{
@ -377,8 +377,8 @@
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 );
face->root.family_name = tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY );
face->root.style_name = tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY );
/* now set up root fields */
{
@ -454,6 +454,33 @@
/* Try to set the charmap encoding according to the platform & */
/* encoding ID of each charmap. */
/* */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
error = TT_Build_CMaps( face );
if (error) goto Exit;
/* set the encoding fields */
{
FT_UInt n;
for ( n = 0; n < root->num_charmaps; n++ )
{
FT_CharMap charmap = root->charmaps[n];
charmap->encoding = sfnt_find_encoding( charmap->platform_id,
charmap->encoding_id );
if ( root->charmap == NULL &&
charmap->encoding == ft_encoding_unicode )
{
/* set 'root->charmap' to the first Unicode encoding we find */
root->charmap = charmap;
}
}
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
charmap = face->charmaps;
root->num_charmaps = face->num_charmaps;
@ -470,7 +497,7 @@
charmap->root.face = (FT_Face)face;
charmap->root.platform_id = (FT_UShort)platform;
charmap->root.encoding_id = (FT_UShort)encoding;
charmap->root.encoding = find_encoding( platform, encoding );
charmap->root.encoding = sfnt_find_encoding( platform, encoding );
/* now, set root->charmap with a unicode charmap */
/* wherever available */
@ -481,6 +508,9 @@
root->charmaps[n] = (FT_CharMap)charmap;
}
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
if ( face->num_sbit_strikes )
@ -646,6 +676,18 @@
FT_FREE( face->dir_tables );
face->num_tables = 0;
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{
FT_Stream stream = FT_FACE_STREAM(face);
/* simply release the 'cmap' table frame */
FT_FRAME_RELEASE( face->cmap_table );
face->cmap_size = 0;
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
/* freeing the character mapping tables */
if ( sfnt && sfnt->load_charmaps )
{
@ -663,6 +705,8 @@
face->root.num_charmaps = 0;
face->root.charmap = 0;
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
/* freeing the horizontal metrics */
FT_FREE( face->horizontal.long_metrics );
FT_FREE( face->horizontal.short_metrics );

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,8 @@
/***************************************************************************/
#ifndef __TTCMAP_H__
#define __TTCMAP_H__
#ifndef __TTCMAP0_H__
#define __TTCMAP0_H__
#include <ft2build.h>
@ -30,7 +30,7 @@ FT_BEGIN_HEADER
typedef struct TT_CMapRec_
{
FT_CMapRec cmap;
FT_Byte* data;
FT_Byte* data; /* pointer to in-memory cmap table */
} TT_CMapRec, *TT_CMap;
@ -47,14 +47,24 @@ FT_BEGIN_HEADER
} TT_CMap_ClassRec;
typedef struct TT_ValidatorRec_
{
FT_Validator validator;
FT_UInt num_glyphs;
} TT_ValidatorRec, *TT_Validator;
#define TT_VALIDATOR(x) ((TT_Validator)(x))
#define TT_VALID_GLYPH_COUNT(v) TT_VALIDATOR(v)->num_glyphs
FT_LOCAL( FT_Error )
TT_Build_CMaps( TT_Face face )
TT_Build_CMaps( TT_Face face );
FT_END_HEADER
#endif /* __TTCMAP_H__ */
#endif /* __TTCMAP0_H__ */
/* END */

View File

@ -1120,6 +1120,40 @@
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
FT_LOCAL_DEF( FT_Error )
TT_Load_CMap( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_Long table_start;
TT_CMapDirRec cmap_dir;
error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
if ( error )
{
FT_TRACE2(( "No 'cmap' table in font !\n" ));
error = SFNT_Err_CMap_Table_Missing;
goto Exit;
}
if ( !FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
FT_TRACE2(( "'cmap' table loaded\n" ));
else
{
FT_ERROR(( "'cmap' table is too short !!\n" ));
face->cmap_size = 0;
}
Exit:
return error;
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
FT_LOCAL_DEF( FT_Error )
TT_Load_CMap( TT_Face face,
FT_Stream stream )
@ -1216,6 +1250,7 @@
return error;
}
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
/*************************************************************************/
/* */