Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Justified Text view with hyphenation #6

Open
waelsaad opened this issue Jun 20, 2023 · 4 comments
Open

Justified Text view with hyphenation #6

waelsaad opened this issue Jun 20, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@waelsaad
Copy link

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

@waelsaad waelsaad 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] Jun 20, 2023
@ryanlintott
Copy link
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.

@ryanlintott ryanlintott added the enhancement New feature or request label Jun 21, 2023
@ryanlintott ryanlintott 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 Jun 21, 2023
@waelsaad
Copy link
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.

@ryanlintott
Copy link
Owner

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

@waelsaad
Copy link
Author

waelsaad commented Jun 21, 2023

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
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants