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

Rework layer text #389

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

AdenKoperczak
Copy link
Contributor

A few fixes for layer text.

  1. Ensure text is rendered on the correct layer
  2. Enable support for (most) OpenType font faces in layer text
  3. Some clang tidy fixes

Text rendering

Text is rendered on there layer by using an ImGui context for each layer. A separate context is used in MapWidget to render tooltips and to ensure that all fonts are loaded.
This works because MapLibre mostly renders layers from bottom to top. It does also use GL_DEPTH_TEST. ImGui's OpenGL backend explicitly disables this, so rendering is not perfect. In particular, the opaque layers of the map underlay are always rendered first, so putting a layer under this keeps the text on top of it. This is still much better than what we had before.

OpenType

I added OpenType CFF fonts for ImGui. This seems to be the most common OpenType format. This should enable the usage of most fonts on Linux systems.

RFC's

  1. Not checking the font format (TrueType vs CFF etc) also seems to work fine, but I have not tested it thoroughly. ImGui uses FreeType, which supports most common font formats, so this check may be unnecessary.
  2. I had to add a pointer to the MapWidget to MapContext in order for imgui_impl_qt to work. I think this is mostly inevitable, but maybe it should be done in a different way. (I am mostly worried about race conditions when shutting down).
  3. Some layers needed to initialize and use the ImGui context when running their own rendering code. I split up the ImGui code in such a way that it can be used successfully, but requires being somewhat careful when writing Render functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant