word wrapping
-
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
-
Oh, so you're volunteering to write the CSS engine for me right?
Real programmers use butterflies
-
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
-
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[^]?
-
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
-
Disregard my pevious answer - that's for HTML only. If it's for an e-reader you have bigger problems: use a library to do this because there are multiple things involved in flowing text. If you've never used LaTeX you are probably not familiar with all the complexities involved: 1. Font kerning: changes the width of a line. 2. Inter-word spacing: algorithm must ensure no rivers run through paragraphs and edges line up. 3. Paragraph indentation: in literary prose all paragraphs have an indentation. 4. Long word wrapping: You need to use a table of pre-calculated breakpoints that are specific to a glyph. 5. Language: Some languages read right-to-left, and these may be in the middle of a sentence in a language which reads left-to-right. If you're implementing an E-reader then you need to know all of the following concepts: 1. Kerning 2. Ligatures 3. Unicode code-points 4. Unicode BMP 5. Unicode surrogates 6. Unicode characters 7. Unicode glyphs 8. Rivers/runs in text 9. Struts and rules in text 10. Baselines, Caplines 11. Ascenders, descenders 12. Subpixels ... and probably a hundred other typesetting things I forgot or don't know about. Flowing text for an E-reader (or PDF, or book or any typesetting) is an entire Phd topic on its own and can take years of work to implement. It does help if you've used LaTeX in the past, because it chooses good defaults for all of the above, and if you want to change anything you're forced to learn what all those things mean.
Find me a library for this that works on the Arduino framework. 1. Done 2. Not 3. Done 4. Not 5. Done 6. Done 7. Done (although i think you mean ttf/otf glyphs 8. Not 9. Not 10.Done 11.I don't know what that is 12. If you mean fractional pixels or anti-aliasing, done
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
-
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...
-
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
-
Find me a library for this that works on the Arduino framework. 1. Done 2. Not 3. Done 4. Not 5. Done 6. Done 7. Done (although i think you mean ttf/otf glyphs 8. Not 9. Not 10.Done 11.I don't know what that is 12. If you mean fractional pixels or anti-aliasing, done
Real programmers use butterflies
Quote:
Find me a library for this that works on the Arduino framework.
Maybe you should tell your client that the project they contracted you for is not completely realisable on their choice of hardware. Sure, you can get part of the way there on an atmega platform but it may not match their expectations. Or maybe get them to scale their requirements down to exclude extended unicode characters and exclude any sort of typesetting rules; just render text instead of typesetting it. Most (if not all) times my clients let me choose the hardware anyway (they set price restrictions and I tell them what is capable at that price) so it shouldn't really be a problem having this discussion with your client.
-
Say I don't have room to wrap a single world like supercalifragilisticexpialidocious. In the real world, I'd just find a syllable and then hyphenate. I don't think I can do that - and i don't think i *should* do that in html and css. I don't know *what* to do. What would you do?
Real programmers use butterflies
Scrollbars! :laugh:
Latest Articles:
DivWindow: Size, drag, minimize, and maximize floating windows with layout persistence -
Quote:
Find me a library for this that works on the Arduino framework.
Maybe you should tell your client that the project they contracted you for is not completely realisable on their choice of hardware. Sure, you can get part of the way there on an atmega platform but it may not match their expectations. Or maybe get them to scale their requirements down to exclude extended unicode characters and exclude any sort of typesetting rules; just render text instead of typesetting it. Most (if not all) times my clients let me choose the hardware anyway (they set price restrictions and I tell them what is capable at that price) so it shouldn't really be a problem having this discussion with your client.
I could tell my client that but it's not true, and I wouldn't believe myself (I'm the client) anyway. I've got unicode, i'm working on the typesetting. It's not that the device isn't capable - I think I've written enough of the code to prove that the ESP32 can do it. It's just that I don't know the behaviors of all of it - not that I'm trying to implement all of it - just enough to show most epubs mostly correctly.
Real programmers use butterflies
-
Say I don't have room to wrap a single world like supercalifragilisticexpialidocious. In the real world, I'd just find a syllable and then hyphenate. I don't think I can do that - and i don't think i *should* do that in html and css. I don't know *what* to do. What would you do?
Real programmers use butterflies
How much (ROM,RAM) space do you have? Could a translation of a library like [this](https://github.com/mnater/Hyphenopoly) 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
-
How much (ROM,RAM) space do you have? Could a translation of a library like [this](https://github.com/mnater/Hyphenopoly) 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
-
Say I don't have room to wrap a single world like supercalifragilisticexpialidocious. In the real world, I'd just find a syllable and then hyphenate. I don't think I can do that - and i don't think i *should* do that in html and css. I don't know *what* to do. What would you do?
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
-
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
-
I could tell my client that but it's not true, and I wouldn't believe myself (I'm the client) anyway. I've got unicode, i'm working on the typesetting. It's not that the device isn't capable - I think I've written enough of the code to prove that the ESP32 can do it. It's just that I don't know the behaviors of all of it - not that I'm trying to implement all of it - just enough to show most epubs mostly correctly.
Real programmers use butterflies
Quote:
I could tell my client that but it's not true,
You appaer to be in agreement with this statement of mine:
Quote:
Sure, you can get part of the way there on an atmega platform
So, yeah, that's completely true and factual - you can definitely get part of the way there! I'm guessing that the easiest bits can be done (inter-word spacing and hyphenation at syllable boundaries), but anything else you add in is going to result in a ragged right-edge. If you are okay with a ragged right edge, then it all becomes doable on an ESP32 (that's like what, 80KB RAM?)
-
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
-
Say I don't have room to wrap a single world like supercalifragilisticexpialidocious. In the real world, I'd just find a syllable and then hyphenate. I don't think I can do that - and i don't think i *should* do that in html and css. I don't know *what* to do. What would you do?
Real programmers use butterflies
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.
-
Disregard my pevious answer - that's for HTML only. If it's for an e-reader you have bigger problems: use a library to do this because there are multiple things involved in flowing text. If you've never used LaTeX you are probably not familiar with all the complexities involved: 1. Font kerning: changes the width of a line. 2. Inter-word spacing: algorithm must ensure no rivers run through paragraphs and edges line up. 3. Paragraph indentation: in literary prose all paragraphs have an indentation. 4. Long word wrapping: You need to use a table of pre-calculated breakpoints that are specific to a glyph. 5. Language: Some languages read right-to-left, and these may be in the middle of a sentence in a language which reads left-to-right. If you're implementing an E-reader then you need to know all of the following concepts: 1. Kerning 2. Ligatures 3. Unicode code-points 4. Unicode BMP 5. Unicode surrogates 6. Unicode characters 7. Unicode glyphs 8. Rivers/runs in text 9. Struts and rules in text 10. Baselines, Caplines 11. Ascenders, descenders 12. Subpixels ... and probably a hundred other typesetting things I forgot or don't know about. Flowing text for an E-reader (or PDF, or book or any typesetting) is an entire Phd topic on its own and can take years of work to implement. It does help if you've used LaTeX in the past, because it chooses good defaults for all of the above, and if you want to change anything you're forced to learn what all those things mean.
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.