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

add MATH table #87

Merged
merged 15 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Cargo.lock
.directory
.DS_Store
.vscode
.idea
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ edition = "2018"
exclude = ["benches/**"]

[features]
default = ["std", "opentype-layout", "apple-layout", "variable-fonts", "glyph-names"]
default = ["std", "opentype-layout", "opentype-math", "apple-layout", "variable-fonts", "glyph-names"]
std = []
# Enables variable fonts support. Increases binary size almost twice.
# Includes avar, CFF2, fvar, gvar, HVAR, MVAR and VVAR tables.
variable-fonts = []
# Enables GDEF, GPOS and GSUB tables.
opentype-layout = []
# Enables MATH tables.
opentype-math = []
ruifengx marked this conversation as resolved.
Show resolved Hide resolved
# Enables feat, trak tables.
apple-layout = []
# Enables glyph name query via `Face::glyph_name`.
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub use tables::CFFError;
pub use tables::{cmap, kern, sbix, maxp, hmtx, name, os2, loca, svg, vorg, post, head, hhea, glyf};
pub use tables::{cff1 as cff, vhea, cbdt, cblc};
#[cfg(feature = "opentype-layout")] pub use tables::{gdef, gpos, gsub};
#[cfg(feature = "opentype-math")] pub use tables::math;
#[cfg(feature = "apple-layout")] pub use tables::{ankr, feat, trak};
#[cfg(feature = "variable-fonts")] pub use tables::{cff2, avar, fvar, gvar, hvar, mvar};

Expand Down Expand Up @@ -570,6 +571,8 @@ pub struct RawFaceTables<'a> {
#[cfg(feature = "opentype-layout")] pub gpos: Option<&'a [u8]>,
#[cfg(feature = "opentype-layout")] pub gsub: Option<&'a [u8]>,

#[cfg(feature = "opentype-math")] pub math: Option<&'a [u8]>,

#[cfg(feature = "apple-layout")] pub ankr: Option<&'a [u8]>,
#[cfg(feature = "apple-layout")] pub feat: Option<&'a [u8]>,
#[cfg(feature = "apple-layout")] pub trak: Option<&'a [u8]>,
Expand Down Expand Up @@ -618,6 +621,8 @@ pub struct FaceTables<'a> {
#[cfg(feature = "opentype-layout")] pub gpos: Option<opentype_layout::LayoutTable<'a>>,
#[cfg(feature = "opentype-layout")] pub gsub: Option<opentype_layout::LayoutTable<'a>>,

#[cfg(feature = "opentype-math")] pub math: Option<math::Table<'a>>,

#[cfg(feature = "apple-layout")] pub ankr: Option<ankr::Table<'a>>,
#[cfg(feature = "apple-layout")] pub feat: Option<feat::Table<'a>>,
#[cfg(feature = "apple-layout")] pub trak: Option<trak::Table<'a>>,
Expand Down Expand Up @@ -746,6 +751,8 @@ impl<'a> Face<'a> {
b"GPOS" => tables.gpos = table_data,
#[cfg(feature = "opentype-layout")]
b"GSUB" => tables.gsub = table_data,
#[cfg(feature = "opentype-math")]
b"MATH" => tables.math = table_data,
#[cfg(feature = "variable-fonts")]
b"HVAR" => tables.hvar = table_data,
#[cfg(feature = "variable-fonts")]
Expand Down Expand Up @@ -863,6 +870,8 @@ impl<'a> Face<'a> {
#[cfg(feature = "opentype-layout")] gpos: raw_tables.gpos.and_then(opentype_layout::LayoutTable::parse),
#[cfg(feature = "opentype-layout")] gsub: raw_tables.gsub.and_then(opentype_layout::LayoutTable::parse),

#[cfg(feature = "opentype-math")] math: raw_tables.math.and_then(math::Table::parse),

#[cfg(feature = "apple-layout")] ankr: raw_tables.ankr
.and_then(|data| ankr::Table::parse(maxp.number_of_glyphs, data)),
#[cfg(feature = "apple-layout")] feat: raw_tables.feat.and_then(feat::Table::parse),
Expand Down
Loading