diff -Burb fontconfig-2.2.3.orig/src/fcfreetype.c fontconfig-2.2.3/src/fcfreetype.c --- fontconfig-2.2.3.orig/src/fcfreetype.c Tue Aug 22 12:26:07 2006 +++ fontconfig-2.2.3/src/fcfreetype.c Wed Aug 23 12:02:38 2006 @@ -1538,8 +1538,53 @@ FT_UInt glyph, FcBlanks *blanks, FT_Pos *advance) { - FT_Int load_flags = FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; + FT_Int load_flags = FT_LOAD_NO_HINTING; FT_GlyphSlot slot; + char *s0, *s1; + FT_Int bitmap_size = -1; + + + s0 = getenv( "FC_BITMAP_SIZE" ); + /* lookup strike_index for given bitmap pixel size */ + while ( s0 != NULL && '\0' != s0[0] ) + { + bitmap_size = strtol( s0, &s1, 10 ); + if ( 0 == bitmap_size && 0 != ( face->face_flags & FT_FACE_FLAG_SCALABLE ) ) + { + load_flags |= ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ); + goto verify_loading; + } + else if ( LONG_MIN != bitmap_size && LONG_MAX != bitmap_size ) + { +#ifdef HAVE_FT_SELECT_SIZE + int i; + for ( i = 0; i < face->num_fixed_sizes; i++ ) + { + if ( bitmap_size == face->available_sizes[i].height ) + { + if ( FT_Err_Ok == FT_Select_Size( face, i ) ) + goto verify_loading; + } + } +#else + /* + * XXX: DANGER HOOK FOR LEGACY FREETYPE-2.1.X + * To check the exist of bitmap glyph at specified size + * switch FT_FACE_FLAG_SCALABLE off forcibly. As a result, + * FT_Set_Pixel_Sizes() cannot use outline glyph for fallback. + */ + FT_Error status; + FT_Long orig_face_flags = face->face_flags; + face->face_flags = face->face_flags ^ FT_FACE_FLAG_SCALABLE ; + status = FT_Set_Pixel_Sizes( face, bitmap_size, bitmap_size ) ; + face->face_flags = orig_face_flags ; + if ( FT_Err_Ok == status ) + goto verify_loading; +#endif + } + s0 = strpbrk( s1, "0123456789" ); + } + load_flags |= FT_LOAD_NO_SCALE; /* * When using scalable fonts, only report those glyphs @@ -1551,6 +1596,7 @@ if (face->face_flags & FT_FACE_FLAG_SCALABLE) load_flags |= FT_LOAD_NO_BITMAP; +verify_loading: if (FT_Load_Glyph (face, glyph, load_flags)) return FcFalse; @@ -1569,6 +1615,12 @@ */ return FcTrue; case ft_glyph_format_outline: + /* + * Exclude fallback outline data when we tried to + * load bitmap data. + */ + if ( 0 == ( load_flags & FT_LOAD_NO_SCALE ) ) + return FcFalse; /* * Glyphs with contours are always OK */