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

Added support to render OpenType SVG fonts using plutosvg as an alternative to lunasvg (fix #7187) #7927

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 27, 2024

  1. Added support to render OpenType SVG fonts using plutosvg as an alter…

    …native to lunasvg (fix ocornut#7187)
    
    <SVG Fonts include a set of SVG documents. As per the [OpenType specification](https://learn.microsoft.com/en-us/typography/opentype/spec/svg#glyph-identifiers),
    some SVG fonts (such as NotoColorEmoji) may group several glyphs in a common svg document (by selecting a subset of the elements in this document).
    
    LunaSvg does support fonts where each glyph is associated to a distinct document. Unfortunately, it is not able to render
    a subset of a svg document, and will likely not be able to do so in the future.
    
    Its cousin project plutosvg (by the same author), is able to do it, and provides ready to use freetype hooks.
    
    Example: sammycage/lunasvg#150 shows an example where a single svg document
    included in the font may contains thousands of glyphs (each glyph is a subset of the svg document).
    
    Pros and Cons
    -------------
    Since this commit adds some complexity in the code here is a study of the pros and cons:
    
    Pros:
    - plutosvg is faster than lunasvg
    - freetype hooks are provided by plutosvg (no need to provide them in imgui_freetype.cpp)
    
    Cons:
    - the compilation setup for plutosvg is a bit more complex than for lunasvg (requires plutovg + plutosvg)
    - no offical release is available yet for plutosvg. No vcpkg package available yet.
    - having two competing compilation flags is not ideal (IMGUI_ENABLE_FREETYPE_LUNASVG vs IMGUI_ENABLE_FREETYPE_PLUTOSVG)
      (it may be possible to remove IMGUI_ENABLE_FREETYPE_LUNASVG in the future, at the cost of breaking some users build upon upgrade)
    
    Compilation hints for plutovg/plutosvg
    --------------------------------------
    _Compilation hints for plutovg_
    - Compile all source files in `plutovg/source/*.c`
    - Add include directory: `plutovg/include` + `plutovg/stb`
    
    _Compilation hints for plutosvg_
    - Compile `plutosvg/source/plutosvg.c`
    - Add include directory: `plutosvg/source`
    - Add define: `PLUTOSVG_HAS_FREETYPE`
    - Link with: plutovg, freetype
    
    Demonstration repository
    -------------------------
    https://github.com/pthom/lunasvg_perf_issue
    pthom committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    b7ec13a View commit details
    Browse the repository at this point in the history