forked from enlightenment/efl
and in my continuing foxes for bitmap font loading... correctly chose
the closest of N sizes. SVN revision: 72055
This commit is contained in:
parent
0d33c5eb19
commit
6746b071d1
|
@ -378,43 +378,48 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
|
||||||
fi->real_size = fi->size * 64;
|
fi->real_size = fi->size * 64;
|
||||||
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi);
|
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
|
||||||
fi->real_size = fi->size;
|
|
||||||
error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
|
error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
|
||||||
}
|
|
||||||
FTUNLOCK();
|
FTUNLOCK();
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
int i;
|
int i, maxd = 0x7fffffff;
|
||||||
int chosen_size = 0;
|
int chosen_size = 0;
|
||||||
int chosen_width = 0;
|
int chosen_size2 = 0;
|
||||||
|
|
||||||
for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++)
|
for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++)
|
||||||
{
|
{
|
||||||
int s;
|
int s, cd;
|
||||||
int d, cd;
|
|
||||||
|
|
||||||
s = fi->src->ft.face->available_sizes[i].height;
|
s = fi->src->ft.face->available_sizes[i].size;
|
||||||
cd = chosen_size - fi->size;
|
cd = chosen_size - fi->real_size;
|
||||||
if (cd < 0) cd = -cd;
|
if (cd < 0) cd = -cd;
|
||||||
d = s - fi->size;
|
if (cd < maxd)
|
||||||
if (d < 0) d = -d;
|
|
||||||
if (d < cd)
|
|
||||||
{
|
{
|
||||||
chosen_width = fi->src->ft.face->available_sizes[i].width;
|
maxd = cd;
|
||||||
chosen_size = s;
|
chosen_size = s;
|
||||||
|
chosen_size2 = fi->src->ft.face->available_sizes[i].y_ppem;
|
||||||
|
if (maxd == 0) break;
|
||||||
}
|
}
|
||||||
if (d == 0) break;
|
|
||||||
}
|
}
|
||||||
fi->real_size = chosen_size;
|
fi->real_size = chosen_size;
|
||||||
FTLOCK();
|
FTLOCK();
|
||||||
error = FT_Set_Pixel_Sizes(fi->src->ft.face, chosen_width, fi->real_size);
|
error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
|
||||||
FTUNLOCK();
|
FTUNLOCK();
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
/* hack around broken fonts */
|
||||||
|
fi->real_size = (chosen_size2 / 64) * 60;
|
||||||
|
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
/* couldn't choose the size anyway... what now? */
|
/* couldn't choose the size anyway... what now? */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
fi->src->current_size = 0;
|
fi->src->current_size = 0;
|
||||||
fi->max_h = 0;
|
fi->max_h = 0;
|
||||||
val = (int)fi->src->ft.face->bbox.yMax;
|
val = (int)fi->src->ft.face->bbox.yMax;
|
||||||
|
|
Loading…
Reference in New Issue