summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2022-09-18 21:31:13 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2022-09-18 21:31:13 +0000
commit6385c33095d9edbce816d8eceb760d4072f876f5 (patch)
tree7a3e36961f41d3e2b0f5c0074008c7d64c05715e /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc
parent404a949ca90543a6ac8830d4f2273700066109dd (diff)
harfbuzz 5.2.0
git-svn-id: svn://tug.org/texlive/trunk@64436 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc101
1 files changed, 69 insertions, 32 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc
index ef073475cbe..bcc1dd080f5 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc
@@ -80,16 +80,19 @@
*/
+using hb_ft_advance_cache_t = hb_cache_t<16, 24, 8, false>;
+
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;
mutable unsigned cached_serial;
- mutable hb_advance_cache_t advance_cache;
+ mutable hb_ft_advance_cache_t advance_cache;
};
static hb_ft_font_t *
@@ -136,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;
@@ -173,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)
@@ -428,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 mult = matrix.xx / 65536.f;
-#else
- float 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++)
{
@@ -450,7 +462,7 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data,
ft_font->advance_cache.set (glyph, v);
}
- *first_advance = (int) (v * mult + (1<<9)) >> 10;
+ *first_advance = (int) (v * x_mult + (1<<9)) >> 10;
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
}
@@ -466,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 = 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;
@@ -498,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 = matrix.xx / 65536.f;
- float y_mult = 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;
@@ -553,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 = matrix.xx / 65536.f;
- float y_mult = 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;
@@ -663,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 = 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)
{
@@ -1233,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);
}