FBReaderJ can not support Chinese.

17 views
Skip to first unread message

Taoyi

unread,
Dec 20, 2009, 1:54:21 AM12/20/09
to FBReader
I am Chinese programmer. When I used the FBReaderJ, I found out it
could not support Chinese. Out of curiosity, I browse the source of
project and discover the problem. FBReaderJ use ZLTextWordCursor to
allocate the cursor, and use word element as basic text element.
However, not like English, Chinese words are not split by blank space.
Thus, a paragraph is look as a big long word element to be printed on
the screen as single one line.

I hope you team to change something to fix this problem. If you want
my help, just let me know.

geometer

unread,
Dec 20, 2009, 2:25:07 AM12/20/09
to FBReader
Hi,

Yes, this problem is known. In FBReader C++ we use liblinebreak
library for breaking text in any language including Chinese. For
FBReaderJ we plan to write a Java wrapper for liblinebreak and then it
will be possible to support Chinese too.

Best,

-- Nikolay

Kevin Guo

unread,
Dec 20, 2009, 1:38:22 PM12/20/09
to fbre...@googlegroups.com
Maybe problem is not like your mention. I have change some codes in class of org.geometerplus.zlibrary.text.view.ZLTextParagraphCursor. I modify internal class Processor's fill method. I tried epub files, FBReader can display Chinese now.
Even it can render the Chinese correctly, I do not think my solution is an efficient one. I take each char as a single word an element (because there no spaces in Chinese sentence) which causes "Paint.measureText" method to be called much more times by ZLAndroidPaintContext. I hope your team can find a better solution for Chinese's FBReader users.

Thanks.

for (int charPos = offset; charPos < end; ++charPos) {
final char ch = data[charPos];
// if ((ch == ' ') || (ch <= 0x0D)) {
// if (firstNonSpace != -1) {
// addWord(data, firstNonSpace, charPos - firstNonSpace, myOffset + (firstNonSpace - offset));
// elements.add(hSpace);
// spaceInserted = true;
// firstNonSpace = -1;
// } else if (!spaceInserted) {
// elements.add(hSpace);
// spaceInserted = true;
// }
// } else if (firstNonSpace == -1) {
// firstNonSpace = charPos;
// }
if ((ch == ' ') || (ch <= 0x0D)) {
elements.add(hSpace);
}else{
addWord(data,charPos,1,myOffset+(charPos-offset));

> --
>
> You received this message because you are subscribed to the Google Groups "FBReader" group.
> To post to this group, send email to fbre...@googlegroups.com.
> To unsubscribe from this group, send email to fbreader+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/fbreader?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages