New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@dldc/fonts

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dldc/fonts

A tool to create dynamic colors by interpolating multiple colors

latest
Source
npmnpm
Version
3.0.8
Version published
Maintainers
1
Created
Source

TS-Fonts Build Status

Utils to uses fonts weights with Typescript

Installation

yarn add ts-fonts

Usage

import { Font } from 'ts-fonts';

const MyFont = Font.create('MyFont', {
  // for each valid weight
  400: {
    // specify paths to normal and italic woff and woff2
    normal: {
      woff: '/path-to-font-normal.woff',
      woff2: '/path-to-font-normal.woff2',
    },
    italic: {
      woff: '/path-to-font-italic.woff',
      woff2: '/path-to-font-italic.woff2',
    },
  },
  600: {
    // You can specify only one of normal and italic
    // If woff and woff2 have the same name you can use a string
    italic: '/path-to-font-semibold-italic',
  },
});

// Inject this in your document to register fonts
MyFont.fontFaces;

// you can now use the font

console.log(MyFont.styles.Regular.Normal);
// { fontFamily: 'MyFont', fontWeight: 400, fontStyle: 'normal' }

console.log(MyFont.styles.Regular.Italic);
// { fontFamily: 'MyFont', fontWeight: 400, fontStyle: 'italic' }

// if the weight has only one style get the object directly
console.log(MyFont.styles.SemiBold);
// { fontFamily: 'MyFont', fontWeight: 600, fontStyle: 'italic' }

Font weight aliases

You can use any of the following name / number to acces a font.

Note: You have to use numbers to define the object passed to Font.create

export type FontWeight_100 = 100 | 'Thin';
export type FontWeight_200 = 200 | 'ExtraLight' | 'UltraLight';
export type FontWeight_300 = 300 | 'Light';
export type FontWeight_400 = 400 | 'Normal' | 'Book' | 'Regular';
export type FontWeight_500 = 500 | 'Medium';
export type FontWeight_600 = 600 | 'SemiBold' | 'DemiBold';
export type FontWeight_700 = 700 | 'Bold';
export type FontWeight_800 = 800 | 'ExtraBold' | 'UltraBold';
export type FontWeight_900 = 900 | 'Black' | 'Heavy';

Font.resolveFontWeight

This function take any valid font weight name / number and return the corresponding font weight number.

FAQs

Package last updated on 01 May 2024

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