Skip to content

Commit

Permalink
Make core_maths optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
RazrFalcon committed Jul 2, 2024
1 parent a06b588 commit b38c0a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
override: true

- name: Build with no default features
run: cargo build --no-default-features
run: cargo build --no-default-features --features=no-std-float

- name: Build with std
run: cargo build --no-default-features --features std
run: cargo build --no-default-features --features=std

- name: Build with variable-fonts
run: cargo build --no-default-features --features variable-fonts
run: cargo build --no-default-features --features=variable-fonts,no-std-float

- name: Build with all features
run: cargo build --all-features
Expand All @@ -45,7 +45,7 @@ jobs:

- name: Build C API with variable-fonts
working-directory: c-api
run: cargo build --no-default-features --features variable-fonts
run: cargo build --no-default-features --features=variable-fonts

- name: Test C API
working-directory: c-api
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ edition = "2018"
exclude = ["benches/**"]

[dependencies]
core_maths = { version = "0.1.0" } # No-op for `std` builds.
core_maths = { version = "0.1.0", optional = true } # only for no_std builds

[features]
default = ["std", "opentype-layout", "apple-layout", "variable-fonts", "glyph-names"]
# Enables the use of the standard library.
# When disabled, the `no-std-float` feature must be enabled instead.
std = []
no-std-float = ["core_maths"]
# Enables variable fonts support. Increases binary size almost twice.
# Includes avar, CFF2, fvar, gvar, HVAR, MVAR and VVAR tables.
variable-fonts = []
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ Font parsing starts with a [`Face`].
#[macro_use]
extern crate std;

#[allow(unused_imports)]
use core_maths::*;
#[cfg(not(any(feature = "std", feature = "no-std-float")))]
compile_error!("You have to activate either the `std` or the `no-std-float` feature.");

#[cfg(not(feature = "std"))]
use core_maths::CoreFloat;

#[cfg(feature = "apple-layout")]
mod aat;
Expand Down

0 comments on commit b38c0a2

Please sign in to comment.