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

multi-byte characters in labels take up twice as much space as in 'native' graphviz #10

Open
Nakilon opened this issue Jul 20, 2020 · 9 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Nakilon
Copy link

Nakilon commented Jul 20, 2020

Hello.
Looks like this repo is a fork. Is this bug fixed in it? sverweij/state-machine-cat#19
If so, how do I launch it similarly to http://viz-js.com/? Is there a Docker image or Dockerfile?

Original issue (link)

Steps taken

Render this digraph with viz.js (either version 1.8.x or 2.0.0)

digraph {
  node [shape=box]
  "Hello world" [label="Привет мир"]
}

... or this one that uses html style label formatting...:

digraph {
  rankdir=LR
  node [shape=plaintext]
  "Hello world" [label= < 
    <table border="1" cellborder="0">
      <tr><td>Привет мир</td></tr>
    </table>
  >]
}

Expected

This is the output from the 'native' graphviz dot (version 2.40.1) respectively:

regular-graphviz-output graphviz-output

Found

This is the viz.js output for both digraphs:
regular-viz-js-output viz-js-output

@aduh95
Copy link
Owner

aduh95 commented Jul 20, 2020

Hey! I have forked the web app as well, you can find it at aduh95.github.io/viz.js-playground.
As you can see, the issue still exists in this fork unfortunately… I'll try to investigate it, but if anyone else knows what might be going on here, suggestions are welcome.

@aduh95 aduh95 changed the title Is the character width bug fixed? multi-byte characters in labels take up twice as much space as in 'native' graphviz Jul 20, 2020
@aduh95
Copy link
Owner

aduh95 commented Jul 20, 2020

After digging out, it seems to be related to a font issue, it's still unclear to me if that's easily fixable at the level of Viz.js.

Reference: https://gitlab.com/graphviz/graphviz/-/issues/1712

@Nakilon
Copy link
Author

Nakilon commented Jul 20, 2020

Graphviz relies on freetype, pango, or quartz to render text to estimate its size.

As I understand Graphviz uses one thing to estimate sizes and another thing to actually render. Seems like in that Gitlab issue it lacked some libs during compilation. You probably need to have it when you compile the thing for github.io

@aduh95
Copy link
Owner

aduh95 commented Jul 21, 2020

Yes, although I don't know which libs, and at which step they are required. PR's welcome if anyone is able to get it working.

@aduh95 aduh95 added bug Something isn't working help wanted Extra attention is needed labels Aug 28, 2020
@christianvoigt
Copy link

Is this issue also related to measuring bold and italic text in html labels? See here for an example.

If not, I would open another issue.

I am pretty sure that there was once a version of Viz.js where this was not a problem. But on the current version of http://viz-js.com/ this is already occurring.

I tried to work around this by adding empty spaces between bold and non-bold text. But this does not work reliably.

@aduh95
Copy link
Owner

aduh95 commented Feb 27, 2021

Well if it's not reproducible on native graphviz, it's probably the same issue – or rather, it's probably the same solution.

I think the way to move forward would be to build native graphviz removing external library one-by-one to identify which one is needed to solve the issue.

@sebbloc
Copy link

sebbloc commented Mar 27, 2021

I made a workaround that works.
The principle is simple: since only the letters ascii work correctly, then I replace the texts in DOT by their equivalent of the same size.
I render and after I change to SVG with the original texts.
It's clearly heavy but it works.
Here is an illustraction:
bug viz no ascii2
You can play with there:
https://memodraw.com/?source=%D0%9C%D0%BB%D0%B5%D1%87%D0%BD%D1%8B%D0%B9_%D0%9F%D1%83%D1%82%D1%8C&sourceId=Q321&entry=ru.wdat&target=%D0%BA%D1%80%D0%B0%D1%81%D0%BD%D1%8B%D0%B9&targetId=Q3142&margin=0.5
I am currently working to distribute a JS to you (my current version is not general enough)

@aduh95
Copy link
Owner

aduh95 commented Mar 29, 2021

@sebbloc Thanks that looks promising :)

@sebbloc
Copy link

sebbloc commented Apr 10, 2021

This is my fix there:
https://github.com/sebbloc/fixWebGraphvizAscii

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

No branches or pull requests

4 participants