-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Support for OpenType SVG fonts #6591
Conversation
The problem with librsvg on windows is the vcpkg package is deprecated since it has switched to rust which vcpkg toolchain doesn't really support. This means we couldn't use the proper I've been struggling to build librsvg on windows, considering how heavy and problematic it is, switching to a more lightweight, easy-to-install library like lunasvg might be ideal. |
This now uses lunasvg instead of librsvg, it is way faster (not measured but maybe ~10x) and renders better than librsvg. I've also updated the vcpkg port to 2.3.8, so installing the dependencies is not a problem anymore, and we don't need to add a bunch of additional include directories like with the librsvg. |
Finally, thank you! Now i can use the notoemoji font Note: You may need to cd to vcpkg directory and @ocornut any chance of merging? |
Thanks for the PR. I was initially hesitant in the first draft because of the librsvg availability issue you mentioned + the fact it used to be much more code, but switching to lunasvg makes it much saner and shorter. I'll need to try it and review more carefully, but in the meantime if you don't mind, some quick feedback:
Thanks a lot! |
I would also suggest using |
Sorry I did not think about the licensing issue, but since most of the original code from the demo is replaced, I believe it is fair use. |
…n about the FreeType demo license
@ocornut I'm not really sure how to go about adding information about the demo license, would you mind checking? imconfig.h
//---- Use lunasvg library to render OpenType SVG fonts (SVGinOT)
// Requires lunasvg headers to be available in the include path. Requires program to be compiled with the lunasvg library (not provided).
// See https://github.com/ocornut/imgui/tree/master/misc/freetype
// Only works in combination with IMGUI_ENABLE_FREETYPE.
+// The implementation is based on the demo https://gitlab.freedesktop.org/freetype/freetype-demos/-/blob/master/src/rsvg-port.c
+// which is licensed under CeCILL-C Free Software License Agreement
//#define IMGUI_ENABLE_FREETYPE_LUNASVG
imgui_freetype.cpp
#ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
// For more details, see https://gitlab.freedesktop.org/freetype/freetype-demos/-/blob/master/src/rsvg-port.c
+// The original code from the demo is licensed under CeCILL-C Free Software License Agreement
+// https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/LICENSE.TXT |
Lunasvg is a great library but it still lacks some features in comparison with other libraries. For example, it lacks text and image rendering (lunasvg#113), which might be a deal breaker for some users using their own custom fonts (but not an issue with noto-emoji and twemoji). Ideally, we may want to use resvg which is currently the best svg rendering library that I could find, but again, just like with the librsvg - it is in Rust, hopefully vcpkg#30251 will get merged some day and resvg can be added in the future along with lunasvg. Although if resvg were to be added in the future, it's a little problematic to have two options doing the exact same thing. |
One question, could we support skin tone? |
Probably not as the modifier depends on a subset of Unicode specs we don't support nor intend to support. |
@ocornut sorry to rush but could this be merged before the next release? I'd like to use this with vcpkg |
misc/freetype/imgui_freetype.cpp
Outdated
// Calculate the bitmap size | ||
slot->bitmap_left = FT_Int(box.x); | ||
slot->bitmap_top = FT_Int(-box.y); | ||
slot->bitmap.rows = unsigned int(ceil(box.h)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here should be (unsigned int)(cell(box.h))
. Not sure why CI passed, but this is not valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed invalid, Explicit type conversion section 2)
The functional-style cast expression consists of a simple type specifier or a typedef specifier (in other words, a single-word type name, that is, cases such as
unsigned int(expression)
andint*(expression)
are not valid), followed by a comma-separated list of expressions in parentheses.
Interestingly, both MSVC compiler and intellisense did not complain about this, godbolt.
CI passed because we haven't added the test with IMGUI_ENABLE_FREETYPE_OTSVG
enabled.
See #7187 suggesting that current version of Lunasvg may have performance issues in some situations, hopefully fixed soon. |
Can you upload a copy of your twemoji font? Why did the twemoji I downloaded from GitHub only show a part? I want to know what the reason is |
Support for OpenType SVG fonts (SVGinOT)
Motivation
How it works
Enable SVG support and install required libraries
#define IMGUI_ENABLE_FREETYPE_OTSVG
in yourimconfig.h
.vcpkg install lunasvg --triplet=x64-windows
.Preview