Use Magnum's builtin text rendering instead of ImGui; expose it in Python#1853
Use Magnum's builtin text rendering instead of ImGui; expose it in Python#1853
Conversation
aclegg3
left a comment
There was a problem hiding this comment.
Running the viewer after installing on Fedora 36 I get:
PluginManager::Manager::Manager(): none of the plugin search paths in {../lib/magnum/fonts, magnum/fonts} exists and pluginDirectory was not set, skipping plugin discovery
PluginManager::Manager::load(): plugin TrueTypeFont is not static and was not found in
Cannot open font file
There's really no need to pull in that whole dependency for just a bit of text. At the very least, to keep the feeling, I reused the ImGui default font. Originally ImGui got used because Magnum::Text "seemed complicated", but I don't really think that's the case :P
|
Fixed, sorry! Forgot that you all use a build with bundled Magnum 😅 |
aclegg3
left a comment
There was a problem hiding this comment.
Works for me! Thanks for slicing out another dependency.
The text is rather larger now, let's shrink it down a bit.
Unfortunately, due to Python implicitly isolating loaded native modules,
this will only work if the following is done:
import ctypes, sys
flags = sys.getdlopenflags()
sys.setdlopenflags(flags | ctypes.RTLD_GLOBAL)
import magnum
# Now there's no StbTrueTypeFont yet
import habitat_sim
# Now there is
An alternative solution would be to force newer CMake to be used and
link the StbTrueTypeFont plugin to the magnum bindings module *from
outside* :/
|
@aclegg3 is it better now? I realized too late that the original setting was DPI-dependent and what looked alright on my 4K display with 1.6875x scaling was probably way too huge on non-HiDPI screens. Also I added a commit that links the font plugin for Python bindings, but unfortunately due to the dreaded problem with native Python modules being isolated from each other, it will only work if the following is done: import ctypes, sys
flags = sys.getdlopenflags()
sys.setdlopenflags(flags | ctypes.RTLD_GLOBAL)
import magnum
# Now there's no StbTrueTypeFont yet
import habitat_sim
# Now there is, but only thanks to RTLD_GLOBALAn alternative solution would be to force CMake 3.13+ to be used and link the font plugin to the magnum bindings module from outside, similarly to how Erik Wijmans did it for the Basis compressor here. Then the plugin would be available right after This is yet another case of the exact same problem stemming from static libraries getting duplicated across multiple shared modules. I'll try to find a manual workaround at least -- something that needs an explicit piece of code but doesn't require fiddling with the CMake build or with dlopen flags. |
Thanks, much better now!
A bit messy, but functional. We can add this chunk to the viewer python with a comment to this effect.
We already require CMake 3.14.0, so this doesn't sound like a blocker to me. |
|
|
|
@mosra I'd much rather upgrade it to 3.14. It's a pretty old-CMake and cmake is pretty easy to update use pip install. |
|
@mosra Happy to bump the cmake version for 3.14. I just checked and the latest OpenEXR is specifically cmake I'm even fine bumping up to 3.20 as we already require that for our emsdk build. |
|
"Pretty old" is relative ;) Personally I'm not bumping the minimal required version unless there's a significant new feature to use. And the "external linking" that's allowed since 3.13 feels like a hack in my opinion, and I'll provide a better way to handle static plugin dependencies for bindings and CLI utilities in a followup PR. Merging this as-is. What on Emscripten needs 3.20, btw? |
|
|
Motivation and Context
As we discussed in #1842, this does the following:
ProggyClean.ttfthat ImGui embeds.magnum-sceneconverterchanges yet, it's not really useful to anybody, actually. And for the batch renderer use case it also still needs custom scene field support and sampler property export to be finished.How Has This Been Tested
Here's how it looks now. Probably not pixel-perfect to what was there before, but I'd say pretty close. Coincidentally, in this particular case both ImGui and Magnum use the exact same font renderer. (I'd personally make the text significantly smaller, it's obnoxiously big, let me know if you want that.)
If anybody else should be added as a reviewer, please add them ;)