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

[WIP] Add custom font data types #37

Merged
merged 5 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion data/custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</mime-type>

<mime-type type="video/webm">
<sub-class-of="application/x-matroska" />
<sub-class-of type="application/x-matroska" />

<magic priority="50">
<match value="0x1a45dfa3" type="string" offset="0">
Expand All @@ -77,4 +77,26 @@
</match>
</magic>
</mime-type>

<mime-type type="font/woff">
<alias type="application/font-woff"/>

<magic priority="50">
<!-- Source: https://www.w3.org/TR/WOFF/#WOFFHeader -->
<match value="0x774F4646" type="string" offset="0" />
</magic>

<glob pattern="*.woff" />
</mime-type>

<mime-type type="font/woff2">
<alias type="application/font-woff2" />

<magic priority="50">
<!-- Source https://www.w3.org/TR/WOFF2/#woff20Header -->
<match value="0x774F4632" type="string" offset="0" />
</magic>

<glob pattern="*.woff2" />
</mime-type>
</mime-info>
1 change: 1 addition & 0 deletions lib/marcel/mime_type/definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
Marcel::MimeType.extend "video/mp4", magic: [[4, "ftypisom"], [4, "ftypM4V "]], extensions: %w( mp4 m4v )

Marcel::MimeType.extend "font/ttf", magic: [[0, "\x00\x01\x00\x00"]], extensions: %w( ttf ttc )
Marcel::MimeType.extend "font/otf", magic: [[0, "OTTO"]], extensions: %w( otf ), parents: "font/ttf"
Marcel::MimeType.extend "application/vnd.adobe.flash.movie", magic: [[0, "FWS"], [0, "CWS"]], extensions: %w( swf )
Marcel::MimeType.extend "application/sql", extensions: %w( sql )
Marcel::MimeType.extend "text/vcard", magic: [[0, "BEGIN:VCARD"]], extensions: %w( vcf ), parents: "text/plain"
6 changes: 6 additions & 0 deletions lib/marcel/tables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,8 @@ module Marcel
'wmv' => 'video/x-ms-wmv',
'wmx' => 'video/x-ms-wmx',
'wmz' => 'application/x-ms-wmz',
'woff' => 'font/woff',
'woff2' => 'font/woff2',
'wp' => 'application/vnd.wordperfect',
'wp5' => 'application/vnd.wordperfect',
'wp6' => 'application/vnd.wordperfect',
Expand Down Expand Up @@ -1908,6 +1910,8 @@ module Marcel
'chemical/x-csml' => [%w(csml), %w(), nil],
'chemical/x-pdb' => [%w(pdb), %w(), 'Brookhaven Protein Databank File'],
'chemical/x-xyz' => [%w(xyz), %w(), nil],
'font/woff' => [%w(woff), %w(), nil],
'font/woff2' => [%w(woff2), %w(), nil],
'image/aces' => [%w(exr), %w(), 'ACES Image Container File'],
'image/avif' => [%w(avif), %w(), 'AV1 Image File'],
'image/bmp' => [%w(bmp dib), %w(), 'Windows bitmap'],
Expand Down Expand Up @@ -2399,6 +2403,8 @@ module Marcel
['audio/x-ms-wma', [[0..8192, 'Windows Media Audio']]],
['audio/x-pn-realaudio', [[0, ".ra\375"]]],
['chemical/x-cdx', [[0, 'VjCD0100']]],
['font/woff', [[0, 'wOFF']]],
['font/woff2', [[0, 'wOF2']]],
['image/aces', [[0, "v/1\001\002\000\000\000"], [0, "v/1\001\002\004\000\000"]]],
['image/cgm', [[0, 'BEGMF']]],
['image/emf', [[0, "\001\000\000\000", [[40, ' EMF']]]]],
Expand Down
Binary file added test/fixtures/magic/font/otf.otf
Binary file not shown.
Binary file added test/fixtures/magic/font/woff.woff
Binary file not shown.
Binary file added test/fixtures/magic/font/woff2.woff2
Binary file not shown.
Binary file added test/fixtures/name/font/otf.otf
Binary file not shown.
Binary file added test/fixtures/name/font/woff.woff
Binary file not shown.
Binary file added test/fixtures/name/font/woff2.woff2
Binary file not shown.