From 0a29c6979de1e9aca582407c470d505fc7232a4c Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 12 May 2000 17:09:38 +0000 Subject: [PATCH] implemented FT_Select_Charmap and FT_Set_Charmap (at last :-) --- include/freetype/freetype.h | 47 ++++++++++++++++++++--- src/base/ftobjs.c | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 5 deletions(-) diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index a66f0527a..b7b3a04d9 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -1990,15 +1990,52 @@ -/* XXX : Not implemented yet, but should come soon */ -#if 0 + /*************************************************************************/ + /* */ + /* */ + /* FT_Select_Charmap */ + /* */ + /* */ + /* Selects a given charmap by its encoding tag. */ + /* */ + /* */ + /* face :: A handle to the source face object. */ + /* encoding :: handle to the selected charmap */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + /* */ + /* This function will return an error if no charmap in the face */ + /* corresponds to the encoding queried here */ + /* */ EXPORT_DEF(FT_Error) FT_Select_Charmap( FT_Face face, FT_Encoding encoding ); - EXPORT_DEF(FT_Error) FT_Error FT_Set_Charmap( FT_Face face, - FT_CharMap charmap ); -#endif + /*************************************************************************/ + /* */ + /* */ + /* FT_Set_Charmap */ + /* */ + /* */ + /* Selects a given charmap for character code to glyph index */ + /* decoding. */ + /* */ + /* */ + /* face :: A handle to the source face object. */ + /* charmap :: handle to the selected charmap */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + /* */ + /* this function will return an error when the charmap is not part */ + /* of the face (i.e. if it is not listed in the face->charmaps[] */ + /* table). */ + /* */ + EXPORT_DEF(FT_Error) FT_Set_Charmap( FT_Face face, + FT_CharMap charmap ); /*************************************************************************/ /* */ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 401c39f0b..29caeeaa8 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1916,6 +1916,80 @@ return error; } + /*************************************************************************/ + /* */ + /* */ + /* FT_Select_Charmap */ + /* */ + /* */ + /* Selects a given charmap by its encoding tag. */ + /* */ + /* */ + /* face :: A handle to the source face object. */ + /* encoding :: handle to the selected charmap */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + /* */ + /* This function will return an error if no charmap in the face */ + /* corresponds to the encoding queried here */ + /* */ + EXPORT_FUNC(FT_Error) FT_Select_Charmap( FT_Face face, + FT_Encoding encoding ) + { + FT_CharMap* cur = face->charmaps; + FT_CharMap* limit = cur + face->num_charmaps; + + for ( ; cur < limit; cur++ ) + { + if ( cur[0]->encoding == encoding ) + { + face->charmap = cur[0]; + return 0; + } + } + return FT_Err_Invalid_Argument; + } + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Set_Charmap */ + /* */ + /* */ + /* Selects a given charmap for character code to glyph index */ + /* decoding. */ + /* */ + /* */ + /* face :: A handle to the source face object. */ + /* charmap :: handle to the selected charmap */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + /* */ + /* this function will return an error when the charmap is not part */ + /* of the face (i.e. if it is not listed in the face->charmaps[] */ + /* table). */ + /* */ + EXPORT_FUNC(FT_Error) FT_Set_Charmap( FT_Face face, + FT_CharMap charmap ) + { + FT_CharMap* cur = face->charmaps; + FT_CharMap* limit = cur + face->num_charmaps; + + for ( ; cur < limit; cur++ ) + { + if ( cur[0] == charmap ) + { + face->charmap = cur[0]; + return 0; + } + } + return FT_Err_Invalid_Argument; + } /*************************************************************************/ /* */