Skip to content

Justified Text view with hyphenation #6

Open

Description

@waelsaad

Hi Ryan,

FrameUp is an amazing project. once again thank you for sharing.

I am wondering in additonal to my previous issue regarding right to left language support.

Is it also possible to implement an option for HFlow Layout so that when a word is too long for a row, it would break the word onto 2 lines with the extra characters of the word on the second line?

In my scenario I am displaying like 3 columns of justified text each column has one kind of a language, the frame width for each column is not that wide so sometimes the word is too long in its row and to display it correctly I would like to break it up on to 2 lines.

Hoping for a response whenever you are free on the 2 issues please. I pormise I won't have any more :].

Thank you.

Wael

Activity

  1. changed the title [-]When the word is too long is it possible to wrap the extra characters on a new line [Feature Request][/-] [+]When the word is too long is it possible to wrap the extra characters on a second line [Feature Request][/+] on Jun 20, 2023
  2. ryanlintott commented on Jun 21, 2023

    @ryanlintott
    Owner

    This isn't really possible for HFlow as it's not designed specifically for text layout and can't break up the views that are supplied. You would need to pre-process the text and break up long words yourself.

    My recommendation would be to use UIKit or CoreText for more complex text layout like this as I think there are more automatic ways to support justification and hyphenation.

    That said, if you want a hacky SwiftUI approach I haven't fully developed it yet (It doesn't support right to left for example). I might include this in FrameUp in the future if I can make a less hacky version.

  3. changed the title [-]When the word is too long is it possible to wrap the extra characters on a second line [Feature Request][/-] [+]Justified Text view with hyphenation[/+] on Jun 21, 2023
  4. waelsaad commented on Jun 21, 2023

    @waelsaad
    Author

    Thank you Ryan. I got what you said about attempting to break up the text preior. I will have a go at that.

    I understand your recommendation regarding UIKit or CoreText that they can do more complex text layout but to be honest I found that FrameUp is an easy to use library that is a mature enough for what I need it to do and its specifically designed for SwiftUI.

    Even though HFlow was not designed specifically for text layout but its filling a SwiftUI gap for my requirements at the moment.

    I will be greedy to raise one more issue to get your thoughts, even if its a simillar response to this one.

  5. ryanlintott commented on Jun 21, 2023

    @ryanlintott
    Owner

    Feel free to raise issues if there are features you'd like to see. I'm glad you're finding the package helpful.

  6. waelsaad commented on Jun 21, 2023

    @waelsaad
    Author

    Absloutly you don't understand how helpful it has been,. Its also serving an important great purpose that I intend on sharing once its complete, I am still at early stages of the development of this project. Also just my opinion that hacky SwiftUI approach you mentioned above is worthy of putting it as part of the FrameUp library once it has support for right to left and also flexiable width like with HFlowLayout(alignment: .justified) you don't need to pass a width so for example if it exists within a HStack, then it should workout the maximum width by itself. Then its a very powerfull lightwieght version of what I am after. and can be easily used in other apps. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions