|
|
|
@ -87,6 +87,7 @@ struct hb_ft_font_t |
|
|
|
|
int load_flags; |
|
|
|
|
bool symbol; /* Whether selected cmap is symbol cmap. */ |
|
|
|
|
bool unref; /* Whether to destroy ft_face when done. */ |
|
|
|
|
bool transform; /* Whether to apply FT_Face's transform. */ |
|
|
|
|
|
|
|
|
|
mutable hb_mutex_t lock; |
|
|
|
|
FT_Face ft_face; |
|
|
|
@ -138,6 +139,8 @@ _hb_ft_font_destroy (void *data) |
|
|
|
|
/* hb_font changed, update FT_Face. */ |
|
|
|
|
static void _hb_ft_hb_font_changed (hb_font_t *font, FT_Face ft_face) |
|
|
|
|
{ |
|
|
|
|
hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data; |
|
|
|
|
|
|
|
|
|
float x_mult = 1.f, y_mult = 1.f; |
|
|
|
|
|
|
|
|
|
if (font->x_scale < 0) x_mult = -x_mult; |
|
|
|
@ -175,6 +178,7 @@ static void _hb_ft_hb_font_changed (hb_font_t *font, FT_Face ft_face) |
|
|
|
|
FT_Matrix matrix = { (int) roundf (x_mult * (1<<16)), 0, |
|
|
|
|
0, (int) roundf (y_mult * (1<<16))}; |
|
|
|
|
FT_Set_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
ft_font->transform = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(HAVE_FT_GET_VAR_BLEND_COORDINATES) && !defined(HB_NO_VAR) |
|
|
|
@ -430,13 +434,19 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, |
|
|
|
|
hb_lock_t lock (ft_font->lock); |
|
|
|
|
FT_Face ft_face = ft_font->ft_face; |
|
|
|
|
int load_flags = ft_font->load_flags; |
|
|
|
|
float x_mult; |
|
|
|
|
#ifdef HAVE_FT_GET_TRANSFORM |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
float x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; |
|
|
|
|
#else |
|
|
|
|
float x_mult = font->x_scale < 0 ? -1 : +1; |
|
|
|
|
if (ft_font->transform) |
|
|
|
|
{ |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
#endif |
|
|
|
|
{ |
|
|
|
|
x_mult = font->x_scale < 0 ? -1 : +1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
|
{ |
|
|
|
@ -468,13 +478,19 @@ hb_ft_get_glyph_v_advance (hb_font_t *font, |
|
|
|
|
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; |
|
|
|
|
hb_lock_t lock (ft_font->lock); |
|
|
|
|
FT_Fixed v; |
|
|
|
|
float y_mult; |
|
|
|
|
#ifdef HAVE_FT_GET_TRANSFORM |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_font->ft_face, &matrix, nullptr); |
|
|
|
|
float y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
#else |
|
|
|
|
float y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
if (ft_font->transform) |
|
|
|
|
{ |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_font->ft_face, &matrix, nullptr); |
|
|
|
|
y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
#endif |
|
|
|
|
{ |
|
|
|
|
y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (unlikely (FT_Get_Advance (ft_font->ft_face, glyph, ft_font->load_flags | FT_LOAD_VERTICAL_LAYOUT, &v))) |
|
|
|
|
return 0; |
|
|
|
@ -500,15 +516,21 @@ hb_ft_get_glyph_v_origin (hb_font_t *font, |
|
|
|
|
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; |
|
|
|
|
hb_lock_t lock (ft_font->lock); |
|
|
|
|
FT_Face ft_face = ft_font->ft_face; |
|
|
|
|
float x_mult, y_mult; |
|
|
|
|
#ifdef HAVE_FT_GET_TRANSFORM |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
float x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; |
|
|
|
|
float y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
#else |
|
|
|
|
float x_mult = font->x_scale < 0 ? -1 : +1; |
|
|
|
|
float y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
if (ft_font->transform) |
|
|
|
|
{ |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; |
|
|
|
|
y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
#endif |
|
|
|
|
{ |
|
|
|
|
x_mult = font->x_scale < 0 ? -1 : +1; |
|
|
|
|
y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) |
|
|
|
|
return false; |
|
|
|
@ -555,15 +577,21 @@ hb_ft_get_glyph_extents (hb_font_t *font, |
|
|
|
|
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; |
|
|
|
|
hb_lock_t lock (ft_font->lock); |
|
|
|
|
FT_Face ft_face = ft_font->ft_face; |
|
|
|
|
float x_mult, y_mult; |
|
|
|
|
#ifdef HAVE_FT_GET_TRANSFORM |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
float x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; |
|
|
|
|
float y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
#else |
|
|
|
|
float x_mult = font->x_scale < 0 ? -1 : +1; |
|
|
|
|
float y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
if (ft_font->transform) |
|
|
|
|
{ |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; |
|
|
|
|
y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
#endif |
|
|
|
|
{ |
|
|
|
|
x_mult = font->x_scale < 0 ? -1 : +1; |
|
|
|
|
y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) |
|
|
|
|
return false; |
|
|
|
@ -665,13 +693,19 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED, |
|
|
|
|
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; |
|
|
|
|
hb_lock_t lock (ft_font->lock); |
|
|
|
|
FT_Face ft_face = ft_font->ft_face; |
|
|
|
|
float y_mult; |
|
|
|
|
#ifdef HAVE_FT_GET_TRANSFORM |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
float y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
#else |
|
|
|
|
float y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
if (ft_font->transform) |
|
|
|
|
{ |
|
|
|
|
FT_Matrix matrix; |
|
|
|
|
FT_Get_Transform (ft_face, &matrix, nullptr); |
|
|
|
|
y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
#endif |
|
|
|
|
{ |
|
|
|
|
y_mult = font->y_scale < 0 ? -1 : +1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ft_face->units_per_EM != 0) |
|
|
|
|
{ |
|
|
|
@ -1235,13 +1269,14 @@ hb_ft_font_set_funcs (hb_font_t *font) |
|
|
|
|
if (FT_Select_Charmap (ft_face, FT_ENCODING_MS_SYMBOL)) |
|
|
|
|
FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE); |
|
|
|
|
|
|
|
|
|
_hb_ft_hb_font_changed (font, ft_face); |
|
|
|
|
|
|
|
|
|
ft_face->generic.data = blob; |
|
|
|
|
ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob; |
|
|
|
|
|
|
|
|
|
_hb_ft_font_set_funcs (font, ft_face, true); |
|
|
|
|
hb_ft_font_set_load_flags (font, FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING); |
|
|
|
|
|
|
|
|
|
_hb_ft_hb_font_changed (font, ft_face); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|