ref: 0a29c6979de1e9aca582407c470d505fc7232a4c
parent: c91cfe1100d6de610e01176e4d96909026604d12
author: David Turner <[email protected]>
date: Fri May 12 13:09:38 EDT 2000
implemented FT_Select_Charmap and FT_Set_Charmap (at last :-)
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1990,15 +1990,52 @@
-/* XXX : Not implemented yet, but should come soon */
-#if 0
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Select_Charmap */
+ /* */
+ /* <Description> */
+ /* Selects a given charmap by its encoding tag. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* encoding :: handle to the selected charmap */
+ /* */
+ /* <Return> */
+ /* Error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* 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
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Set_Charmap */
+ /* */
+ /* <Description> */
+ /* Selects a given charmap for character code to glyph index */
+ /* decoding. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* charmap :: handle to the selected charmap */
+ /* */
+ /* <Return> */
+ /* Error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* 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 );
/*************************************************************************/
/* */
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1916,6 +1916,80 @@
return error;
}
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Select_Charmap */
+ /* */
+ /* <Description> */
+ /* Selects a given charmap by its encoding tag. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* encoding :: handle to the selected charmap */
+ /* */
+ /* <Return> */
+ /* Error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* 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;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Set_Charmap */
+ /* */
+ /* <Description> */
+ /* Selects a given charmap for character code to glyph index */
+ /* decoding. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face object. */
+ /* charmap :: handle to the selected charmap */
+ /* */
+ /* <Return> */
+ /* Error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* 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;
+ }
/*************************************************************************/
/* */