Skip to content

Commit

Permalink
Use core_maths instead of libm
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Jun 30, 2024
1 parent 87f6dc9 commit 9561033
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

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

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

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

- name: Build with all features
run: cargo build --all-features
Expand Down
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ edition = "2018"
exclude = ["benches/**"]

[dependencies]
libm = { version = "0.2.8", optional = true }
core_maths = { version = "0.1.0"}

[features]
default = ["std", "opentype-layout", "apple-layout", "variable-fonts", "glyph-names"]
# Enables the use of the standard library. Deactivate this and activate the no-std-float
# feature to compile for targets that don't have std.
# Enables the use of the standard library.
std = []
no-std-float = ["libm"]
# Enables variable fonts support. Increases binary size almost twice.
# Includes avar, CFF2, fvar, gvar, HVAR, MVAR and VVAR tables.
variable-fonts = []
Expand Down
23 changes: 2 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ mod tables;
#[cfg(feature = "variable-fonts")]
mod var_store;

#[allow(unused_imports)]
use core_maths::*;
use head::IndexToLocationFormat;
pub use parser::{Fixed, FromData, LazyArray16, LazyArray32, LazyArrayIter16, LazyArrayIter32};
use parser::{NumFrom, Offset, Offset32, Stream, TryNumFrom};
Expand Down Expand Up @@ -2412,24 +2414,3 @@ pub fn fonts_in_collection(data: &[u8]) -> Option<u32> {
s.skip::<u32>(); // version
s.read::<u32>()
}

#[allow(missing_docs)]
#[cfg(all(not(feature = "std"), feature = "no-std-float"))]
pub(crate) trait NoStdFloat {
fn sin(self) -> Self;
fn cos(self) -> Self;
fn tan(self) -> Self;
}

#[cfg(all(not(feature = "std"), feature = "no-std-float"))]
impl NoStdFloat for f32 {
fn sin(self) -> Self {
libm::sinf(self)
}
fn cos(self) -> Self {
libm::cosf(self)
}
fn tan(self) -> Self {
libm::tanf(self)
}
}

0 comments on commit 9561033

Please sign in to comment.