Skip to content

Commit

Permalink
Add support for the STAT table. (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
inferiorhumanorgans committed Aug 22, 2024
1 parent e5ac245 commit 9a5549c
Show file tree
Hide file tree
Showing 5 changed files with 497 additions and 1 deletion.
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 {
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

0 comments on commit 9a5549c

Please sign in to comment.