mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 21:48:36 +00:00
Merge pull request #582 from ruifengx/freetype-vcpkg
add vcpkg-rs for locating freetype
This commit is contained in:
commit
d0ccbd33d3
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
@ -136,17 +136,23 @@ jobs:
|
||||
- name: docking feature
|
||||
run: cargo test --workspace --all-targets --features docking
|
||||
|
||||
- name: freetype feature
|
||||
- name: freetype feature (non-Windows, pkg-config)
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: cargo test --workspace --all-targets --features freetype
|
||||
|
||||
- name: all features
|
||||
- name: freetype and docking (non-Windows, pkg-config)
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: cargo test --workspace --all-targets --features docking,freetype
|
||||
run: cargo test --workspace --all-targets --features freetype,docking
|
||||
|
||||
- name: doc tests
|
||||
run: cargo test --workspace --doc
|
||||
- name: freetype feature (Windows, vcpkg)
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: cargo test --workspace --all-targets --features freetype,use-vcpkg
|
||||
|
||||
- name: freetype and docking (Windows, vcpkg)
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: cargo test --workspace --all-targets --features freetype,docking,use-vcpkg
|
||||
|
||||
- run: cargo test --workspace --doc
|
||||
# run to check for lint problems
|
||||
- name: build documentation
|
||||
run: cargo doc
|
||||
|
||||
@ -33,9 +33,11 @@ cfg-if = "1"
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
pkg-config = { version="0.3", optional=true }
|
||||
vcpkg = { version="0.2.15", optional=true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
wasm = []
|
||||
freetype = ["pkg-config"]
|
||||
docking = []
|
||||
freetype = ["pkg-config"]
|
||||
use-vcpkg = ["vcpkg"]
|
||||
|
||||
@ -9,11 +9,29 @@ const DEFINES: &[(&str, Option<&str>)] = &[
|
||||
("IMGUI_DISABLE_OSX_FUNCTIONS", None),
|
||||
];
|
||||
|
||||
#[cfg(feature = "freetype")]
|
||||
fn find_freetype() -> Vec<impl AsRef<std::path::Path>> {
|
||||
#[cfg(not(feature = "use-vcpkg"))]
|
||||
match pkg_config::Config::new().find("freetype2") {
|
||||
Ok(freetype) => freetype.include_paths,
|
||||
Err(err) => panic!("cannot find freetype: {}", err),
|
||||
}
|
||||
#[cfg(feature = "use-vcpkg")]
|
||||
match vcpkg::find_package("freetype") {
|
||||
Ok(freetype) => freetype.include_paths,
|
||||
Err(err) => panic!("cannot find freetype: {}", err),
|
||||
}
|
||||
}
|
||||
|
||||
// Output define args for compiler
|
||||
fn main() -> std::io::Result<()> {
|
||||
// Root of imgui-sys
|
||||
let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
// Output define args for compiler
|
||||
println!(
|
||||
"cargo:THIRD_PARTY={}",
|
||||
manifest_dir.join("third-party").display()
|
||||
);
|
||||
for (key, value) in DEFINES.iter() {
|
||||
println!("cargo:DEFINE_{}={}", key, value.unwrap_or(""));
|
||||
}
|
||||
@ -53,9 +71,7 @@ fn main() -> std::io::Result<()> {
|
||||
// Freetype font rasterizer feature
|
||||
#[cfg(feature = "freetype")]
|
||||
{
|
||||
// Find library
|
||||
let freetype = pkg_config::Config::new().find("freetype2").unwrap();
|
||||
for include in freetype.include_paths.iter() {
|
||||
for include in find_freetype() {
|
||||
build.include(include);
|
||||
}
|
||||
// Set flag for dear imgui
|
||||
|
||||
@ -5245,7 +5245,11 @@ CIMGUI_API bool igIsKeyPressedMap(ImGuiKey key,bool repeat)
|
||||
}
|
||||
CIMGUI_API const ImFontBuilderIO* igImFontAtlasGetBuilderForStbTruetype()
|
||||
{
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
return static_cast<const ImFontBuilderIO*>(0);
|
||||
#else
|
||||
return ImFontAtlasGetBuilderForStbTruetype();
|
||||
#endif
|
||||
}
|
||||
CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user