Skip to content
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

fix matcher for woff & woff2 #70

Closed
wants to merge 2 commits into from
Closed

fix matcher for woff & woff2 #70

wants to merge 2 commits into from

Conversation

zimond
Copy link

@zimond zimond commented Jul 13, 2022

This allows more woff/woff2 file to be recognized. fixes #67

&& buf[4] == 0x00
&& buf[5] == 0x01
&& buf[6] == 0x00
&& buf[7] == 0x00
Copy link

@yisibl yisibl Jul 13, 2022

Choose a reason for hiding this comment

The 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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec: https://www.w3.org/TR/WOFF/#WOFFHeader

The flavor field corresponds to the "sfnt version" field found at the beginning of an sfnt file, indicating the type of font data contained. Although only fonts of type 0x00010000 (the version number 1.0 as a 16.16 fixed-point value, indicating TrueType glyph data) and 0x4F54544F (the tag 'OTTO', indicating CFF glyph data) are widely supported at present, it is not an error in the WOFF file if the flavor field contains a different value, indicating a WOFF-packaged version of a different sfnt flavor. (The value 0x74727565 'true' has been used for some TrueType-flavored fonts on Mac OS, for example.) Whether client software will actually support other types of sfnt font data is outside the scope of the WOFF specification, which simply describes how the sfnt is repackaged for Web use.

&& buf[5] == 0x01
&& buf[6] == 0x00
&& buf[7] == 0x00
buf.len() > 3 && buf[0] == 0x77 && buf[1] == 0x4F && buf[2] == 0x46 && buf[3] == 0x46
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Woff2 is not recognized
2 participants