From c4f6ee0e5edfa95a5b9030356f683c12226d91d4 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 6 Nov 2018 15:41:25 +0100 Subject: Fix 700030: Tweak text extraction space adding heuristics. Ignore space-sized backward motions. Assume that these motions are either extreme levels of kerning, or something else fishy going on. --- source/fitz/stext-device.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 0ba944d4..e8f04e1f 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -317,20 +317,25 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int { if (fabsf(spacing) < size * SPACE_DIST) { - /* Motion is in line, and small. */ + /* Motion is in line and small enough to ignore. */ new_line = 0; } - else if (spacing >= size * SPACE_DIST && spacing < size * SPACE_MAX_DIST) + else if (fabsf(spacing) > size * SPACE_MAX_DIST) { - /* Motion is in line, but large enough to warrant us adding a space. */ - if (dev->lastchar != ' ' && wmode == 0) - add_space = 1; + /* Motion is in line and large enough to warrant splitting to a new line */ + new_line = 1; + } + else if (spacing < 0) + { + /* Motion is backward in line! Ignore this odd spacing. */ new_line = 0; } else { - /* Motion is in line, but large enough to warrant splitting to a new line */ - new_line = 1; + /* Motion is forward in line and large enough to warrant us adding a space. */ + if (dev->lastchar != ' ' && wmode == 0) + add_space = 1; + new_line = 0; } } -- cgit v1.2.3