-
Notifications
You must be signed in to change notification settings - Fork 3
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
[solved] error on draw
: NaN values are not allowed for HTML or SVG nodes: ...
#66
Comments
In this setup with Vizagrams, are other packages working? Your issues seems system related. Someone had a similar issue a while ago, but then the user said that the error was actually in his setup (which should be the case, since the package has CI/CD testing which is passing). There is something you might try, which has been afflicting some users (me included). Which is updating the JLLWrappers package to version 1.7.0. I've just tested the package in a brand new LTS (1.10.7) Julia setup, and it worked once I've updated the JLLWrappers. BTW, my system is a Mac. Are you on Windows? Sometimes Windows is a bit clunky. |
Hi, thanks for the response!
As far as I can tell other packages are OK. Didn't try much other plotting packages (well, except for UnicodePlots which work, and Makie which has been failing here for some different reason (X11-related) since forever).
Ah ok, will try that (tomorrow). In case there's reports that this helps, could it be useful to have it bounded in actual package dependencies?
haha nooo no no nope noooope I wouldn't touch that thing with a thirty-foot insulated pole |
I've now tested the package using JuliaHub, and everything worked fine. My guess is something with your setup... Perhaps something related with packages versions. Did you try a clean setup to see if everything works? I mean, create a new folder, a new environment with Pkg.activate() and just install Vizagrams to see if it works. |
OK I'm on another machine now, but the same error is happening in a clean environment, julia |
Are you running in a jupyter notebook or Pluto notebook? Or just VSCode? Could you check if other plotting packages work? I'm not able to reproduce this error you are getting :/ Also, if you could perhaps share a screenshot with the code and the error. |
Hi, ...
posx = geom.pos[1]
# posy = h - geom.pos[2]
posy = geom.pos[2]
@info "style" s
sty, attr = split_style_attributes(s)
@info "primtosvg(::TextGeom)" geom geom.text posx posy sty attr
return m(
"text",
geom.text;
x=posx,
... I get:
I somehow guess the NaNpt is the problem. I wasn't able to find where the NaN gets in actually (adding explicit Any ideas on where to try next? :) |
ah btw
no, bare terminal + julia repl. I suffered through Makie installation and it seems to be able to save a picture. |
So is Makie working in your system? Using Vizagrams inside the terminal is probably not very useful, as it does not show the images... I truly have no idea what is going on here. This "NaN" issue is very odd, and since I can't reproduce it, it is quite hard to investigate. I've tried installing a different Julia version on my machine, and I also ran a brand new server using JuliaHub. Both worked without issues. If you had trouble installing Makie, this suggests to me that there is something going on with your machine and Julia in general, in other words, I don't think the issue is Vizagrams. In fact, the error message you posted suggested an error in the Hyperscript.jl package... but again, I don't think the issue is that package, but something in your setup. My suggestion would be to investigate if Julia installation is properly done in your computer. Did you use JuliaUp or something else? I'm sorry I can't be of much help. |
Julia is straight from Julia downloads, it's a clean install and works basically with everything. Makie fails for me because of Cairo dependency that is borked. About the NaNs in the Text geom:
Thanks! |
btw
I want this to generate pictures for Literate documents via CI, so it's always going to be drawsvg() and saving to a file. I guess the bare terminal is closest to that. |
I see. Indeed, this is a possibility. But does simple diagrams without text work? I mean d = Circle()
draw(d) If this works, and only the BTW, you can just use |
yes that works perfectly (I noted that above but not very strongly I see :) ) EDIT: I noted that super implicitly, sorry. 😁 |
OK I realized I could just run Vizagrams test suite and it looks to point at the precise issue. Looks like it's FreeType issue and it kills envelopes. I think it fails loading or rendering the bundled (On a related note you might want to avoid bundling actual helvetica TTF. Neglecting the possible copyright issues (Julia General might not be happy here), there's TeXGyreHeros which is much better for almost all concievable purposes, and the license is much more friendly there.) |
Oh, thanks for pointing it. I did not know. I'll make the switch. |
Test log here: |
I think there's (or should be!) a julia package already which bundles the TexGyre fonts, possibly best to defer to that. |
Just for the record, culprit is: julia> TextGeom(fontsize=15, text="hello")
TextGeom("hello", [0, 0], 15, 0, "Helvetica")
julia> envelope(TextGeom(fontsize=15, text="hello"), S(), [1,0])
NaN |
The envelope requires the font... Now the missing point is why FreeType is not working in your setup. |
OK so in the end it's the fonts. For whatever reason this happens: julia> face = FreeTypeAbstraction.findfont("helvetica")
FTFont (family = Helvetica, style = Regular)
julia> FreeTypeAbstraction.get_extent(face, 'a')
FreeTypeAbstraction.FontExtent{Float32}(Float32[-Inf, Inf], Float32[NaN, Inf], Float32[Inf, Inf], Float32[Inf, Inf])
julia> face = FreeTypeAbstraction.findfont("TeXGyreHeros")
FTFont (family = TeXGyreHeros, style = Regular)
julia> FreeTypeAbstraction.get_extent(face, 'a')
FreeTypeAbstraction.FontExtent{Float32}(Float32[0.0, 0.0], Float32[0.042, 0.539], Float32[0.556, 0.0], Float32[0.493, 0.554])
what's kinda weird is that I don't have any actual helvetica.ttf on my system so I have no clue where it takes the helvetica from. Fixing the default name to TeXGyreHeros seems to solve the issue. |
(the actual problem here is that the Is there any way to extract some information on "where it actually found the font" from the font_face structure that comes from findfont? |
ok the culprit is fontconfig, which aliases helvetica to something that FreeType seems to be able to load but never actually gets a working glyph from. I assume this will happen wildly on linux and BSD machines given the general practice with fontconfig nowadays. Mine is on debian testing but the same might get very easily also get inherited into Ubuntu and Mint. If possible, can we:
Thanks! |
Sounds good. Glad you figured out the issue. |
I see you started to work on some PRs. There are some things I must point though. The issue is actually that for some reason I'm trying to figure out if your issue is actually related to FreeFontType.jl and not to Vizagrams. But anyways, I'll try to write a function to try to catch the error you are facing. |
OK, re the PRs please feel free to close if the correct solution is different, these were just things that I applied to get it working here. Regarding the fontage, I think it actually managed to open some fixed-size bitmap helvetica-like font which Xft by default uses as a replacement for helvetica (wonders of having to support legacy apps! :)). Metrics of these are wild. So maybe it might be sufficient to somehow tell the font finder that we only want actual vector ones that have sensible metrics. OTOH I'd say that whenever there's a NaN coming from the metrics when we actually need the dimension, the plotting is basically doomed, no? (except if we have some super simple case where sizing of stuff does provably not depend on the font sizing) |
Thanks for the effort on the PRs! I think I do agree with changing Helvetica. I just checked, and |
Ah well that makes you a much happier person tbh. 🤣 Re the actual origin of the NaN, it might be here: https://github.com/JuliaGraphics/FreeTypeAbstraction.jl/blob/master/src/types.jl#L84 ...as called from: https://github.com/JuliaGraphics/FreeTypeAbstraction.jl/blob/master/src/types.jl#L233 Pixel/bitmap fonts are AFAIK not required to have these metrics at all, so we're likely ending up with I think this settles the issue but still I'd love to have some helpful fix in place; at least the comprehensible error message from #67 if possible. :) |
Solved for me and hopefully for various others by #69 . The rest of ideas lives in the other 2 PRs |
draw
: NaN values are not allowed for HTML or SVG nodes: ...draw
: NaN values are not allowed for HTML or SVG nodes: ...
Just for completeness, adding a possible quick and reasonably-correct solution: The offending fonts are bitmap fonts and bitmap Helvetica that sometimes (often) gets installed with Debian, Ubuntus and Mints. The packages are:
Removing them has no big effect in most systems (unless you use very legacy software) and works this issue around. |
Thanks, @exaexa! |
Hi,
on one setup I got Vizagrams reporting the following error when trying to
draw
orsavesvg
:The reproducer is literally the first (or any other) plotting example from here: https://davibarreira.github.io/Vizagrams.jl/dev/#Quickstart
My version info and packages are below:
I was unfortunately unable to find anything usable to see where the issue comes from. If there is any debugging I can do please send commands to run/try.
Thank you!
-mk
The text was updated successfully, but these errors were encountered: