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 support for the STAT table. #166

Merged
merged 17 commits into from
Aug 22, 2024
Merged
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ There are roughly three types of TrueType tables:
| `OS/2` table | ✓ | ✓ | |
| `post` table | ✓ | ✓ | |
| `sbix` table | ~ (PNG only) | ~ (PNG only) | |
| `STAT` table | ✓ | | |
| `SVG ` table | ✓ | ✓ | ✓ |
| `trak` table | ✓ | | |
| `vhea` table | ✓ | ✓ | |
Expand Down
12 changes: 12 additions & 0 deletions examples/font-info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ fn main() {
}
}

if let Some(stat) = face.tables().stat {
inferiorhumanorgans marked this conversation as resolved.
Show resolved Hide resolved
println!("Style attributes:");

println!(" Axes:");
for axis in stat.axes {
println!(" {}", axis.tag);
if let Some(subtable) = stat.subtable_for_axis(axis.tag, None) {
println!(" {:?}", subtable)
}
}
}

println!("Elapsed: {}us", now.elapsed().as_micros());
}

Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ pub use tables::{ankr, feat, kerx, morx, trak};
pub use tables::{avar, cff2, fvar, gvar, hvar, mvar, vvar};
pub use tables::{cbdt, cblc, cff1 as cff, vhea};
pub use tables::{
cmap, colr, cpal, glyf, head, hhea, hmtx, kern, loca, maxp, name, os2, post, sbix, svg, vorg,
cmap, colr, cpal, glyf, head, hhea, hmtx, kern, loca, maxp, name, os2, post, sbix, stat, svg,
vorg,
};
#[cfg(feature = "opentype-layout")]
pub use tables::{gdef, gpos, gsub, math};
Expand Down Expand Up @@ -938,6 +939,7 @@ pub struct RawFaceTables<'a> {
pub os2: Option<&'a [u8]>,
pub post: Option<&'a [u8]>,
pub sbix: Option<&'a [u8]>,
pub stat: Option<&'a [u8]>,
pub svg: Option<&'a [u8]>,
pub vhea: Option<&'a [u8]>,
pub vmtx: Option<&'a [u8]>,
Expand Down Expand Up @@ -1008,6 +1010,7 @@ pub struct FaceTables<'a> {
pub os2: Option<os2::Table<'a>>,
pub post: Option<post::Table<'a>>,
pub sbix: Option<sbix::Table<'a>>,
pub stat: Option<stat::Table<'a>>,
pub svg: Option<svg::Table<'a>>,
pub vhea: Option<vhea::Table>,
pub vmtx: Option<hmtx::Table<'a>>,
Expand Down Expand Up @@ -1189,6 +1192,7 @@ impl<'a> Face<'a> {
b"name" => tables.name = table_data,
b"post" => tables.post = table_data,
b"sbix" => tables.sbix = table_data,
b"STAT" => tables.stat = table_data,
#[cfg(feature = "apple-layout")]
b"trak" => tables.trak = table_data,
b"vhea" => tables.vhea = table_data,
Expand Down Expand Up @@ -1305,6 +1309,7 @@ impl<'a> Face<'a> {
sbix: raw_tables
.sbix
.and_then(|data| sbix::Table::parse(maxp.number_of_glyphs, data)),
stat: raw_tables.stat.and_then(stat::Table::parse),
svg: raw_tables.svg.and_then(svg::Table::parse),
vhea: raw_tables.vhea.and_then(vhea::Table::parse),
vmtx,
Expand Down
1 change: 1 addition & 0 deletions src/tables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod name;
pub mod os2;
pub mod post;
pub mod sbix;
pub mod stat;
pub mod svg;
pub mod vhea;
pub mod vorg;
Expand Down
Loading
Loading