Created
March 22, 2025 11:57
-
-
Save RichardKanshen/aee354019aa5b2316164aff8c253106d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fontBuffer is the Buffer of the font converted from base64 | |
if (mimeType === 'font/woff2') { | |
// Check for the trailing 8-byte sequence | |
// because for SOME REASON Bun.build appends 7E 8A E6 6A DC 28 7D FD | |
// at the end of SOME WOFF2 fonts and it BREAKS EVERYTHING | |
const trailingBytes = Buffer.from([0x7E, 0x8A, 0xE6, 0x6A, 0xDC, 0x28, 0x7D, 0xFD]); | |
if (fontBufferSanitized.length >= 8) { | |
const last8Bytes = fontBuffer.subarray(fontBufferSanitized.length - 8); | |
if (last8Bytes.equals(trailingBytes)) { | |
fontBufferSanitized = fontBuffer.subarray(0, fontBufferSanitized.length - 8); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment