diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 6c9b1b3..b84e529 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -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) diff --git a/README.markdown b/README.markdown index fe039db..3754ac7 100644 --- a/README.markdown +++ b/README.markdown @@ -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 diff --git a/imgui-sys/Cargo.toml b/imgui-sys/Cargo.toml index 29a68bb..f439900 100644 --- a/imgui-sys/Cargo.toml +++ b/imgui-sys/Cargo.toml @@ -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"] diff --git a/imgui-sys/build.rs b/imgui-sys/build.rs index 25a11dc..3dd6f79 100644 --- a/imgui-sys/build.rs +++ b/imgui-sys/build.rs @@ -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. diff --git a/imgui-sys/include_all_imgui.cpp b/imgui-sys/include_all_imgui.cpp index 2ba5922..fbda88d 100644 --- a/imgui-sys/include_all_imgui.cpp +++ b/imgui-sys/include_all_imgui.cpp @@ -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 + diff --git a/imgui/Cargo.toml b/imgui/Cargo.toml index 8fa6215..0034699 100644 --- a/imgui/Cargo.toml +++ b/imgui/Cargo.toml @@ -19,6 +19,7 @@ parking_lot = "0.11" [features] wasm = ["imgui-sys/wasm"] +freetype = ["imgui-sys/freetype"] [dev-dependencies] memoffset = "0.6"