Skip to content

Commit 9a5549c

Browse files
Add support for the STAT table. (#166)
1 parent e5ac245 commit 9a5549c

File tree

5 files changed

+497
-1
lines changed

5 files changed

+497
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ There are roughly three types of TrueType tables:
9191
| `OS/2` table ||| |
9292
| `post` table ||| |
9393
| `sbix` table | ~ (PNG only) | ~ (PNG only) | |
94+
| `STAT` table || | |
9495
| `SVG ` table ||||
9596
| `trak` table || | |
9697
| `vhea` table ||| |

examples/font-info.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ fn main() {
8484
}
8585
}
8686

87+
if let Some(stat) = face.tables().stat {
88+
println!("Style attributes:");
89+
90+
println!(" Axes:");
91+
for axis in stat.axes {
92+
println!(" {}", axis.tag);
93+
if let Some(subtable) = stat.subtable_for_axis(axis.tag, None) {
94+
println!(" {:?}", subtable)
95+
}
96+
}
97+
}
98+
8799
println!("Elapsed: {}us", now.elapsed().as_micros());
88100
}
89101

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ pub use tables::{ankr, feat, kerx, morx, trak};
8484
pub use tables::{avar, cff2, fvar, gvar, hvar, mvar, vvar};
8585
pub use tables::{cbdt, cblc, cff1 as cff, vhea};
8686
pub use tables::{
87-
cmap, colr, cpal, glyf, head, hhea, hmtx, kern, loca, maxp, name, os2, post, sbix, svg, vorg,
87+
cmap, colr, cpal, glyf, head, hhea, hmtx, kern, loca, maxp, name, os2, post, sbix, stat, svg,
88+
vorg,
8889
};
8990
#[cfg(feature = "opentype-layout")]
9091
pub use tables::{gdef, gpos, gsub, math};
@@ -938,6 +939,7 @@ pub struct RawFaceTables<'a> {
938939
pub os2: Option<&'a [u8]>,
939940
pub post: Option<&'a [u8]>,
940941
pub sbix: Option<&'a [u8]>,
942+
pub stat: Option<&'a [u8]>,
941943
pub svg: Option<&'a [u8]>,
942944
pub vhea: Option<&'a [u8]>,
943945
pub vmtx: Option<&'a [u8]>,
@@ -1008,6 +1010,7 @@ pub struct FaceTables<'a> {
10081010
pub os2: Option<os2::Table<'a>>,
10091011
pub post: Option<post::Table<'a>>,
10101012
pub sbix: Option<sbix::Table<'a>>,
1013+
pub stat: Option<stat::Table<'a>>,
10111014
pub svg: Option<svg::Table<'a>>,
10121015
pub vhea: Option<vhea::Table>,
10131016
pub vmtx: Option<hmtx::Table<'a>>,
@@ -1189,6 +1192,7 @@ impl<'a> Face<'a> {
11891192
b"name" => tables.name = table_data,
11901193
b"post" => tables.post = table_data,
11911194
b"sbix" => tables.sbix = table_data,
1195+
b"STAT" => tables.stat = table_data,
11921196
#[cfg(feature = "apple-layout")]
11931197
b"trak" => tables.trak = table_data,
11941198
b"vhea" => tables.vhea = table_data,
@@ -1305,6 +1309,7 @@ impl<'a> Face<'a> {
13051309
sbix: raw_tables
13061310
.sbix
13071311
.and_then(|data| sbix::Table::parse(maxp.number_of_glyphs, data)),
1312+
stat: raw_tables.stat.and_then(stat::Table::parse),
13081313
svg: raw_tables.svg.and_then(svg::Table::parse),
13091314
vhea: raw_tables.vhea.and_then(vhea::Table::parse),
13101315
vmtx,

src/tables/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod name;
1515
pub mod os2;
1616
pub mod post;
1717
pub mod sbix;
18+
pub mod stat;
1819
pub mod svg;
1920
pub mod vhea;
2021
pub mod vorg;

0 commit comments

Comments
 (0)