sciurius / perl-Text-Layout

Pango style markup formatting for PDF::API2, Markdown, Cairo and more
2 stars 2 forks source link

word wrap? #9

Closed PhilterPaper closed 6 months ago

PhilterPaper commented 2 years ago

As promised in #8, I played with Text::Layout some more. I will need the ability to word-wrap, but it doesn't seem to have it in, at least by default. Most of the routines for WW seem to be dummy stubs. Did I overlook something needed to enable it, or is it truly not there yet? Is there anything in plan or in progress to support WW?

In PDF::Builder, I have some crude support for splitting up a string into a paragraph (WW). It uses a "greedy" algorithm with some language-independent hyphenation, but nothing like Knuth-Liang hyphenation or Knuth-Plass for paragraph shaping. There are several packages around for the former, and I own Text::KnuthPlass (but it needs a lot of work). Anyway, if you want a very simple-minded greedy line-splitting algorithm, feel free to poke around in PDF::Builder::Content::Text for ideas.

sciurius commented 2 years ago

My apologies, I mixed up.

I developed Text::Layout for my ChordPro program, but ChordPro requires a very specific strategy for wrapping since it basically has to wrap two lines at a time simultaneously. So the wrapping I referred to is in ChordPro, not in Text::Layout.

While Text::Layout does a great job I still hope one day to be able to use 'real' Pango for the hard work. This would require an API2/Builder Cairo canvas but maybe the existing SVG canvas can be used, interpreting its results into PDF. But it all seems tricky, and there is no documentation and (community) support for developing Cairo backends.

I'll see if I can add at least basic wrapping to Text::Layout (but don't hold your breath).

PhilterPaper commented 2 years ago

Sounds good! Is one SCUBA tank of air enough? :-)

PhilterPaper commented 6 months ago

Since I'm not planning any more to use Text::Layout (except as some inspiration for PDF::Builder's column()), I'll go ahead and close this ticket. Feel free to re-open it if there's any discussion here that you want to keep alive.