I found the problem with FreeType on my machine. The pike module
never selects any CharMap, and in this freetype version the default
seems to be "no charmap", i.e. FT_Load_Char() will interpret the
argument as a glyph number.
This patch fixed the problem for me, could somebody who _already has a
working FreeType module_ try it out and see if it breaks anything for
them?
Index: src/modules/_Image_FreeType/freetype.c
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.4/src/modules/_Image_FreeType/freetype.c,v
retrieving revision 1.13
diff -u -r1.13 freetype.c
--- freetype.c 2002/11/29 20:56:46 1.13
+++ freetype.c 2003/01/15 13:45:03
@@ -199,6 +199,8 @@
static void image_ft_face_create( INT32 args )
{
int er;
+ FT_Encoding best_enc = ft_encoding_none;
+ int enc_no, enc_score, best_enc_score = -2;
if( !args || sp[-args].type != T_STRING )
Pike_error("Illegal argument 1 to FreeType.Face. Expected string.\n");
er = FT_New_Face( library, sp[-args].u.string->str, 0, &TFACE );
@@ -206,6 +208,22 @@
Pike_error( "Failed to parse the font file %s\n", sp[-args].u.string->str );
else if( er )
Pike_error( "Failed to open the font file %s\n", sp[-args].u.string->str );
+ for(enc_no=0; enc_no<TFACE->num_charmaps; enc_no++) {
+ enc_score = 0;
+ switch(TFACE->charmaps[enc_no]->encoding) {
+ case ft_encoding_symbol: enc_score = -1; break;
+ case ft_encoding_unicode: enc_score = 2; break;
+ case ft_encoding_latin_1: enc_score = 1; break;
+ }
+ if(enc_score > best_enc_score) {
+ best_enc_score = enc_score;
+ best_enc = TFACE->charmaps[enc_no]->encoding;
+ }
+ }
+ er = FT_Select_Charmap(TFACE, best_enc);
+ if( er )
+ Pike_error( "Failed to set a character map for the font %s\n",
+ sp[-args].u.string->str );
pop_n_elems( args );
push_int( 0 );
}