mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-24 11:58:32 +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
|
- name: docking feature
|
||||||
run: cargo test --workspace --all-targets --features docking
|
run: cargo test --workspace --all-targets --features docking
|
||||||
|
|
||||||
- name: freetype feature
|
- name: freetype feature (non-Windows, pkg-config)
|
||||||
if: matrix.os != 'windows-latest'
|
if: matrix.os != 'windows-latest'
|
||||||
run: cargo test --workspace --all-targets --features freetype
|
run: cargo test --workspace --all-targets --features freetype
|
||||||
|
|
||||||
- name: all features
|
- name: freetype and docking (non-Windows, pkg-config)
|
||||||
if: matrix.os != 'windows-latest'
|
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
|
- name: freetype feature (Windows, vcpkg)
|
||||||
run: cargo test --workspace --doc
|
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
|
# run to check for lint problems
|
||||||
- name: build documentation
|
- name: build documentation
|
||||||
run: cargo doc
|
run: cargo doc
|
||||||
|
|||||||
@ -33,9 +33,11 @@ cfg-if = "1"
|
|||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
pkg-config = { version="0.3", optional=true }
|
pkg-config = { version="0.3", optional=true }
|
||||||
|
vcpkg = { version="0.2.15", optional=true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
wasm = []
|
wasm = []
|
||||||
freetype = ["pkg-config"]
|
|
||||||
docking = []
|
docking = []
|
||||||
|
freetype = ["pkg-config"]
|
||||||
|
use-vcpkg = ["vcpkg"]
|
||||||
|
|||||||
@ -9,11 +9,29 @@ const DEFINES: &[(&str, Option<&str>)] = &[
|
|||||||
("IMGUI_DISABLE_OSX_FUNCTIONS", None),
|
("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<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
// Root of imgui-sys
|
// Root of imgui-sys
|
||||||
let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
|
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() {
|
for (key, value) in DEFINES.iter() {
|
||||||
println!("cargo:DEFINE_{}={}", key, value.unwrap_or(""));
|
println!("cargo:DEFINE_{}={}", key, value.unwrap_or(""));
|
||||||
}
|
}
|
||||||
@ -53,9 +71,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
// Freetype font rasterizer feature
|
// Freetype font rasterizer feature
|
||||||
#[cfg(feature = "freetype")]
|
#[cfg(feature = "freetype")]
|
||||||
{
|
{
|
||||||
// Find library
|
for include in find_freetype() {
|
||||||
let freetype = pkg_config::Config::new().find("freetype2").unwrap();
|
|
||||||
for include in freetype.include_paths.iter() {
|
|
||||||
build.include(include);
|
build.include(include);
|
||||||
}
|
}
|
||||||
// Set flag for dear imgui
|
// Set flag for dear imgui
|
||||||
|
|||||||
@ -5245,7 +5245,11 @@ CIMGUI_API bool igIsKeyPressedMap(ImGuiKey key,bool repeat)
|
|||||||
}
|
}
|
||||||
CIMGUI_API const ImFontBuilderIO* igImFontAtlasGetBuilderForStbTruetype()
|
CIMGUI_API const ImFontBuilderIO* igImFontAtlasGetBuilderForStbTruetype()
|
||||||
{
|
{
|
||||||
|
#ifdef IMGUI_ENABLE_FREETYPE
|
||||||
|
return static_cast<const ImFontBuilderIO*>(0);
|
||||||
|
#else
|
||||||
return ImFontAtlasGetBuilderForStbTruetype();
|
return ImFontAtlasGetBuilderForStbTruetype();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas)
|
CIMGUI_API void igImFontAtlasBuildInit(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user