diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-03-29 12:18:05 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-03-29 12:18:05 +0000 |
commit | aac0cb6678133a932a3a676c35349b9b0297803a (patch) | |
tree | d44b803a2bf52afe689923df93d1df908717cd9e | |
parent | 0042f82b364d96f6c4747de481945d40e082a2d1 (diff) | |
download | xorg-lib-libXft-aac0cb6678133a932a3a676c35349b9b0297803a.tar.gz |
merge with XORG-RELEASE-1
-rw-r--r-- | include/X11/Xft/Xft.h | 2 | ||||
-rw-r--r-- | src/xftfreetype.c | 53 |
2 files changed, 33 insertions, 22 deletions
diff --git a/include/X11/Xft/Xft.h b/include/X11/Xft/Xft.h index d495b58..1c67265 100644 --- a/include/X11/Xft/Xft.h +++ b/include/X11/Xft/Xft.h @@ -33,7 +33,7 @@ #define XFT_MAJOR 2 #define XFT_MINOR 1 -#define XFT_REVISION 5 +#define XFT_REVISION 6 #define XFT_VERSION ((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION)) #define XftVersion XFT_VERSION diff --git a/src/xftfreetype.c b/src/xftfreetype.c index d6285b4..1a52c21 100644 --- a/src/xftfreetype.c +++ b/src/xftfreetype.c @@ -182,6 +182,14 @@ _XftUnlockFile (XftFtFile *f) _XftLockError ("too many file unlocks"); } +#if HAVE_FT_BITMAP_SIZE_Y_PPEM +#define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem) +#define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem) +#else +#define X_SIZE(face,i) ((face)->available_sizes[i].width << 6) +#define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6) +#endif + FcBool _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix) { @@ -198,39 +206,42 @@ _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix */ if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) { - FT_Short width = xsize >> 6; - FT_Short height = ysize >> 6; - int i, best = -1; + int i, best = 0; #define xft_abs(a) ((a) < 0 ? -(a) : (a)) #define dist(a,b) (xft_abs((a)-(b))) -#if !HAVE_FT_BITMAP_SIZE_Y_PPEM -#define y_ppem height -#define x_ppem width -#endif - for (i = 0; i < face->num_fixed_sizes; i++) + for (i = 1; i < face->num_fixed_sizes; i++) { - if (best == -1 || - dist (height, face->available_sizes[i].y_ppem >> 6) < - dist (height, face->available_sizes[best].y_ppem >> 6) || - (dist (height, face->available_sizes[i].y_ppem >> 6) == - dist (height, face->available_sizes[best].y_ppem >> 6) && - dist (width, face->available_sizes[i].x_ppem >> 6) < - dist (width, face->available_sizes[best].x_ppem >> 6))) + if (dist (ysize, Y_SIZE(face,i)) < + dist (ysize, Y_SIZE(face, best)) || + (dist (ysize, Y_SIZE(face, i)) == + dist (ysize, Y_SIZE(face, best)) && + dist (xsize, X_SIZE(face, i)) < + dist (xsize, X_SIZE(face, best)))) { best = i; } } - if (FT_Set_Char_Size (face, face->available_sizes[best].x_ppem, - face->available_sizes[best].y_ppem, 0, 0) != 0) + /* + * Freetype 2.1.7 and earlier used width/height + * for matching sizes in the BDF and PCF loaders. + * This has been fixed for 2.1.8. Because BDF and PCF + * files have but a single strike per file, we can + * simply try both sizes. + */ + if ( +#if HAVE_FT_BITMAP_SIZE_Y_PPEM + FT_Set_Char_Size (face, face->available_sizes[best].x_ppem, + face->available_sizes[best].y_ppem, 0, 0) != 0 + && +#endif + FT_Set_Char_Size (face, face->available_sizes[best].width << 6, + face->available_sizes[best].height << 6, + 0, 0) != 0) { return False; } -#if !HAVE_FT_BITMAP_SIZE_Y_PPEM -#undef y_ppem -#undef x_ppem -#endif } else { |