Skip to content

gh-84852: Add MIME types for .eot, ,otf, .ttf, .woff and .woff2 fonts #20199

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

Merged
merged 10 commits into from
Nov 12, 2024

Conversation

sahil290791
Copy link
Contributor

@sahil290791 sahil290791 commented May 19, 2020

Add missing font mime types

Fixes #84852.

Currently the guess_type method doesnt work for fonts of type: .eot, .woff, .woff2, .otf and .ttf
I have added the neccessary mimetypes for these fonts

Reference: https://codingstill.com/2013/01/set-mime-types-for-web-fonts-in-iis/

[bpo-40675](https://bugs.python.org/issue40675): Summary of the changes made

@the-knights-who-say-ni

This comment was marked as resolved.

@sahil290791 sahil290791 changed the title Add fonts .woff, .woff2, .eot and .ttf to mimetypes bpo-40675: Add fonts .woff, .woff2, .eot and .ttf to mimetypes May 19, 2020
tiran
tiran previously requested changes May 19, 2020
@bedevere-bot

This comment was marked as resolved.

@sahil290791 sahil290791 changed the title bpo-40675: Add fonts .woff, .woff2, .eot and .ttf to mimetypes bpo-40675: Add fonts .woff, .woff2, .eot, .otf and .ttf to mimetypes May 19, 2020
@sahil290791 sahil290791 requested review from tiran and removed request for a team May 19, 2020 16:04
@csabella

This comment was marked as resolved.

@sahil290791

This comment was marked as resolved.

@sahil290791

This comment was marked as resolved.

@sahil290791

This comment was marked as resolved.

@bedevere-bot

This comment was marked as resolved.

@sahil290791
Copy link
Contributor Author

@tiran @csabella Please let me know if anything else is pending from my side?

It would be great if this can be merged as currently I am working by adding certain if conditions in my current project.

@tiran tiran removed their request for review April 18, 2021 07:18
@azimovMichael
Copy link

Hi, @tiran @csabella any estimation on if and when this will be merged?
Also, @sahil290791, you don't need if conditions, you can add these types dynamically with:
mimetypes.add_type('application/font-woff2', '.woff2')

@sahil290791
Copy link
Contributor Author

Thanks @azimovMichael for the suggestion, will use dynamic approach currently.

@minchinweb
Copy link

In 2017, the IANA approved a "fonts" top level media type, and so the official MIME types are now:

Name Template Reference
collection font/collection RFC8081
otf font/otf [RFC8081]
sfnt font/sfnt [RFC8081]
ttf font/ttf [RFC8081]
woff font/woff [RFC8081]
woff2 font/woff2 [RFC8081]

source

@hugovk hugovk changed the title bpo-40675: Add fonts .woff, .woff2, .eot, .otf and .ttf to mimetypes gh-84852: Add fonts .woff, .woff2, .eot, .otf and .ttf to mimetypes Nov 4, 2024
@hugovk hugovk dismissed tiran’s stale review November 4, 2024 15:26

the changes were made and tiran removed their request for review

@hugovk hugovk added the type-feature A feature request or enhancement label Nov 4, 2024
@hugovk hugovk changed the title gh-84852: Add fonts .woff, .woff2, .eot, .otf and .ttf to mimetypes gh-84852: Add MIME types for .eot, ,otf, .ttf, .woff and .woff2 fonts Nov 4, 2024
@hugovk
Copy link
Member

hugovk commented Nov 4, 2024

I've updated this to fix the merge conflict, use the RFC 8081 MIME types, corrected the Embedded OpenType (EOT) MIME type (append object: application/vnd.ms-fontobject), and added a What's New entry.

@@ -227,11 +227,16 @@ def check_extensions():
self.assertEqual(mimetypes.guess_extension('application/postscript'), '.ps')
self.assertEqual(mimetypes.guess_extension('application/vnd.apple.mpegurl'), '.m3u')
self.assertEqual(mimetypes.guess_extension('application/vnd.ms-excel'), '.xls')
self.assertEqual(mimetypes.guess_extension('application/vnd.ms-fontobject'), '.eot')
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is going to conflict with the refactoring in #126412.

Comment on lines +546 to +549
'.otf' : 'font/otf',
'.ttf' : 'font/ttf',
'.woff' : 'font/woff',
'.woff2' : 'font/woff2',
Copy link
Member

Choose a reason for hiding this comment

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

I verified from the RFC that these 4 lines and hence the corresponding test lines are correct. There is no reference I see for the vnd-ms addition so cannot verify. The merge conflict will be in the tests due to the switch to using subtests, which looks good to me. So merge that first and fix this.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for verifying.

application/vnd.ms-fontobject is vendor specific and can be seen for example at:

@hugovk hugovk merged commit 599bfc9 into python:main Nov 12, 2024
36 checks passed
@hugovk
Copy link
Member

hugovk commented Nov 12, 2024

Thank you @sahil290791 for the initial PR and everyone else for the reviews!

@sahil290791
Copy link
Contributor Author

Thanks @hugovk and the reviewers for getting this reviewed and merged. 😃

picnixz pushed a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
… fonts (python#20199)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
… fonts (python#20199)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing mimetypes for fonts