Add back code for choosing strike, and cleanup

The FT_Select_Size() call is important for bitmap-only fonts.
Put it back.  It was removed in e327c4e54544dac5415e8864e80d6b75a0c900fd
Remove some unused abstractions.
This commit is contained in:
Behdad Esfahbod 2017-08-04 14:43:16 +01:00
parent cd4043da0d
commit 659afb2987
1 changed files with 19 additions and 27 deletions

View File

@ -2202,17 +2202,13 @@ static FcBool
FcFreeTypeCheckGlyph (FT_Face face, FcFreeTypeCheckGlyph (FT_Face face,
FcChar32 ucs4, FcChar32 ucs4,
FT_UInt glyph, FcBlanks *blanks, FT_UInt glyph, FcBlanks *blanks,
FT_Pos *advance, FT_Pos *advance)
FcBool using_strike)
{ {
FT_Int load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; FT_Int load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
if (!glyph) if (!glyph)
return FcFalse; return FcFalse;
if (using_strike)
load_flags &= ~FT_LOAD_NO_SCALE;
/* /*
* When using scalable fonts, only report those glyphs * When using scalable fonts, only report those glyphs
* which can be scaled; otherwise those fonts will * which can be scaled; otherwise those fonts will
@ -2246,11 +2242,8 @@ FcFreeTypeCheckGlyph (FT_Face face,
#define APPROXIMATELY_EQUAL(x,y) (FC_ABS ((x) - (y)) <= FC_MAX (FC_ABS (x), FC_ABS (y)) / 33) #define APPROXIMATELY_EQUAL(x,y) (FC_ABS ((x) - (y)) <= FC_MAX (FC_ABS (x), FC_ABS (y)) / 33)
static FcCharSet * FcCharSet *
FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
FcBlanks *blanks,
int *spacing,
FT_Int strike_index)
{ {
FcChar32 page, off, ucs4; FcChar32 page, off, ucs4;
#ifdef CHECK #ifdef CHECK
@ -2262,17 +2255,27 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face,
FT_UInt glyph; FT_UInt glyph;
FT_Pos advance, advance_one = 0, advance_two = 0; FT_Pos advance, advance_one = 0, advance_two = 0;
FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse; FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse;
FcBool using_strike = FcFalse;
fcs = FcCharSetCreate (); fcs = FcCharSetCreate ();
if (!fcs) if (!fcs)
goto bail0; goto bail0;
#if HAVE_FT_SELECT_SIZE #if HAVE_FT_SELECT_SIZE
if (strike_index >= 0) { if (!(face->face_flags & FT_FACE_FLAG_SCALABLE) &&
face->num_fixed_sizes > 0 &&
FT_Get_Sfnt_Table (face, ft_sfnt_head))
{
FT_Int strike_index = 0, i;
/* Select the face closest to 16 pixels tall */
for (i = 1; i < face->num_fixed_sizes; i++)
{
if (abs (face->available_sizes[i].height - 16) <
abs (face->available_sizes[strike_index].height - 16))
strike_index = i;
}
if (FT_Select_Size (face, strike_index) != FT_Err_Ok) if (FT_Select_Size (face, strike_index) != FT_Err_Ok)
goto bail1; goto bail1;
using_strike = FcTrue;
} }
#endif #endif
@ -2290,7 +2293,7 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face,
ucs4 = FT_Get_First_Char (face, &glyph); ucs4 = FT_Get_First_Char (face, &glyph);
while (glyph != 0) while (glyph != 0)
{ {
if (FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance, using_strike)) if (FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
{ {
if (advance) if (advance)
{ {
@ -2376,7 +2379,7 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face,
{ {
ucs4 = FcGlyphNameToUcs4 (name_buf); ucs4 = FcGlyphNameToUcs4 (name_buf);
if (ucs4 != 0xffff && if (ucs4 != 0xffff &&
FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance, using_strike)) FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
{ {
if (advance) if (advance)
{ {
@ -2419,7 +2422,7 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face,
if (has_char && !has_bit) if (has_char && !has_bit)
{ {
if (!FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance, using_strike)) if (!FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
printf ("Bitmap missing broken char 0x%x\n", ucs4); printf ("Bitmap missing broken char 0x%x\n", ucs4);
else else
printf ("Bitmap missing char 0x%x\n", ucs4); printf ("Bitmap missing char 0x%x\n", ucs4);
@ -2441,17 +2444,6 @@ bail0:
return 0; return 0;
} }
FcCharSet *
FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
{
FcCharSet *cs;
FT_Int strike_index = -1;
cs = FcFreeTypeCharSetAndSpacingForSize (face, blanks, spacing, strike_index);
return cs;
}
FcCharSet * FcCharSet *
FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks) FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks)
{ {