|
There is a pre baked library that covers many of these problems:
http://site.icu-project.org/
Do not underestimate the weedy-ness of wrapping text. Check out some of the South Asian scripts. Thai, for example, has no spaces.
Another strategy would be to scroll the too-long word. Think 1980's 16 character LED and LCD displays.
|
|
|
|
|
Fixed width fonts, know how many across, break there.
Is that an option?
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
|
|
|
|
|
Not really. The whole thing is open type/true type and using digital typesetting. Worse, there are default fonts but they can be overridden by the EPUB via CSS.
And really the problem is knowing where I should break the word. I could do it right in the middle but that seems less than good.
Real programmers use butterflies
|
|
|
|
|
As you are already neck-deep into CSS you should learn from it...
word-break: break-all;
To prevent overflow, word breaks should be inserted between any two characters (excluding Chinese/Japanese/Korean text).
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
honey the codewitch wrote: In the real world, I'd just find a syllable and then hyphenate
What about hyphenating at random places ? How often do you need it ?
|
|
|
|
|
I'm not sure. It depends on the size of the screen that's connected to the e-reader I'm making. It can use any size screen, though in the end I'll be settling on a 600x800 epaper display
Real programmers use butterflies
|
|
|
|
|
The browser rendering engine already has good support for splitting words.
I put "hypens: auto;" into my CSS and I am quite pleased with the result.
[edit]: My css is as follows (lookup the hyphenate styles for what they do)
body {
font-family: 'Computer Modern Serif';
margin: 40px auto;
max-width: 640px;
line-height: 1.6;
font-size: 16px;
padding: 0 10px;
hyphens: auto;
hyphenate-limit-lines: 2;
hyphenate-limit-chars: 6 3 2;
text-indent: 30px;
}
|
|
|
|
|
Wouldn't that be great if I didn't have to implement my own web browser which is the whole point of this?
Real programmers use butterflies
|
|
|
|
|
Quote: Wouldn't that be great if I didn't have to implement my own web browser which is the whole point of this?
Well, your initial message didn't specify that as a point and my crystal ball isn't working today
But, isn't it great that I gave you a really nice introduction into the complexities of your problem over here:
The Lounge[^]?
|
|
|
|
|
I also didn't say I was using a web browser. It's weird that you would assume I was. C# is the most commonly used language at CP, not HTML and CSS.
Real programmers use butterflies
|
|
|
|
|
CSS schould do the trick automatically, see https://medium.com/clear-left-thinking/all-you-need-to-know-about-hyphenation-in-css-2baee2d89179
|
|
|
|
|
Oh, so you're volunteering to write the CSS engine for me right?
Real programmers use butterflies
|
|
|
|
|
Totally - since CSS engines are my bread and butter...
not really, I just thought EPUB displays content using something that is capable of CSS...
|
|
|
|
|
Yes, it does. I wish it didn't. I'm making an epub reader on a device that can't even run a basic web browser.
Real programmers use butterflies
|
|
|
|
|
Do you know https://github.com/litehtml/litehtml ? this not a browser but just a parser for html and CSS... perhaps this can help...
|
|
|
|
|
I've got a parser, and that uses the STL and I cannot rely on the STL being available.
Real programmers use butterflies
|
|
|
|
|
Scrollbars!
|
|
|
|
|
How much (ROM,RAM) space do you have? Could a translation of a library like this into C++ be of any use? The core hyphenation engine is 24kB of WASM, which would probably translate into a similar amount of assembly...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I might be able to translate it, but 24kB is significant. I have about 300kB of usable general purpose RAM, 4MB of NVS flash, and *sometimes* 4MB of PSRAM
Basically how I've orchestrated this it works in 300kB but works much faster if you have the PSRAM as well.
The 4MB of NVS storage is divvied up between my code and a data partition I use to store unpacked EPUB content. I'm not sure offhand how much program space I have.
The bad part of using more program space is it starts to make the dev cycle turnaround longer because you have to upload the code via serial uart.
Real programmers use butterflies
|
|
|
|
|
What's wrong w/ hyphenating at vowels? Software can figure out where the vowels are w/o a dictionary Best Wishes - Cheerio
|
|
|
|
|
I mean, breaking bookkeeper on the first o seems kind of not good.
Real programmers use butterflies
|
|
|
|
|
Why not break at the consonants then or simply rely on whatever the rule is for word wrapping w/ hyphenation I assume such a rule exist But in any case a dictionary is not needed - Cheerio
|
|
|
|
|
Look at the CSS options which cover a lot
https://tippingpoint.dev/pure-css-truncate-text
Seem like simple wrap would be good for an ereader just splitting the word at the last char on the line...no ellipses or such needed.
|
|
|
|
|
That's what I'm hoping I can get away with. =)
Real programmers use butterflies
|
|
|
|
|