Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. word wrapping

word wrapping

Scheduled Pinned Locked Moved The Lounge
htmlcssquestion
60 Posts 20 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U User 13269747

    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.

    H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #34

    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

    U 1 Reply Last reply
    0
    • H honey the codewitch

      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

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #35

      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

      H 1 Reply Last reply
      0
      • S Stuart Dootson

        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

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #36

        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

        1 Reply Last reply
        0
        • H honey the codewitch

          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

          B Offline
          B Offline
          BernardIE5317
          wrote on last edited by
          #37

          What's wrong w/ hyphenating at vowels? Software can figure out where the vowels are w/o a dictionary Best Wishes - Cheerio

          H 1 Reply Last reply
          0
          • B BernardIE5317

            What's wrong w/ hyphenating at vowels? Software can figure out where the vowels are w/o a dictionary Best Wishes - Cheerio

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #38

            I mean, breaking bookkeeper on the first o seems kind of not good.

            Real programmers use butterflies

            B 1 Reply Last reply
            0
            • H honey the codewitch

              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

              U Offline
              U Offline
              User 13269747
              wrote on last edited by
              #39

              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?)

              H 1 Reply Last reply
              0
              • H honey the codewitch

                I mean, breaking bookkeeper on the first o seems kind of not good.

                Real programmers use butterflies

                B Offline
                B Offline
                BernardIE5317
                wrote on last edited by
                #40

                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

                1 Reply Last reply
                0
                • H honey the codewitch

                  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

                  M Offline
                  M Offline
                  mdblack98
                  wrote on last edited by
                  #41

                  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.

                  H 1 Reply Last reply
                  0
                  • U User 13269747

                    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.

                    C Offline
                    C Offline
                    CosmoSpacely
                    wrote on last edited by
                    #42

                    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.

                    1 Reply Last reply
                    0
                    • H honey the codewitch

                      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

                      R Offline
                      R Offline
                      Rusty Bullet
                      wrote on last edited by
                      #43

                      Honey, ascenders and descenders are letters like 't', 'l', 'h' that ascend above a standard 'a' type character and descenders are 'p', 'q', 'y' that descend below a standard 'a' type character.

                      H 1 Reply Last reply
                      0
                      • H honey the codewitch

                        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

                        M Offline
                        M Offline
                        Member_5893260
                        wrote on last edited by
                        #44

                        Use a different word...

                        1 Reply Last reply
                        0
                        • R Rusty Bullet

                          Honey, ascenders and descenders are letters like 't', 'l', 'h' that ascend above a standard 'a' type character and descenders are 'p', 'q', 'y' that descend below a standard 'a' type character.

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #45

                          Oh I thought it was going to be something weird. Yeah my stuff does that. It's basic truetype. you couldn't render fonts without it.

                          Real programmers use butterflies

                          R 1 Reply Last reply
                          0
                          • M mdblack98

                            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.

                            H Offline
                            H Offline
                            honey the codewitch
                            wrote on last edited by
                            #46

                            That's what I'm hoping I can get away with. =)

                            Real programmers use butterflies

                            1 Reply Last reply
                            0
                            • H honey the codewitch

                              Oh I thought it was going to be something weird. Yeah my stuff does that. It's basic truetype. you couldn't render fonts without it.

                              Real programmers use butterflies

                              R Offline
                              R Offline
                              Rusty Bullet
                              wrote on last edited by
                              #47

                              Jargon is always scary until you know what it means!

                              1 Reply Last reply
                              0
                              • U User 13269747

                                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?)

                                H Offline
                                H Offline
                                honey the codewitch
                                wrote on last edited by
                                #48

                                Adding, you didn't mention an atmega before so I'm not sure what you're quoting. In any case I didn't agree or disagree with that statement because you didn't make it. This is what I responding to:

                                Maybe you should tell your client that the project they contracted you for is not completely realisable on their choice of hardware.

                                Real programmers use butterflies

                                U 1 Reply Last reply
                                0
                                • P PIEBALDconsult

                                  --------------------
                                  Well, I'd split on a
                                  ​space if ​possible,
                                  but that isn't
                                  always possible,
                                  particularly with
                                  "supercalifragilisti
                                  cexpialidocious",
                                  which exceeds the
                                  line length all on
                                  its own.

                                  D Offline
                                  D Offline
                                  dandy72
                                  wrote on last edited by
                                  #49

                                  That seems very reasonable to me. As a reader, frankly I could do without a hyphenation character being introduced. As a developer, I'd see that and think to myself, "you know what - I couldn't have done better". Win-win. I think you have your solution.

                                  1 Reply Last reply
                                  0
                                  • H honey the codewitch

                                    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

                                    M Offline
                                    M Offline
                                    maze3
                                    wrote on last edited by
                                    #50

                                    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.

                                    H 1 Reply Last reply
                                    0
                                    • M maze3

                                      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.

                                      H Offline
                                      H Offline
                                      honey the codewitch
                                      wrote on last edited by
                                      #51

                                      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

                                      1 Reply Last reply
                                      0
                                      • H honey the codewitch

                                        Adding, you didn't mention an atmega before so I'm not sure what you're quoting. In any case I didn't agree or disagree with that statement because you didn't make it. This is what I responding to:

                                        Maybe you should tell your client that the project they contracted you for is not completely realisable on their choice of hardware.

                                        Real programmers use butterflies

                                        U Offline
                                        U Offline
                                        User 13269747
                                        wrote on last edited by
                                        #52

                                        Quote:

                                        Adding, you didn't mention an atmega before so I'm not sure what you're quoting.

                                        I'm quoting this post over here, which as you can see contains the sentence you missed: The Lounge[^]

                                        Quote:

                                        This is what I responding to: Maybe you should tell your client that the project they contracted you for is not completely realisable on their choice of hardware.

                                        Seems you're in agreement with that too, since you say:

                                        Quote:

                                        not that I'm trying to implement all of it - just enough to show most epubs mostly correctly.

                                        That's what "not completely realisable" means.

                                        H 1 Reply Last reply
                                        0
                                        • U User 13269747

                                          Quote:

                                          Adding, you didn't mention an atmega before so I'm not sure what you're quoting.

                                          I'm quoting this post over here, which as you can see contains the sentence you missed: The Lounge[^]

                                          Quote:

                                          This is what I responding to: Maybe you should tell your client that the project they contracted you for is not completely realisable on their choice of hardware.

                                          Seems you're in agreement with that too, since you say:

                                          Quote:

                                          not that I'm trying to implement all of it - just enough to show most epubs mostly correctly.

                                          That's what "not completely realisable" means.

                                          H Offline
                                          H Offline
                                          honey the codewitch
                                          wrote on last edited by
                                          #53

                                          First of all, you never mentioned the atmega in that post. I just looked at the link you gave me. I didn't miss a sentence. What was being discussed was the Arduino framework. It is only incidently related to an atmega in that an atmega will run it. It's not the only thing that does.

                                          Member 13301679 wrote:

                                          That's what "not completely realisable" means.

                                          It's what this means

                                          Member 13301679 wrote:

                                          Maybe you should tell your client that the project they contracted you for is not completely realisable

                                          I bolded the relevant bits. You forgot the operative part. I was never contracted to build a 100% to spec e-reader.

                                          Real programmers use butterflies

                                          U 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups