Re: [Tuxpaint-devel] Using libtextwrap in Tux Paint Config.
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
|
From: Bill K. <nb...@so...> - 2021-11-16 06:17:19
|
On Mon, Nov 15, 2021 at 03:05:42PM -0800, Bill Kendrick wrote:
> On Mon, Nov 15, 2021 at 09:36:29PM +0900, TOYAMA Shin-ichi wrote:
> <snip>
> > libunibreak compiled easily and produced dll file on MinGW/MSYS2.
> > It also compiled on CentOS7.
> >
> > Therefore, I will be able to provide binary release for windows
> > and RHEL using it.
>
> Awesome!
>
> Mark, can you confirm that this library will build fine for you
> on macOS?
I'm hopeful it will work. If not, we can just #ifdef the code
into oblivion on systems that don't support it, and (for now at least)
just state that Japanese (and any other affected locale that
Tux Paint Config. has been translated to) will not work right.
I've just gone in and re-re-re-written the code to implement
libunibreak to grab hints as to where a string may be broken,
and then I iterate over the string and add characters until
there are too many. Then I rewind to the previous potential
breakpoint and introduce a space, thus allowing FLTK to word-wrap.
For example, using CamelCase English, since I don't know
Japanese, consider this text.
TheQuickBrownFoxJumpedOverTheLazyDog
Unibreak would return a LINEBREAK_ALLOWBREAK value at the
end of each individual word ("e" in "The", "k" in "Quick", etc.)
If I needed to fit this within a space that could fit
18 characters here in Emacs on my terminal, the code I
just added to Tux Paint Config. would do this:
T
Th
The (! -- keeping track of the end of a word, so we can rewind)
TheQ
TheQu
TheQui
TheQuic
TheQuick (!)
...
TheQuickBrownFox (!)
TheQuickBrownFoxJ
TheQuickBrownFoxJu
TheQuickBrownFoxJum (X -- the string is too wide...)
TheQuickBrownFox_ (go back to the last word, add a space)
TheQuickBrownFox_J (and continue...)
TheQuickBrownFox_Ju
TheQuickBrownFox_Jum
...
TheQuickBrownFox_JumpedOverTheLaz
TheQuickBrownFox_JumpedOverTheLazy (!)
TheQuickBrownFox_JumpedOverTheLazyD
TheQuickBrownFox_JumpedOverTheLazyDo (X)
TheQuickBrownFox_JumpedOverTheLazy_
TheQuickBrownFox_JumpedOverTheLazy_D
TheQuickBrownFox_JumpedOverTheLazy_Do
TheQuickBrownFox_JumpedOverTheLazy_Dog
And therefore, the text would word-wrap like so:
123456789012345678
------------------
TheQuickBrownFox
JumpedOverTheLazy
Dog
------------------
It seems to be working for me, but I'd like
Shin-Ichi to take a close look and make sure it's
actually rendering things properly.
Thanks!
--
-bill!
Sent from my computer
|