cytoscape / cytoscape.js

Graph theory (network) library for visualisation and analysis
https://js.cytoscape.org
MIT License
9.89k stars 1.64k forks source link

Font kerning non fixed upon zooming #3250

Open EliotRagueneau opened 2 weeks ago

EliotRagueneau commented 2 weeks ago

Environment info

Current (buggy) behaviour

What does the bug do?

The font seems to change the kerning upon reaching a certain threshold of zooming.

https://github.com/cytoscape/cytoscape.js/assets/42945601/541931d1-a52c-42b2-940b-fcd6ff717af4

Desired behaviour

It should be consistent (Ideally with the situation when zoomed out, as it seems closer to the definitions).

Minimum steps to reproduce

Unfortunately I wasn't able to reproduce the issue in the demo

For reviewers

Reviewers should ensure that the following tasks are carried out for incorporated issues:

maxkfranz commented 1 week ago

If you change the font to something like Helvetica Neue or Courier, do you still see this behaviour?

EliotRagueneau commented 1 week ago

It does somehow:

https://github.com/cytoscape/cytoscape.js/assets/42945601/ccb6a7f9-c286-4931-ad75-3c4d811192fb

maxkfranz commented 5 days ago

Some fonts render differently at different scales generally. Often you would not notice, because the changes from small changes in zoom level would be slight.

Cytoscape uses visual caches. What you're seeing is a step function change in how the font is rendered rather than a smoother transition, because the cache is not used (or useful) when zoomed in very far.

Given that the cache gives significant performance improvements and the changing the cache to accommodate fonts that vary widely would be expensive, it may be best to make a careful choice of font that wouldn't have this problem.

Which font face are you using?

EliotRagueneau commented 5 days ago

I am using Roboto font.

maxkfranz commented 20 hours ago

Open Sans is similar but does not exhibit this issue, as far as I'm aware.

EliotRagueneau commented 1 hour ago

I really tried to repoduce the issue on the fiddle, but I couldn't manage to reproduce there, but in my usage context, its consistently happening on the same nodes, and is most visible when the text is overflowing the max width, see

I did try many fonts, and the problem is present with all of them :/