diff --git a/src/map.rs b/src/map.rs index f1a2f42..b07cd8a 100644 --- a/src/map.rs +++ b/src/map.rs @@ -338,6 +338,12 @@ matcher_map!( "otf", matchers::font::is_otf ), + ( + MatcherType::Font, + "application/font-collection", + "ttc", + matchers::font::is_ttc + ), // Document ( MatcherType::Doc, diff --git a/src/matchers/font.rs b/src/matchers/font.rs index aca5e1c..70e84e5 100644 --- a/src/matchers/font.rs +++ b/src/matchers/font.rs @@ -1,27 +1,11 @@ /// Returns whether a buffer is WOFF font data. pub fn is_woff(buf: &[u8]) -> bool { - buf.len() > 7 - && buf[0] == 0x77 - && buf[1] == 0x4F - && buf[2] == 0x46 - && buf[3] == 0x46 - && buf[4] == 0x00 - && buf[5] == 0x01 - && buf[6] == 0x00 - && buf[7] == 0x00 + 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() > 7 - && buf[0] == 0x77 - && buf[1] == 0x4F - && buf[2] == 0x46 - && buf[3] == 0x32 - && buf[4] == 0x00 - && buf[5] == 0x01 - && buf[6] == 0x00 - && buf[7] == 0x00 + buf.len() > 3 && buf[0] == 0x77 && buf[1] == 0x4F && buf[2] == 0x46 && buf[3] == 0x32 } /// Returns whether a buffer is TTF font data. @@ -43,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 +}