Skip to content

Commit

Permalink
support ttc
Browse files Browse the repository at this point in the history
  • Loading branch information
zimond committed Oct 26, 2022
1 parent a80c9bd commit 9d3bd2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ matcher_map!(
"otf",
matchers::font::is_otf
),
(
MatcherType::Font,
"application/font-collection",
"ttc",
matchers::font::is_ttc
),
// Document
(
MatcherType::Doc,
Expand Down
17 changes: 7 additions & 10 deletions src/matchers/font.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
/// Returns whether a buffer is WOFF font data.
pub fn is_woff(buf: &[u8]) -> bool {
buf.len() > 3
&& buf[0] == 0x77
&& buf[1] == 0x4F
&& buf[2] == 0x46
&& buf[3] == 0x46
buf.len() > 3 && buf[0] == 0x77 && buf[1] == 0x4F && buf[2] == 0x46 && buf[3] == 0x46
}

/// Returns whether a buffer is WOFF2 font data.
pub fn is_woff2(buf: &[u8]) -> bool {
buf.len() > 3
&& buf[0] == 0x77
&& buf[1] == 0x4F
&& buf[2] == 0x46
&& buf[3] == 0x32
buf.len() > 3 && buf[0] == 0x77 && buf[1] == 0x4F && buf[2] == 0x46 && buf[3] == 0x32
}

/// Returns whether a buffer is TTF font data.
Expand All @@ -35,3 +27,8 @@ pub fn is_otf(buf: &[u8]) -> bool {
&& buf[3] == 0x4F
&& buf[4] == 0x00
}

/// Returns whether a buffer is TTC font data.
pub fn is_ttc(buf: &[u8]) -> bool {
buf.len() > 3 && buf[0] == 0x74 && buf[1] == 0x74 && buf[2] == 0x63 && buf[3] == 0x66
}

0 comments on commit 9d3bd2a

Please sign in to comment.