跳到主要內容

Font opitimize with grunt

In the past, if a different font was desired, I had to create images for the text instead.But image scale up badly and loaded slowly. I think web fonts is a better solution. Google Web Fonts(GWF) allow to host on their service for request fonts without limit. So It's easier to use different fonts in the web page. Most of all, I only use few characters but include one hole font family. Grunt-font-optimizer is the system which could help us to repack font with characters what we need.

How to install Grunt-font-optimizer

  • Install nodeJS
  • Install grunt cli
  • Install grunt-font-optimizer : npm install grunt-font-optimizer --save-dev

Load grunt-font-optimizer in gruntfile.js

grunt.loadNpmTasks('grunt-font-optimizer');

Download google web fonts form skyfonts

Skyfonts is the system which could download and sync google fonts easily.

Example to imprement

grunt.initConfig({
        font_optimizer: {
            default: {
                options: {
                    // Characters to include
                    chars: 'ABC',
                    // Features to include.
                    includeFeatures: ['none']
                },  
                files: {
                    'dist/fonts/logo.ttf': ['assets/fonts/railway_regular.ttf'],
                }   
            }   
        }
}) 
➽ See more

留言

這個網誌中的熱門文章

Indexed Database API - Initail

As a front web developer, I could create UI faster or Optimize file to load page faster. But it hard to faster response time form server however 80-90% of the end-user response time is spent on the frontend. Nowadays we could use the Indexed Database API, or IndexedDB to reduce the request times. Less request times, less response time. What is IndexedDB ? IndexedDB is web browser standard interface for a local database of records holding simple values and hierarchical objects. IndexedDB was initially proposed by Oracle in 2009./* wiki */ What browsers would support IndexedDB ? Most browsers of hybrid devices support it exclude IE9-, Safari 7-,iOS Safari 7.1-, Opera Mini, Android Browser 4.3-./* caniuse.com */ When shall we use IndexedDB ? Save Money on web hosting Data index sort Data keyword search Keep data for period of time How to start it? //*************************************************************** //initDB //{Object}, {data: dbName, objectStore: storeName, ...

最近設計的一組icon..太有APPLE風格被打槍了

jQuery 的slideToggle太好用了

$ ( ".collapse" ) .each ( function ( index, value ) { $ ( this ) . click ( function ( evt ) { evt.preventDefault ( ) ; //prevent the default click event of the anchor tag. var target = $ ( this ) .attr ( "data-toggle" ) ; $ ( "." + target ) .slideToggle ( ) ; } ) ; } ) ; http://code-tricks.com/create-a-common-toggler-for-div-using-jquery/