3 ms·
I have a graphical window, and I have a bunch of text (in whatever Unicode encoding you want---it doesn't matter to me) that I need to display in said graphical
by spc476 4y ago
I have a graphical window, and I have a bunch of text (in whatever Unicode encoding you want---it doesn't matter to me) that I need to display in said graphical window such that the text just doesn't run off one edge of the window and can't be read. How do I break the text up into segments that will fit within the horizontal width of the graphical window without changing the meaning of any of the text?
Fourty years ago I could assume ASCII and be done with it. These days? With the yearly changes to the "Rules of Unicode"? Screw that, let's build a self-landing rocket which appears to be easier these days than actually displaying text.
- kazinator 4y ago> How do I break the text up into segments that will fit within the horizontal width of the graphical window without changing the meaning of any of the text? This is language dependent. For instance, the Japanese don't care. I was reading a novel a few months ago, and a chapter ended in a sentence ending in "た。" (ta.) due to some past tense verb. This "た。" did not fit, and so was just punted to the next page, which was otherwise entirely blank. There is no concept of hyphenation. So if the text is Japanese, you just chop it into the required line length, and you're pretty much done; no hyphenation is required, no multi-pass breaking algorithm to create an evenly gray page, nothing.