stylus.url() base64 encodes woff2 font

pstenstrm

I use Stylus to write CSS and the stylus.url() method to base64 encode all images. My problem is that stylus will also encode one of the fonts. It's only one woff2 font that's being encoded. All other are left as URLs.

How can I ignore the font file or otherwise prevent it from being base64 encoded when using the stylus.url() method.

font.styl:

@font-face {
    font-family: 'GillSansMTStd';
    src: url('../fonts/2D770A_6_0.eot');
    src: local('☺︎'),
         url('../fonts/2D770A_6_0.woff2') format('woff2'),
         url('../fonts/2D770A_6_0.woff') format('woff'),
         url('../fonts/2D770A_6_0.ttf')  format('truetype');
}

main.css:

@font-face {
    font-family: 'GillSansMTStd';
    src: url("../fonts/2D770A_6_0.eot");
    src: local('☺︎'),
         url("data:application/font-woff2;base64,d09GMgABA[...]") format('woff2'),
         url('../fonts/2D770A_6_0.woff') format('woff'),
         url('../fonts/2D770A_6_0.ttf')  format('truetype');
}
pstenstrm

Reading through the sourcecode for stylus.url() I found the mimes option. Which I haven't found documented anywhere. I can set which mime types I want to base64 encode by setting that option:

stylus(str)
    .set('filename', __dirname + '/css/test.styl')
    .define('url', stylus.url({
        mimes: {
            '.gif': 'image/gif',
            '.png': 'image/png',
            '.jpg': 'image/jpeg',
            '.jpeg': 'image/jpeg',
            '.svg': 'image/svg+xml'
        }
    }))
    .render(function(err, css){

    });

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Bootstrap woff2 font not getting loaded correctly

MimeType missing in Base64 encoded url

base64 url safe removes =

Angular2 Base64 sanitizing unsafe URL value

Passing base64 encoded strings in URL

Convert font in WOFF2 format to something else

Summernote - Image url instead of Base64

How to export font-awesome svg icons as a base64 url?

Stylus inline SVG data uri without base64 encoding

NodeJS Express encodes the URL - how to decode

Javascript Convert an URL to a BASE64 Image

Angular2 display base64 image ERR_INVALID_URL

Quill editor + VueJS2 image upload: Base64 image to URL

View contents of a .woff2 font file

Angular encodes url in ng-src and replaces '/' with %2F and '?' with %3F

FileReader.readAsDataURL() reader result is empty for font files such as .ttf, .woff, and .woff2

displayDialogAsync() encodes provided url

Converting an Image url to base64 in Angular

Synchronous base64 encode from url

To Convert Base64 URL to Base64 Encoded format in WSO2 EI 6.3.0

How do I convert a woff2 font to ttf using fonttools in Python?

Python's `email.message.as_string` encodes some parts as base64; unclear why

Font rendering in Chrome (woff2) - after load font family doesn't want to change

Looping @font-face in Stylus css

Decode base64 URL and embedding in HTML

Hosting Font Awesome Yourself: Do we need all formats eot, svg, ttf, woff, woff2?

"Refused to apply style from because its MIME type "('font/woff2')" is not a supported stylesheet MIME type, and strict MIME checking is enabled"

How to import at .woff2 font and use it in a sass setting?

Powershell Invoke-Webrequest encodes filename of uploaded file to Base64 when it contains german umlaut