-
Notifications
You must be signed in to change notification settings - Fork 33
fix matcher for woff & woff2 #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be the difference between TrueType(0x00010000) and OTF(OTTO, 0x4F54544F) https://github.com/junmer/is-woff/blob/f66b0846497788bbb6d8f78e2d07106919232089/index.js#L9-L27 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spec: https://www.w3.org/TR/WOFF/#WOFFHeader
|
||
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the line break for better diff.