[texworks] Hard wrapping

Alain Delmotte esperanto at swing.be
Thu May 7 15:06:50 CEST 2009


Hi!

Jonathan Kew a écrit :
> On 7 May 2009, at 02:53, Dohyun Kim wrote:
>
>> 2009/5/7 Stefan Löffler <st.loeffler at gmail.com>:
>>>
>>> BTW: A few minor issues I've found:
>>> 1) Wrapping at the current window size doesn't work properly (at least
>>> on Linux). First of all it doesn't subtract the width of the scroll bar
>>> (so the text is to wide if there is enough text so that a scrollbar is
>>> shown), and secondly some lines are still too long. It's probably 
>>> just a
>>> few pixels, and may be related to the fact that on X the window
>>> decoration (borders, etc.) happens asynchronously, IIRC. But it could
>>> also be related to using the wrong rectangle (e.g. window rect instead
>>> of client rect or something), but I didn't have time to look into the
>>> code for that, yet.
>>>
>>
>> Moreover, we should also consider CJK characters:
>> The width of CJK characters is twice as wide as Latin characters,
>> so that the width of "漢" or "あ" or "가" (one CJK character) is
>> the same as "AA" (two Latin characters).
>>
>> Under current implementation of hard wrap, wrapping at
>> "current window size" is useless for CJK documents, because
>> TeXworks treats all characters as having the same width as Latin 
>> characters.
>
> Hmmm. Yes, that's unfortunate.
>
> Currently, wrapping to "current window size" is based on the width of 
> the window and the "average char width" of the current font. This is 
> only an approximation, and generally leaves the lines a bit short if 
> using a proportional font. That's not too bad, but with CJK documents, 
> the consistently wide characters will result in over-long lines.
>
> Does it behave any better if you explicitly choose a suitable CJK 
> font, instead of relying on automatic font fallback to display the CJK 
> characters?
>
> What I really wanted to do for "current window size" was to locate and 
> use the line-breaks that the editor is already using for soft-wrapping 
> the text. However, I ran into problems trying to implement this and 
> didn't have time to figure it all out, so the current code is a quick 
> hack to provide an approximation, but obviously it's not very 
> satisfactory.
Further, often one wants to hard wrap to be able later to indent once or 
more times; if wrapping is done on the "current window size" the indent 
will push the text and you'll get normal wrapping of the too long lines.

Alain




More information about the texworks mailing list