“FBReader”如何使用对 epub 中的 html 文件进行分页
我正在尝试制作一个 epub 阅读器
我想像 fbreader 那样进行分页
现在我有 fbreader 的源代码,但我不知道它在哪里实现分页
我有其他功能的实现
我需要 fbreader 提供的只是pagination
有没有人做过类似的事情?
感谢您花时间阅读这个问题。
ps:分页是把html文件吐到页面上,取决于屏幕的大小和字体的大小,还有语言的考虑,当改变字体大小时,页码也改变了。并且epub文件内容是html格式
I'm trying to make an epub reader
I want to do the pagination like fbreader does
Now I have source code of fbreader, but I don't know where it implement pagination
I have my implementation on other features
All I need from fbreader is the pagination
Is there anyone who have done the similar thing?
Thanks for your time to read this question.
ps: the pagination is to spit html file to pages, depending on the size of screen and size of font, and language is also in consideration, when changed the font size, the page number also changed. And epub file content is html format
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是令人着迷的代码。我很想看到原始学生项目的翻译(但我认为原始文档是俄语的)。由于这是 C++ 项目的移植,因此它在某些地方具有有趣的编码风格。
该应用程序使用段落光标 (ZLTextParagraphCursor) 跟踪您在书中的位置。这种情况与数据库游标和记录分页相比较。负责提供当前页面并计算页面数的类是ZLTextView。
由于epub是可重排的文档,而不是面向页面的,因此页面并没有真正的具体定义 - 它仅取决于您在文档中碰巧查看的位置(段落、单词、字符)和使用什么显示设置。
It is fascinating code. I would love to see a translation of the original student project (but I presume the original document is in Russian). As this is a port of a C++ project it has an interesting style of coding in places.
The app keeps track of where you are in the book by using paragraph cursors (ZLTextParagraphCursor). This situation is comparative with database cursors and record pagination. The class that is responsible for serving up the current page and calculating the number of pages is ZLTextView.
As epubs are reflowable documents and not page-oriented there isn't really a concrete definition of a page - it just depends on where in the document you happen to be looking (paragraph, word, character) and with what display settings.
正如 McLaren 所说,FBReader 不实现分页:它使用 ZLibrary,可从同一个 网站 作为 FBReader。
原始代码使用这个来计算当前页码:
Java版本使用这个函数来计算页码:
这个位于 org.geometerplus.zlibrary.text.view.TextView 中,
非常简单,不过,您也可以实现自己的。
As McLaren says, FBReader doesn't implement pagination: It uses the ZLibrary, which is available from the same website as FBReader.
The original code uses this to calculate the current page number:
The Java version uses this function to compute the page number:
This is located in
org.geometerplus.zlibrary.text.view.TextView
It's so simplistic, though, that you might as well implement your own.
我的理解是它使用了前一个、当前和下一个的 3 个位图。他们所做的是编写一个文本,通过这 3 个位图来存储和读取该文本。正如您在顶部看到的那样,它们计算您在其他示例中看到的滚动的段落数据。您可以从 android.view 包类 bitmapManager 开始逆向工程。这应该可以解释有关他们如何进行寻呼的所有内容。
How I understood it is that it uses 3 bitmaps previous current and next. What they have done is written a text which gets stored and read over this 3 bitmaps. Over as what you see on the top they calculate paragraphs data of how long it is for the scroll you see on the others example. You can start reverse engineering at android.view package class bitmapManager. This should explain everything about how they do their paging.