改进的 Okular 文本选择功能

心之所在 | 2011/08/23

Mahfuzur 的GSoc项目涉及 Okular 的文本选择特性。

当前4.7的Okular文本选择功能(工具-文本选择)很弱,是以字符块的形式,要使文档只有一列的话没问题,要是两列的文档,列间距都会被高亮选择上,不支持多列的文本选择。这个问题见下图所示:

4-7_pdf_selection

还有个问题,Okular 支持多种文档,不同文档生成文本的方式是不同的,在选定文本前 Okular 需要有继承 Generator 的类来生成文本(PDF文档是PDFgenerator类用的poppler处理文本),生成的文本存储在 TextPage 中,每页都有个 TextPage,选定文本后,具体的文字就从 TextPage 中提取出来。

但一些具体类(generators)没有考虑到文字之间的空格(比如djvu),这种情况下文本选择后复制粘贴会出现没空格没法读的悲剧。选择文本的时候很明显空格都没高亮选定,效果图:

4-7_djvu_selection

(中间省略一堆的实现算法/细节……)

最后的效果图是这样的:

selection_and_highlighting_pdf_selection

文本选择功能都够识别“列”

djvu文档的空格问题也解决了:

final-selection-removes-space-problem-in-djvu

多列的文本选择效果(左侧是当前效果,右侧是改进后的)

comaprison-four-columncomparison2comparison1

作者开发中还遇到其它问题,像是没选择文本右键也出现“复制文本”的菜单,odt、epub格式高亮色是黑色而非蓝色的bug,这些都修正了。

此外还需要改进的是报刊杂志常用的复杂布局(列覆盖/重叠,column overlaying   column overlapping),对比Adobe Reader效果(左侧是Okular,很糟,右侧是Adobe Reader):

okular_fails

和chm文档文本选择的generator返回混乱,epub文档文本选择后文字加粗的问题,文本选择/加注解后滚动页面出现随机有颜色的线之类的。

这些还需要改进的地方作者打算以后有空再搞。

via http://nightcrawlerinshadow.wordpress.com/2011/08/20/advanced-text-selection-in-okular/

    泰达希尔-德鲁伊
    Tags: ,

    8 FEEDBACKS

    Leave a Reply to uu Cancel reply

    Your email address will not be published. Required fields are marked *

    Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).

    This site uses Akismet to reduce spam. Learn how your comment data is processed.