1
0
mirror of https://gitlab.gnome.org/GNOME/evince synced 2024-06-30 22:54:23 +00:00

get_match_offset(): ignore areas with center outside of match

Find sidebar implementation of evince uses "reconstruction"
of found letters by comparing geometrical position of match and letters
in get_match_offset method.

Before this change the only criteria for search was
"beginning of the match is inside letter (area)".
However, for pdfs containing letters that are much bigger than found
(huge labels over content, like watermarks) those huge letters passed
criteria and were incorrectly displayed in find sidebar.

With current architecture this problem can't be solved for 100% cases,
but can be hugely improved.

This commit adds extra check that center of a letter is inside the match,
this fixes a huge percent of huge letters incorrectly passing criteria.

See MR !372 for more info and testing file.
This commit is contained in:
Vasily Galkin 2021-08-14 00:24:06 +03:00 committed by Germán Poo-Caamaño
parent afd3383648
commit c3c1fcd761

View File

@ -422,9 +422,13 @@ get_match_offset (EvRectangle *areas,
do {
EvRectangle *area = areas + i;
gdouble area_y = (area->y1 + area->y2) / 2;
gdouble area_x = (area->x1 + area->x2) / 2;
if (x >= area->x1 && x < area->x2 &&
y >= area->y1 && y <= area->y2) {
y >= area->y1 && y <= area->y2 &&
area_x >= match->x1 && area_x <= match->x2 &&
area_y >= match->y1 && area_y <= match->y2) {
return i;
}