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

I need more information in file README.md #4

Open
bear-wolf opened this issue Mar 17, 2016 · 1 comment
Open

I need more information in file README.md #4

bear-wolf opened this issue Mar 17, 2016 · 1 comment

Comments

@bear-wolf
Copy link

I want convert a few of files to directory path.create.fonts.
What does I need to pass for call function fontmin in parameter?
Can show on this example?
I have this example:

var gulp = require('gulp');
var fontmin = require('gulp-fontmin');

gulp.task('font-min',function(callback){
     return gulp.src(path.source.fonts+'*.ttf')
         .pipe(fontmin({
            text: '天地玄黄 宇宙洪荒',
        }))
        .pipe(gulp.dest(path.create.fonts))
        .pipe(reload({stream: true}));
})

I not understand this "Get needed text from html". How text?
I have file in directory path.source.fonts+'*.ttf'.

@junmer
Copy link
Contributor

junmer commented Mar 23, 2016

hi @bear-wolf
you can ref

https://github.com/ecomfe/gulp-fontmin#get-needed-text-from-html

function minifyFont(text, cb) {
    gulp
        .src('src/font/*.ttf')
        .pipe(fontmin({
            text: text
        }))
        .pipe(gulp.dest('dest/font'))
        .on('end', cb);
}

gulp.task('fonts', function(cb) {

    var buffers = [];

    gulp
        .src('index.html')
        .on('data', function(file) {
            buffers.push(file.contents);
        })
        .on('end', function() {
            var text = Buffer.concat(buffers).toString('utf-8');
            minifyFont(text, cb);
        });

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants