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

Harfbuzz Integration #234

Open
Chashm-e-Afreen opened this issue Oct 14, 2020 · 13 comments
Open

Harfbuzz Integration #234

Chashm-e-Afreen opened this issue Oct 14, 2020 · 13 comments
Assignees

Comments

@Chashm-e-Afreen
Copy link

Hi!
Hope you're doing well. Just recently came across this wonderful GUI library. The issue at hand is that RTL languages currently do not render properly. Integrating Harfbuzz should solve the problem.

@Xeverous
Copy link
Contributor

This probably belongs to artist which is planned to be the backend implementation. Artist is planned to use Skia (which has a lot of own dependencies, Harfbuzz included IIRC) which supports RTL.

@djowel
Copy link
Member

djowel commented Oct 14, 2020

This probably belongs to artist which is planned to be the backend implementation. Artist is planned to use Skia (which has a lot of own dependencies, Harfbuzz included IIRC) which supports RTL.

No, this belongs here. Elements develop and main branches do not use Harfbuzz and is the reason for this issue.

Some corrections:

  • Artist already uses Harfbuzz.
  • Artist already uses Skia (not planned to use)
  • Harfbuzz is NOT a dependency of Skia

The correct answer: Please try the artist_port branch. It is the future of Elements.

@Chashm-e-Afreen
Copy link
Author

Thanks a lot for the clarification. I tried the artist_port branch but the textedit example crashes when a non ASCII character is entered.

@djowel
Copy link
Member

djowel commented Oct 16, 2020

Thanks a lot for the clarification. I tried the artist_port branch but the textedit example crashes when a non ASCII character is entered.

The artist_port is very new and surely needs to be tested more before it goes to develop and then master:

  1. Can you repro the crash by copy/pasting the text?
  2. If yes, can you share the text that you pasted?

@djowel
Copy link
Member

djowel commented Oct 21, 2020

@Chashm-e-Afreen , do you have an update on this? I tried pasting russian, but I do not get the crash you mentioned:
Screen Shot 2020-10-22 at 5 46 49 AM

@djowel
Copy link
Member

djowel commented Oct 21, 2020

OK, please try the updated code (I pushed to the artist_branch). I fixed some code probably related to the issue you mentioned. I'd appreciate it if you can give it a try and stress test the example well.

@djowel djowel self-assigned this Oct 21, 2020
@Chashm-e-Afreen
Copy link
Author

Sorry for not being able to reply. I'll give it a test and update you soon.

@Chashm-e-Afreen
Copy link
Author

Still no luck, entering an RTL unicode point causes the application to crash, copy pasting works but RTL fonts do not work particularly well. For LTR languages it's all good I guess.

@djowel
Copy link
Member

djowel commented Oct 24, 2020

Still no luck, entering an RTL unicode point causes the application to crash, copy pasting works but RTL fonts do not work particularly well. For LTR languages it's all good I guess.

Could you give me a stack trace of the crash? Would you be willing to work with me on making this work? I'll need to figure out a way to test this myself, install RTL fonts and input methods, etc. For example, we can probably feed the input programmatically (instead of typing) and make a test out of it. I should start making tests and this can be a good start.

If you are willing to work on me to make this work, we can discuss in the Discord channel

@Chashm-e-Afreen
Copy link
Author

Yeah, I'll be glad to help. The segmentation fault occurs in the

inline std::u32string to_utf32(std::string_view s)

function. I'll try my best to fix it.

@Chashm-e-Afreen
Copy link
Author

Chashm-e-Afreen commented Oct 24, 2020

Figured out where the problem is, the loop variable gets incremented twice and hence never becomes equal to the last character. This leads to an infinite loop. The decode_utf8 automaton might be at fault here.

@djowel
Copy link
Member

djowel commented Oct 24, 2020

Figured out where the problem is, the loop variable gets incremented twice and hence never becomes equal to the last character. This leads to an infinite loop. The decode_utf8 automaton might be at fault here.

Hmm... OK, can you give me an input string I can try?

In any case, I think the text element and layout engine needs a lot of work because they all assume LTR, although the harfbuzz engine itself can do RTL, and so is Skia, I assume. So this is doable, and I'd like to make it work.

@Chashm-e-Afreen
Copy link
Author

Sure, here's a simple RTL string

حرف باز

You can get an RTL font from here

https://github.com/notofonts/NotoNastaliqUrdu/blob/master/fonts/ttf/unhinted/instance_ttf/NotoNastaliqUrdu-Regular.ttf

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

No branches or pull requests

3 participants