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

Wasm-shaper info #161

Closed
wants to merge 5 commits into from
Closed
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
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ glyph-names = []
# enable this feature.
gvar-alloc = ["std"]

# Enables experimental features, such as the WASM Shaper experimental feature,
# ported from HarfBuzz. https://github.com/harfbuzz/harfbuzz/blob/main/docs/wasm-shaper.md
experimental = ["wasm-shaper"]
wasm-shaper = []

[dev-dependencies]
base64 = "0.22.1"
pico-args = "0.5"
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub use fvar::VariationAxis;
pub use language::Language;
pub use name::{name_id, PlatformId};
pub use os2::{Permissions, ScriptMetrics, Style, UnicodeRanges, Weight, Width};
#[cfg(feature = "wasm-shaper")]
pub use tables::wasm;
pub use tables::CFFError;
#[cfg(feature = "apple-layout")]
pub use tables::{ankr, feat, kerx, morx, trak};
Expand Down Expand Up @@ -971,6 +973,8 @@ pub struct RawFaceTables<'a> {
pub mvar: Option<&'a [u8]>,
#[cfg(feature = "variable-fonts")]
pub vvar: Option<&'a [u8]>,
#[cfg(feature = "wasm-shaper")]
pub wasm: Option<&'a [u8]>,
}

/// Parsed face tables.
Expand Down Expand Up @@ -1041,6 +1045,8 @@ pub struct FaceTables<'a> {
pub mvar: Option<mvar::Table<'a>>,
#[cfg(feature = "variable-fonts")]
pub vvar: Option<vvar::Table<'a>>,
#[cfg(feature = "wasm-shaper")]
pub wasm: Option<wasm::Table<'a>>,
}

/// A font face.
Expand Down Expand Up @@ -1187,6 +1193,8 @@ impl<'a> Face<'a> {
b"trak" => tables.trak = table_data,
b"vhea" => tables.vhea = table_data,
b"vmtx" => tables.vmtx = table_data,
#[cfg(feature = "wasm-shaper")]
b"Wasm" => tables.wasm = table_data,
_ => {}
}
}
Expand Down Expand Up @@ -1348,6 +1356,8 @@ impl<'a> Face<'a> {
mvar: raw_tables.mvar.and_then(mvar::Table::parse),
#[cfg(feature = "variable-fonts")]
vvar: raw_tables.vvar.and_then(vvar::Table::parse),
#[cfg(feature = "wasm-shaper")]
wasm: raw_tables.wasm.and_then(wasm::Table::parse),
})
}

Expand Down
3 changes: 3 additions & 0 deletions src/tables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub mod mvar;
#[cfg(feature = "variable-fonts")]
pub mod vvar;

#[cfg(feature = "wasm-shaper")]
pub mod wasm;

pub use cff::cff1;
#[cfg(feature = "variable-fonts")]
pub use cff::cff2;
Expand Down
19 changes: 19 additions & 0 deletions src/tables/wasm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! A [WASM table](https://github.com/harfbuzz/harfbuzz/blob/main/docs/wasm-shaper.md) experimental implementation

#![allow(unused)] // for the time being

use crate::parser::{Offset as _, Offset32, Stream};

/// A WASM module. Contains the WASM Raw Data
#[derive(Clone, Copy, Debug)]
pub struct Table<'a> {
/// Raw WASM data in WASM format.
pub wasm_data: &'a [u8],
}

impl<'a> Table<'a> {
/// Parses a table from raw data.
pub fn parse(data: &'a [u8]) -> Option<Self> {
Some(Table { wasm_data: data })
}
}
Loading