0.1.24 • Published 2 years ago

material.font.features v0.1.24

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Material Font Features

A React component that displays a ui for choosing the opentype font features of a font. The component then provides a string you can use in CSS rules to display the font with the selected font features. Depends on MUI. If you use a different UI framework, you can build you own using opentype.features.js.

license builds.sr.ht status

Installation

npm install --save material.font.features

This assumes you are using npm as your package manager.

Requires: @mui/material: >= 5 react: >= 17

Usage

// Example

import React from 'react';
import './App.css';
import FontFeatures from 'material.font.features'

function App() {

  const [settings, setSettings] = React.useState('');

  return (    
    <div className="App">
      <h2>font-feature-settings : {settings};</h2>
      <br />
      <FontFeatures fontUrl={'Andika-Regular.ttf'} settings={settings} onSettingsChanged={(newSettings) => setSettings(newSettings)} />        
    </div>
  );
}

export default App;

App.css:

.font-features-container
{
  display: flex;
  flex-direction: column;
}

.font-features-entry
{
  padding-left: 10px;
}

API

FontFeatures

propsdescriptiontypedefault
settingsthe default font feature valuesstring
settingsFormatformat of the settings propsSettingsFormatSettingsFormat.CSS
fontFilefile path to font filestring
fontUrlurl to the font filestring
fontDatafont file binary dataArrayBuffer
fontFeaturespre-extracted font data.Feature[]
showHiddenshow options normally hidden to the userbooleanfalse
onSettingsChangedevent that fires when user changes feature values.Function

Only set one of fontFile, fontUrl, fontData or fontFeatures.

Feature type is defined in opentype.features.js

legacySettingsToCss(settings: string)

Convert SettingsFormat.LEGACY settings to SettingsFormat.CSS

Styling

The container div has class ".font-features-container"

Each option div has class ".font-features-entry"

0.1.24

2 years ago

0.1.23

2 years ago

0.1.22

2 years ago

0.1.21

2 years ago

0.1.20

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago