From add45cde747cabf0951f36e16428a760e0714752 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Wed, 3 Apr 2013 18:15:06 +0800 Subject: [PATCH] restrict letter space optimization --- pdf2htmlEX.1.in | 4 +++- src/HTMLRenderer/TextLineBuffer.cc | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pdf2htmlEX.1.in b/pdf2htmlEX.1.in index 74cab5f..ed8c234 100644 --- a/pdf2htmlEX.1.in +++ b/pdf2htmlEX.1.in @@ -189,7 +189,9 @@ For some versions of Firefox, however, there will be a problem when the font siz .TP .B --space-as-offset <0|1> (Default: 1) -If set to 1, space characters will be treated as offsets, which allows a better optimization. Turn it off if space characters are not displayed correctly. +If set to 1, space characters will be treated as offsets, which allows a better optimization. + +This option may cause problems for PDF files with bad encodings. .TP .B --tounicode <-1|0|1> (Default: 0) diff --git a/src/HTMLRenderer/TextLineBuffer.cc b/src/HTMLRenderer/TextLineBuffer.cc index 20b6442..143c039 100644 --- a/src/HTMLRenderer/TextLineBuffer.cc +++ b/src/HTMLRenderer/TextLineBuffer.cc @@ -338,7 +338,8 @@ void HTMLRenderer::TextLineBuffer::optimize() } // now we would like to adjust letter space to most_used width - if(max_count <= text_count - offset_count) + // we shall apply the optimization only when it can significantly reduce the number of elements + if(max_count <= text_count / 2) { // the old value is the best // just copy copy offsets