In article <5163d9fd.9090...@lyx.org>,
 Jean-Marc Lasgouttes <lasgout...@lyx.org> wrote:

> 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

Hi Jin,

Jean-Marc drew my attention to this thread.
I'm working on another problem (the slow scrolling problem) and this 
involves also the TextMetrics::rowBreakPoint() function.

As Jean-Marc explained the function keeps track of the last breakpoint 
and then tries to add as much of the next word as possible; if there is 
still enough space the breakpoint is moved otherwise the function 
returns the last breakpoint. However if a very long word is inserted the 
function will break within that word. That's probably what happens if 
you insert chinese (without any spaces).

If there are no spaces between words, I suppose "one" must understand 
the meaning of the words to know where to break? Or is there another way 
to find the possible breakpoints?

Regards,

P. De Visschere

Reply via email to