Discordchatexporter: [HTML] Discord fonts are blocked by CORS policy

Created on 18 Jul 2020  路  5Comments  路  Source: Tyrrrz/DiscordChatExporter

Recently Discord decided to finally enable CORS policy on their CDN which prevents Whitney fonts from loading in HTML exports:

image

There are a couple of ways to deal with this but each comes with certain drawbacks:

  1. Embed fonts directly in the export file. This would mean that the fonts are going to be part of the page, which pushes the minimum size of the export file up to ~500kb since the fonts are quite large.

  2. Embed only one font directly in the export file. Instead of using all fonts, we can only use the most common one (Whitney Regular, which is used for text content) and extrapolate the others with font weight. This pushes the minimum size to ~100kb.

  3. Host the fonts on another CDN that allows any CORS origin. This would fix the problem, but someone will have to care of the hosting and it won't be me.

  4. Leave things as they are. That means the fonts will likely not work on modern browsers, unless you launch them with special settings that ignore CORS for locally stored files or use extensions that help with that on per-page basis. In worst case scenario, Whitney fonts are automatically replaced with Helvetica variants which are similar-ish but will still look different than original Discord fonts.

This thread is open for discussions, votes, and suggestions.

bug wontfix

Most helpful comment

I'm personally completely OK with the Helvetica fallback - it's quite close, and in my opinion doesn't detract from the "integrity" of an export. I wouldn't wish to see the minimum size of a backup become so inflated.

That said, I think the best solution would be to exclude all fonts by default, with an optional flag to embed the full font set.

Thanks again for this software, and for maintaining it!

All 5 comments

For comparison, here's the difference between fonts.

Whitney fonts (which currently cannot be loaded normally):
image

Helvetica fallback:
image

I'm personally completely OK with the Helvetica fallback - it's quite close, and in my opinion doesn't detract from the "integrity" of an export. I wouldn't wish to see the minimum size of a backup become so inflated.

That said, I think the best solution would be to exclude all fonts by default, with an optional flag to embed the full font set.

Thanks again for this software, and for maintaining it!

Helvetica it is then!

Host the fonts on another CDN that allows any CORS origin. This would fix the problem, but someone will have to care of the hosting and it won't be me.

JSDelivr could be used as a cdn for the fonts, just put them in a github repo.
https://cdn.jsdelivr.net/gh/user/repo@version/file

@shirtjs hm, I didn't know it was as simple as that. I'll check that out, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NNNIIndia picture NNNIIndia  路  4Comments

fynnay picture fynnay  路  6Comments

Unknow0059 picture Unknow0059  路  6Comments

Sakani17 picture Sakani17  路  3Comments

billyon picture billyon  路  3Comments