Open benmkw opened 3 years ago
I'll try to reproduce this on my end. Things do get wrapped in im_str!
, for the axis labels this happens here: https://github.com/4bb4/implot-rs/blob/master/src/plot.rs#L245 - but maybe something else is going wrong. What are you seeing when you use €? Nothing? Or weird other letters?
If I e.g. change the y_label in my wgpu pr in show_basic_plot
to "€" it crashes.
Plot::new("Simple line plot")
// The size call could also be omitted, though the defaults don't consider window
// width, which is why we're not doing so here.
.size(content_width, 300.0)
.y_label(&"€")
.build(plot_ui, || {
// If this is called outside a plot build callback, the program will panic.
let x_positions = vec![0.1, 0.9];
let y_positions = vec![0.1, 0.9];
PlotLine::new("legend label").plot(&x_positions, &y_positions);
});
Assertion failed: ((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size), function AddDrawListToDrawData, file third-party/imgui/imgui.cpp, line 4047.
fish: 'cargo run --release' terminated by signal SIGABRT (Abort)
interestingly it does not crash if used as x_label but just shows a "?"
I certainly had it not crash at the y axis and just produce artefacts for rendering though (hundreds of long white lines across the plotting area) as well.
interestingly it does not crash if used as x_label but just shows a "?"
This sounds like a memory issue. I'll have to walk through it with a debugger to see what's going wrong - I thought I could just do im_str!("{}" my_string).as_ptr()
and presto I have a char ptr, but apparently things are not that simple...
EDIT: Ooh, I think I know what the problem is - the result of im_str!() is a temporary here and may be deleted before it is used. I'll try out a fix (probably not before tomorrow though) and let you know how it goes.
EDIT 2: Now with the right account xD I wondered why I got a notification for my own comment
I did some checks, here's what I found so far:
ui.text
. That tells me that likely the font that is loaded just can't display that.AddVerticalText
function, which does some fancy stuff for dealing with UTF: https://github.com/epezent/implot/blob/master/implot.cpp#L255. It would be interesting to see if we see the glitches also in the C++ version - if we do, that means it's a bug in implot itself.Did you verify that "€" is represented in the glyph ranges that you used and is it in your texture atlas?
@aloucks No, and I suspect that this may be the issue. I did check that the FindGlyph
call in https://github.com/epezent/implot/blob/master/implot.cpp#L277 returned a non-null pointer when I was stepping through it with a debugger, if I remember correctly.
If this is the issue, I'd be interested in what to do / check in the code in order to make sure that a user specifying valid UTF does not lead to the program drawing glitches or even crashing though - if that's possible with reasonable effort.
@benmkw Have you tried out another font in the meantime?
No :/ I played with using your project as a template basically to port imnodes though until my laptop broke yesterday so I was/ am in the process of looking at more details/ trying some things out for this whole API thing. I‘ll have to see how much further I push this on windows or if I do a bit less for a bit.
Alright, I need to try using other fonts for work at some point in the future anyway, I'll make sure to plop an €
in there to see if it works and ping you with an update
I used "€" so I assume only ascii is allowed or maybe it would have to be wrapped into im_str! or sth. on an api level. I've not looked into the internals but maybe this helps someone debugging :)