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

Unnecessary spaces between nodes of different colors. #66

Open
astrochili opened this issue Nov 16, 2020 · 8 comments
Open

Unnecessary spaces between nodes of different colors. #66

astrochili opened this issue Nov 16, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@astrochili
Copy link

I'm trying to color a part of existing text, but the library creates unnecessary spaces between nodes of different colors.

Hello Mickey, - >He llo Mickey ,
Georg, -> Georg ,
Adam? -> Adam ?

An example to reproduce: richtext_coloring.zip

ezgif com-gif-maker

@britzl
Copy link
Owner

britzl commented Nov 17, 2020

Ah, yes, this is a tricky one.

Here's the width of three different strings:

STRING WIDTH
Georg, 47
Georg 41
, 7

As you can see you get a different width of the string "Georg," when you measure "Georg" and "," individually and sum the widths. I'm not entirely sure what can be done about it....

@britzl britzl added the bug Something isn't working label Nov 17, 2020
@astrochili
Copy link
Author

astrochili commented Nov 17, 2020

Ah, yes, this is a tricky one.

Here's the width of three different strings:

STRING WIDTH
Georg, 47
Georg 41
, 7
As you can see you get a different width of the string "Georg," when you measure "Georg" and "," individually and sum the widths. I'm not entirely sure what can be done about it....

I understand that this is due to the possibility of overlaying font elements in the word.

For example, we can to find blocks of the same font size, calculate their width as a seamless node and subtract the width difference between seamless node and two separated nodes. And then set this difference to the offset.

Ideally, we should get the margins of the first/last node font symbols itself and combine the nodes with the overlay margins.

@subsoap
Copy link
Contributor

subsoap commented Jun 21, 2022

@astrochili Did you ever come up with a solution that worked for you?

@astrochili
Copy link
Author

astrochili commented Jun 21, 2022

@astrochili Did you ever come up with a solution that worked for you?

Unfortunately, no, but if you know in advance which parts you need to highlight, you can highlight them with the default color in the normal state. This should allow you to change only the color without changing the nodes.

But this method doesn't solve the problem of extra spacing.

@subsoap
Copy link
Contributor

subsoap commented Mar 28, 2023

@JCash
any idea on how to actually fix this properly? I need to highlight words over time without everything jumping around

@subsoap
Copy link
Contributor

subsoap commented Mar 28, 2023

really stupid hacky way I'm considering:
create two sets of nodes one normal color one highlighted
for normal set disable any nodes which are currently highlighted
for highlighted disable all normal nodes
that way tags are not being used
but doing this sucks

@JCash
Copy link

JCash commented Mar 28, 2023

I haven't thought about it tbh.
I'll need to read up on the code a bit to get a better understanding what's included in the widths

@ChuckMayo
Copy link

We're also dealing with this issue and are looking for a fix or workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants