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

Use SVG icons in PiGui fonts #5608

Merged
merged 11 commits into from
Aug 26, 2023
Merged

Conversation

sturnclaw
Copy link
Member

@sturnclaw sturnclaw commented Aug 23, 2023

This is a fun one - I've refactored the PiGui font handling to be a bit more efficient, and added support for loading icons from our icons.svg file as font glyphs (using the Unicode Private Use Range). This allows icon rendering to take advantage of the same pipeline for on-demand glyph rendering and font size management as regular text rendering, and when integrated will solve some issues with icon blurriness our current icon rendering system has.

This PR only implements the technical capability to load icons from SVG files and does not convert any Lua code to use the new capability.

TODO:

  • Don't hardcode icon grid, load from data file instead
  • Add specific "icon" font type which doesn't load basic characters (allow using odd-sized icons without pulling in 100+ unused character glyphs)

Allow rendering wiith user-provided material and transform
Allow inverting DrawData size for Y-flip
The new names follow convention better and correctly reflect the fact that these are widely available generic data formats.
- Avoid copying and modifying the entire reference font-face chain with every font instance
- Allow ImGUI to determine which font face is responsible for a glyph
- Simplify handling multiple font files and improve maintainability
- Architecture supports modifying font definitions with new faces at runtime
- Also pass reference to owning application to avoid need to reference Pi namespace inside PiGui::Instance
Allow loading SVG icons into an existing PiFont, using the same existing mechanisms for glyph tracking and font size handling as character fonts.

This massively simplifies using icons in editor code, and will improve the quality of icons in the main game as well.
- Allows using a more familiar and less complex syntax when iterating over files.
Existed only for OldUI/NewUI, entirely obsoleted by PiGui font handling.
- Remove old/unused font definitions
- Provide definitions for monospace, icon-only, and current pionillium/orbiteer fonts
- Avoids compiling icon grid size into binary (instead, need to update all font definition json files on change)
- If a font doesn't provide a used glyph in any of its faces, avoid constantly rebuilding the font atlas every frame.
- Remove PiFont::sortUsedRanges, as ImFontGlyphRangesBuilder already provides the same functionality.
@sturnclaw sturnclaw force-pushed the font-icons branch 2 times, most recently from 667d366 to 54f1c69 Compare August 25, 2023 08:55
@sturnclaw sturnclaw merged commit 4dd7fc8 into pioneerspacesim:master Aug 26, 2023
4 of 5 checks passed
@sturnclaw sturnclaw deleted the font-icons branch August 26, 2023 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant