backport recent libreoffice-related harfbuzz fixes

Change-Id: I1ff1b6291e9799d95477334f2726132ddc99442f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143208
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2022-11-24 13:17:20 +01:00
parent 32720b4744
commit ae72d9cc7b
4 changed files with 201 additions and 0 deletions
@@ -0,0 +1,65 @@
From 404cb99d86c2d639b4ce2fc59f00f5e66468af34 Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Wed, 23 Nov 2022 15:35:14 -0700
Subject: [PATCH] [buffer-diff] Fix check for glyph flag equality
I'm not sure if the old behavior was intentional, but it was checking
that the glyph flags were a subset of the reference buffer's glyph
flags. I don't see why that is useful. Fix that.
Then make the buffer-verify code ignore flag differences when verifying
buffers, since our unsafe-to-concat flag at least, is conservative and
not guaranteed to be produced the same in fragments. See:
https://github.com/harfbuzz/harfbuzz/issues/3888
---
src/hb-buffer-verify.cc | 5 ++---
src/hb-buffer.cc | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/hb-buffer-verify.cc b/src/hb-buffer-verify.cc
index 5453e1ca9..1cd52b39b 100644
--- a/src/hb-buffer-verify.cc
+++ b/src/hb-buffer-verify.cc
@@ -186,7 +186,7 @@ buffer_verify_unsafe_to_break (hb_buffer_t *buffer,
bool ret = true;
hb_buffer_diff_flags_t diff = hb_buffer_diff (reconstruction, buffer, (hb_codepoint_t) -1, 0);
- if (diff)
+ if (diff & ~HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH)
{
buffer_verify_error (buffer, font, BUFFER_VERIFY_ERROR "unsafe-to-break test failed.");
ret = false;
@@ -313,7 +313,6 @@ buffer_verify_unsafe_to_concat (hb_buffer_t *buffer,
bool ret = true;
hb_buffer_diff_flags_t diff;
-
/*
* Shape the two fragment streams.
*/
@@ -382,7 +381,7 @@ buffer_verify_unsafe_to_concat (hb_buffer_t *buffer,
* Diff results.
*/
diff = hb_buffer_diff (reconstruction, buffer, (hb_codepoint_t) -1, 0);
- if (diff)
+ if (diff & ~HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH)
{
buffer_verify_error (buffer, font, BUFFER_VERIFY_ERROR "unsafe-to-concat test failed.");
ret = false;
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index f1e30f241..9e67e680c 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -2095,7 +2095,7 @@ hb_buffer_diff (hb_buffer_t *buffer,
result |= HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH;
if (buf_info->cluster != ref_info->cluster)
result |= HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH;
- if ((buf_info->mask & ~ref_info->mask & HB_GLYPH_FLAG_DEFINED))
+ if ((buf_info->mask ^ ref_info->mask) & HB_GLYPH_FLAG_DEFINED)
result |= HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH;
if (contains && ref_info->codepoint == dottedcircle_glyph)
result |= HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT;
--
2.38.1
@@ -0,0 +1,104 @@
From 060ecac949dca29a75538ddeedf015441296334b Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Wed, 23 Nov 2022 16:31:37 -0700
Subject: [PATCH] [font] Respect subfont slant setting in hb-draw
Fixes https://github.com/harfbuzz/harfbuzz/issues/3890
---
src/hb-font.cc | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 93005f4f3..e1699ca2a 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -518,6 +518,7 @@ typedef struct hb_font_get_glyph_shape_default_adaptor_t {
void *draw_data;
float x_scale;
float y_scale;
+ float slant;
} hb_font_get_glyph_shape_default_adaptor_t;
static void
@@ -530,9 +531,10 @@ hb_draw_move_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED,
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
+ float slant = adaptor->slant;
adaptor->draw_funcs->emit_move_to (adaptor->draw_data, *st,
- x_scale * to_x, y_scale * to_y);
+ x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@@ -544,12 +546,13 @@ hb_draw_line_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
+ float slant = adaptor->slant;
- st->current_x *= x_scale;
- st->current_y *= y_scale;
+ st->current_x = st->current_x * x_scale + st->current_y * slant;
+ st->current_y = st->current_y * y_scale;
adaptor->draw_funcs->emit_line_to (adaptor->draw_data, *st,
- x_scale * to_x, y_scale * to_y);
+ x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@@ -562,13 +565,14 @@ hb_draw_quadratic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
+ float slant = adaptor->slant;
- st->current_x *= x_scale;
- st->current_y *= y_scale;
+ st->current_x = st->current_x * x_scale + st->current_y * slant;
+ st->current_y = st->current_y * y_scale;
adaptor->draw_funcs->emit_quadratic_to (adaptor->draw_data, *st,
- x_scale * control_x, y_scale * control_y,
- x_scale * to_x, y_scale * to_y);
+ x_scale * control_x + slant * control_y, y_scale * control_y,
+ x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@@ -582,14 +586,15 @@ hb_draw_cubic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
hb_font_get_glyph_shape_default_adaptor_t *adaptor = (hb_font_get_glyph_shape_default_adaptor_t *) draw_data;
float x_scale = adaptor->x_scale;
float y_scale = adaptor->y_scale;
+ float slant = adaptor->slant;
- st->current_x *= x_scale;
- st->current_y *= y_scale;
+ st->current_x = st->current_x * x_scale + st->current_y * slant;
+ st->current_y = st->current_y * y_scale;
adaptor->draw_funcs->emit_cubic_to (adaptor->draw_data, *st,
- x_scale * control1_x, y_scale * control1_y,
- x_scale * control2_x, y_scale * control2_y,
- x_scale * to_x, y_scale * to_y);
+ x_scale * control1_x + slant * control1_y, y_scale * control1_y,
+ x_scale * control2_x + slant * control2_y, y_scale * control2_y,
+ x_scale * to_x + slant * to_y, y_scale * to_y);
}
static void
@@ -624,7 +629,8 @@ hb_font_get_glyph_shape_default (hb_font_t *font,
draw_funcs,
draw_data,
(float) font->x_scale / (float) font->parent->x_scale,
- (float) font->y_scale / (float) font->parent->y_scale
+ (float) font->y_scale / (float) font->parent->y_scale,
+ (font->slant - font->parent->slant) * (float) font->x_scale / (float) font->parent->y_scale
};
font->parent->get_glyph_shape (glyph,
--
2.38.1
@@ -0,0 +1,29 @@
From 2e9b270a496de14d3eee9d8b7e1372293bf13888 Mon Sep 17 00:00:00 2001
From: Behdad Esfahbod <behdad@behdad.org>
Date: Wed, 23 Nov 2022 16:17:50 -0700
Subject: [PATCH] [hb-view] Fix cairo slanting condition
hb-draw already does slanting. If NOT hb-draw, we should slant
through cairo path. Donno why this was untested before.
This was double-slanting with hb-draw, and not slanting without it.
---
util/helper-cairo.hh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh
index 37bde1896..fbdbbb1db 100644
--- a/util/helper-cairo.hh
+++ b/util/helper-cairo.hh
@@ -104,7 +104,7 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
cairo_matrix_init_scale (&font_matrix,
font_opts->font_size_x,
font_opts->font_size_y);
- if (use_hb_draw)
+ if (!use_hb_draw)
font_matrix.xy = -font_opts->slant * font_opts->font_size_x;
font_options = cairo_font_options_create ();
--
2.38.1
+3
View File
@@ -18,6 +18,9 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,harfbuzz,0))
# <https://github.com/harfbuzz/harfbuzz/pull/3874> "Adjust unsafe-to-break for non-zero ValueFormat2":
$(eval $(call gb_UnpackedTarball_add_patches,harfbuzz, \
external/harfbuzz/3874.patch.1 \
external/harfbuzz/0001-hb-view-Fix-cairo-slanting-condition.patch.1 \
external/harfbuzz/0001-font-Respect-subfont-slant-setting-in-hb-draw.patch.1 \
external/harfbuzz/0001-buffer-diff-Fix-check-for-glyph-flag-equality.patch.1 \
))
# vim: set noet sw=4 ts=4: