Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use core maths #162

Merged
merged 3 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading