Open Elara6331 opened 1 year ago
I run this code and it can be reproduced. I think it may be caused by lineBounds in richtext.
@andydotxyz Do you have any design doc for richtext? It will be easier to fix it if there are more details.
@andydotxyz Do you have any design doc for richtext? It will be easier to fix it if there are more details.
The high level proposal is at https://github.com/fyne-io/proposals/blob/main/richtext.md.
The problem is fairly complex, because we're not just adding wrap to hyperlink, but asking it to wrap with an initial offset as well (when the hyperlink wraps on a line it was not the first item of).
There are some if _, ok; obj.(*canvas.Text); ok
in the rich text code as we assumed only text would wrap.
Potentially we need to split hyperlink into two different objects when rendering to simulate the wrap?
@andydotxyz Do you have any design doc for richtext? It will be easier to fix it if there are more details.
The high level proposal is at https://github.com/fyne-io/proposals/blob/main/richtext.md.
The problem is fairly complex, because we're not just adding wrap to hyperlink, but asking it to wrap with an initial offset as well (when the hyperlink wraps on a line it was not the first item of). There are some
if _, ok; obj.(*canvas.Text); ok
in the rich text code as we assumed only text would wrap. Potentially we need to split hyperlink into two different objects when rendering to simulate the wrap?
Agreed. Splitting hyperlink into some objects is a practical way, another problem is when the mouse cursor is hovering it, these split objects should share the same an underline.
In short, implementing a rich text it is really very trivial.
Is there a good solution available at the moment?
This is an open bug, until it is fixed there isn't a fix. You could use shorter text in your hyperlinks I guess?
I'm developing an epub reader and some of the books have a problem with excessively long links.
Checklist
Describe the bug
When using a hyperlink segment in RichText, it does not wrap the text, despite
TextWrapWord
being set. Normal text does wrap.How to reproduce
Screenshots
With hyperlink:
Without hyperlink:
Example code
Fyne version
2.2.4
Go compiler version
1.19.3
Operating system
Linux
Operating system version
Arch Linux
Additional Information
No response