diff --git a/pdf_viewer/document.cpp b/pdf_viewer/document.cpp index 6e6182015..81c21e226 100644 --- a/pdf_viewer/document.cpp +++ b/pdf_viewer/document.cpp @@ -80,7 +80,7 @@ void Document::fill_highlight_rects(fz_context* ctx, fz_document* doc_) { std::vector highlight_rects; std::vector merged_rects; std::wstring highlight_text; - get_text_selection(ctx, highlight.selection_begin, highlight.selection_end, true, highlight_rects, highlight_text, doc_); + get_text_selection(ctx, highlight.selection_begin, highlight.selection_end, false, highlight_rects, highlight_text, doc_); merge_selected_character_rects(highlight_rects, merged_rects); if (i < highlights.size()) { diff --git a/pdf_viewer/document_view.cpp b/pdf_viewer/document_view.cpp index 348e0e619..3d29262b9 100644 --- a/pdf_viewer/document_view.cpp +++ b/pdf_viewer/document_view.cpp @@ -307,7 +307,9 @@ void DocumentView::add_highlight(AbsoluteDocumentPos selection_begin, AbsoluteDo get_text_selection(selection_begin, selection_end, is_word_selection, selected_characters, selected_text); merge_selected_character_rects(selected_characters, merged_characters); if (selected_text.size() > 0) { - current_document->add_highlight(selected_text, merged_characters, selection_begin, selection_end, type); + const fz_rect& rect1 = selected_characters.at(0); + const fz_rect& rect2 = selected_characters.at(selected_characters.size() - 1); + current_document->add_highlight(selected_text, merged_characters, {rect1.x0, (rect1.y0 + rect1.y1) / 2}, {rect2.x0, (rect2.y0 + rect2.y1) / 2}, type); } } }