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 dea0a90
Showing 1 changed file with 7 additions and 10 deletions.
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 dea0a90

Please sign in to comment.