Merge pull request #496 from dbr/freetype

This commit is contained in:
Jonathan Spira 2021-09-09 15:24:52 -07:00 committed by GitHub
commit bde35e9f3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 0 deletions

View File

@ -61,6 +61,8 @@ with the exception of the current default winit feature/dep version. Additionall
- If you're using `DEP_IMGUI_DEFINE_`s for this already, then no change is needed.
- If you're using `.cargo/config` to apply a build script override and link against a prebuilt `Dear Imgui` (or something else along these lines), you need to ensure you link with a version that was built using `-DIMGUI_USE_WCHAR32`.
- Support for the freetype font rasterizer. Enabled by the non-default `freetype` feature, e.g `imgui = {version = "...", features=["freetype"]})`
## [0.7.0] - 2021-02-04
- Upgrade to [Dear ImGui v1.80](https://github.com/ocornut/imgui/releases/tag/v1.80). (Note that the new table functionality is not yet supported, however)

View File

@ -47,6 +47,7 @@ Window::new(im_str!("Hello world"))
for more information and justification for this design.
- Easy integration with Glium / pre-ll gfx (renderer)
- Easy integration with winit (backend platform)
- Optional support for the freetype font rasterizer
## Choosing a backend platform and a renderer

View File

@ -18,7 +18,9 @@ chlorine = "1.0.7"
[build-dependencies]
cc = "1.0"
pkg-config = { version="0.3", optional=true }
[features]
default = []
wasm = []
freetype = ["pkg-config"]

View File

@ -48,6 +48,20 @@ fn main() -> io::Result<()> {
build.define(key, *value);
}
// Freetype font rasterizer feature
#[cfg(feature = "freetype")]
{
let freetype = pkg_config::Config::new().find("freetype2").unwrap();
for include in freetype.include_paths.iter() {
build.include(include);
}
build.define("IMGUI_ENABLE_FREETYPE", None);
println!("cargo:DEFINE_IMGUI_ENABLE_FREETYPE=");
// imgui_freetype.cpp needs access to imgui.h
build.include(manifest_dir.join("third-party/imgui/"));
}
let compiler = build.get_compiler();
// Avoid the if-supported flag functions for easy cases, as they're
// kinda costly.

View File

@ -9,4 +9,8 @@
#include "./third-party/imgui/imgui_tables.cpp"
#include "./third-party/cimgui.cpp"
#ifdef IMGUI_ENABLE_FREETYPE
#include "./third-party/imgui/misc/freetype/imgui_freetype.cpp"
#endif

View File

@ -19,6 +19,7 @@ parking_lot = "0.11"
[features]
wasm = ["imgui-sys/wasm"]
freetype = ["imgui-sys/freetype"]
[dev-dependencies]
memoffset = "0.6"