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

[ift] Put ift-related code behind a feature #1349

Merged
merged 1 commit into from
Feb 10, 2025
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
4 changes: 2 additions & 2 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ release = false
[dependencies]
libfuzzer-sys = { version = "0.4", features = ["arbitrary-derive"] }
font-types = { workspace = true }
read-fonts = { workspace = true, default-features = true }
write-fonts = { workspace = true, default-features = true }
read-fonts = { workspace = true, default-features = true, features = ["ift"] }
write-fonts = { workspace = true, default-features = true, features = ["ift"] }
skrifa = { workspace = true }
incremental-font-transfer = { workspace = true }

Expand Down
4 changes: 2 additions & 2 deletions incremental-font-transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ default = ["read-fonts/std"]
cli = ["clap", "regex"]

[dependencies]
read-fonts = { workspace = true }
write-fonts = { workspace = true }
read-fonts = { workspace = true, features = ["ift"] }
write-fonts = { workspace = true, features = ["ift"] }
font-types = { workspace = true }
skrifa = { workspace = true }
klippa = { workspace = true }
Expand Down
3 changes: 3 additions & 0 deletions read-fonts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ features = ["libm", "serde", "std"]
std = ["font-types/std"]
codegen_test = []
scaler_test = []
# experimental support for incremental font transfer (https://www.w3.org/TR/IFT/)
# code behind this feature does not honor semver and may break at any time.
ift = []
# this feature is not stable, but provides untyped traversal of font tables.
# we do not consider this feature public API for the purposes of semver.
experimental_traverse = ["std"]
Expand Down
2 changes: 2 additions & 0 deletions read-fonts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub(crate) mod codegen_prelude {
(count.try_into().unwrap_or_default() + 7) / 8
}

#[cfg(feature = "ift")]
pub fn max_value_bitmap_len<T: TryInto<usize>>(count: T) -> usize {
let count: usize = count.try_into().unwrap_or_default() + 1usize;
(count + 7) / 8
Expand All @@ -160,6 +161,7 @@ pub(crate) mod codegen_prelude {
.saturating_mul(c.try_into().unwrap_or_default())
}

#[cfg(feature = "ift")]
pub fn multiply_add<T: TryInto<usize>, U: TryInto<usize>, V: TryInto<usize>>(
a: T,
b: U,
Expand Down
2 changes: 2 additions & 0 deletions read-fonts/src/table_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,13 @@ pub trait TableProvider<'a> {
self.expect_table()
}

#[cfg(feature = "ift")]
fn ift(&self) -> Result<tables::ift::Ift<'a>, ReadError> {
self.expect_data_for_tag(tables::ift::IFT_TAG)
.and_then(FontRead::read)
}

#[cfg(feature = "ift")]
fn iftx(&self) -> Result<tables::ift::Ift<'a>, ReadError> {
self.expect_data_for_tag(tables::ift::IFTX_TAG)
.and_then(FontRead::read)
Expand Down
4 changes: 3 additions & 1 deletion read-fonts/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub mod head;
pub mod hhea;
pub mod hmtx;
pub mod hvar;
pub mod ift;
pub mod layout;
pub mod loca;
pub mod ltag;
Expand All @@ -49,6 +48,9 @@ pub mod vmtx;
pub mod vorg;
pub mod vvar;

#[cfg(feature = "ift")]
pub mod ift;

/// Computes the table checksum for the given data.
///
/// See the OpenType [specification](https://learn.microsoft.com/en-us/typography/opentype/spec/otff#calculating-checksums)
Expand Down
1 change: 1 addition & 0 deletions write-fonts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ default = []
read = []
dot2 = ["dep:dot2"]
serde = ["dep:serde", "font-types/serde", "read-fonts/serde"]
ift = ["read-fonts/ift"]

[dependencies]
font-types = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion write-fonts/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub mod head;
pub mod hhea;
pub mod hmtx;
pub mod hvar;
pub mod ift;
pub mod layout;
pub mod loca;
pub mod maxp;
Expand All @@ -32,6 +31,9 @@ pub mod variations;
pub mod vhea;
pub mod vmtx;

#[cfg(feature = "ift")]
pub mod ift;

// ensure that all of our types implement the serde traits
#[cfg(feature = "serde")]
#[test]
Expand Down