Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ttf-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ttf-loader

The simplest font loading using webpack available

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.9K
increased by39.2%
Maintainers
1
Weekly downloads
 
Created
Source

ttf-loader

npm versionBuild Status

Import and use fonts easily in your javascript web app

Usage

  • Install
    # file-loader is peerDependency
    npm install --save-dev ttf-loader file-loader
    # or yarn
    yarn add -D ttf-loader file-loader
    
  • Add loader to your webpack-config
    ...
     module: {
        rules: [
          {
              test: /\.ttf$/,
              use: [
                {
                  loader: 'ttf-loader',
                  options: {
                    name: './font/[hash].[ext]',
                  },
                },
              ]
          }
        ]
     }
    
  • Import ttfs and use them in your code!
    • Inline
    import React, { Component } from 'react';
    import someFontFamily from 'some.ttf';
    
    export default class App extends Component {
      render() {
        return (
          <div style={{ fontFamily: someFontFamily }}>
            <span>
              Welcome to my React app!
            </span>
          </div>
        );
      }
    }
    
    • jss
    import React, { Component } from 'react';
    import jss from 'jss';
    import someFontFamily from 'some.ttf';
    
    const spanClass = jss.createStyleSheet({
      span: {
        'font-family': someFontFamily,
      },
    }).attach().classes.span;
    
    export default class App extends Component {
      render() {
        return (
          <div className={spanClass}>
            <span>
              Welcome to my React app!
            </span>
          </div>
        );
      }
    }
    

Keywords

FAQs

Package last updated on 24 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc