09/04/2013 09:25, Lin Wei:
It seems the following function decides where to break within a paragraph:
TextMetrics.cpp:  pos_type TextMetrics::rowBreakPoint(int width,
pit_type const pit,pos_type pos) const

Yes.

But still, I didn't really figure out how it works...What I'm puzzled
about the codes is how it knows the exact breaking point as it iterates
to then end of a row width but is still in the middle of a word. Say a
word "itshardtowrapaword" is at the end of a line and the position
iterator now pointing to 'p'. Then we find we are now at the end of the
line, which means the whole words needs to be wrapped. How did the codes
achieve that?

As far as I understand, there is a variable named "point" that keeps track of the last possible break point. This is what get used when the algorithm realizes that one given word is too long.

Becides, I think the problem of Lyx with Chinese is that it view all
Chinese characters as just one word so long as no space/newline appears.
A main feature of Chinese and Japanese is that they generally don't use
any space within words or sentences. So a sentence like "***(Bob
2010)***********" would be treated as two words, "**(Bob" and
"2010)***********", thus incorrectly wrapped if the second so-called
word is too long.

I agree with the analysis, but I do not know what the correct algorithm is. There is a Qt tool for that
  http://doc.qt.digia.com/4.6/qtextboundaryfinder.html
but I am not sure that we can use it directly. It may be possible to use it on strings between insets and handle insets by ourselves.

Btw....Sorry that I don't know the convention in developing free
software, but should I reply only to the mailing list or cc to everyone
replied me as well?

You can just answer to the list.

Regards,
JMarc

Reply via email to