|
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
|
|
|
|
|
|
If me I'd question if this a complication that actually needs handling or just a programming challenge I want to figure out.
Real world: what application this on, why would there not be enough screen space in current era. If was user input box on very narrow component, well the problem is flipped why user inputting into narrow viewed space, why cant space be increased.
if label - again flip word. having it increase height of space might not be desirable, so leaves truncation "." "..." as an option.
Put generically: figure out if this a problem that needs solving or if asking the wrong question.
|
|
|
|
|
I mean that's fair, but here's the thing: I don't know the screen size and it may be as small as 300px across. It's an e-reader
300px is not practical for an e-reader, I know - but it's more about me not knowing the functional design specs of the hardware yet. I'm coding defensively in light of lack of solid specs yet.
We simply can't know the specs yet, but it will probably be about 600px across like the nook but there may be a smaller version that's more pocketable if that's practical. Still, if they zoom in, or if the title (H1 tag) is long it could still be a problem.
Real programmers use butterflies
|
|
|
|
|
It sounds like you are leaning toward a hard break at the display margin.
Instead of using a hyphen, how about another pair of symbols?
I am thinking of the proof readers notation when two words are supposed to be joined. It is like a subscripted “u” that connects the words. Draw half of it on the break, and the other half on the continuation. Or use an ellipsis at both the break and the continuation.
Or just a random hyphen. Don’t worry about being correct for a word like that.
It will likely never happen.
|
|
|
|
|