Skip to content

Commit 5c44516

Browse files
committed
Updated README.md
1 parent 8f11e3e commit 5c44516

File tree

7 files changed

+166
-49340
lines changed

7 files changed

+166
-49340
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### Version 1.0.0
2+
3+
Currently supports fot feature settings and dynamic line height with the different font sizes.
4+
5+
- Inter font updated to v3.10 (1.000)
6+
- Updated README.md

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The MIT License (MIT)
22
=====================
33

4-
Copyright © `2018` `Imam Susanto`
4+
Copyright © `2019` `Yuri Sementsov`
55

66
Permission is hereby granted, free of charge, to any person
77
obtaining a copy of this software and associated documentation

README.md

+154-50
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,51 @@ The plugin is inspired with [tailwind-plugin-inter-font](https://github.com/subu
1212

1313
## Installation
1414

15-
# with npm
16-
npm install --save-dev tailwindcss-font-inter
15+
```sh
16+
# with npm
17+
npm install --save-dev tailwindcss-font-inter
1718

18-
# or with yarn
19-
yarn add --dev tailwindcss-font-inter
19+
# or with yarn
20+
yarn add --dev tailwindcss-font-inter
21+
```
2022

2123
## Usage
2224

2325
Add plugin to your `tailwind.config.js`:
2426

25-
// tailwind.config.js
26-
module.exports = {
27-
theme: {
28-
extend: {}
29-
},
30-
variants: {},
31-
plugins: [
32-
require('tailwindcss-font-inter')()
33-
]
34-
};
27+
```js
28+
// tailwind.config.js
29+
module.exports = {
30+
theme: {
31+
extend: {}
32+
},
33+
variants: {},
34+
plugins: [
35+
require('tailwindcss-font-inter')()
36+
]
37+
};
38+
```
3539

3640
You can set additional options for plugin:
3741

38-
// tailwind.config.js
39-
module.exports = {
40-
...
41-
42-
plugins: [
43-
require('tailwindcss-font-inter')({
44-
a: -0.0223,
45-
b: 0.185,
46-
c: -0.1745,
47-
baseFontSize: 16,
48-
baseLineHeight: 1.5,
49-
importFontFace: false,
50-
disableUnusedFeatures: false
51-
})
52-
]
53-
};
42+
```js
43+
// tailwind.config.js
44+
module.exports = {
45+
...
46+
47+
plugins: [
48+
require('tailwindcss-font-inter')({ // it's plugin's default settings
49+
a: -0.0223,
50+
b: 0.185,
51+
c: -0.1745,
52+
baseFontSize: 16,
53+
baseLineHeight: 1.5,
54+
importFontFace: false,
55+
disableUnusedFeatures: false
56+
})
57+
]
58+
};
59+
```
5460

5561
### Plugin Options
5662

@@ -64,121 +70,167 @@ The plugin has several adjustable options.
6470

6571
### Theme Configuration
6672

67-
By default
73+
The plugin uses [`fontSize` and `lineHeight` core plugins](https://tailwindcss.com/docs/configuration#core-plugins) to generate proper font sizes for Inter Typeface. Additionally it uses `interFontFeatures` to config font feature settings.
74+
75+
```js
76+
// tailwind.config.js
77+
module.exports = {
78+
theme: {
79+
interFontFeatures: {
80+
default: ['calt', 'liga', 'kern'],
81+
numeric: ['tnum', 'salt', 'ss02']
82+
},
83+
extend: {
84+
fontSize: {
85+
'xs': '11px',
86+
's': '13px',
87+
'm': '17px',
88+
'l': '28px',
89+
'xl': '36px',
90+
'2xl': '48px',
91+
'3xl': '64px',
92+
base: '16px',
93+
},
94+
lineHeight: {
95+
'lg': '1.6',
96+
'md': '1.33',
97+
'sm': '1.25',
98+
'xs': '1',
99+
},
100+
}
101+
},
102+
plugins: [
103+
require('tailwindcss-font-inter')()
104+
]
105+
}
106+
```
68107

69108
## Output
70109

71110
This package will generate CSS on components section and utilities section.
72111

73-
### On `components` Section
112+
### Font Family
74113

75-
This will add some `@font-face` declaration and adding `.font-inter` class.
114+
The plugin will add some `@font-face` declaration in base (if `importFontFace` option is set to `true`) and add `.font-inter` utility class.
76115

77116
```css
78-
/* Will be generated on @tailwind components; */
117+
/* Just a copy of https://rsms.me/inter/inter.css */
79118

80119
@font-face {
81120
  font-family: Inter UI;
82121
  font-style: normal;
83122
  font-weight: 400;
84123
  font-display: swap;
85-
  src: url("https://rsms.me/inter/font-files/Inter-UI-Regular.woff?v=3.1") format("woff");
124+
  src: url("https://rsms.me/inter/font-files/Inter-UI-Regular.woff2?v=3.1") format("woff2"),
125+
   url("https://rsms.me/inter/font-files/Inter-UI-Regular.woff?v=3.1") format("woff");
86126
}
87127

88128
@font-face {
89129
  font-family: Inter UI;
90130
  font-style: italic;
91131
  font-weight: 400;
92132
  font-display: swap;
93-
  src: url("https://rsms.me/inter/font-files/Inter-UI-Italic.woff?v=3.1") format("woff");
133+
  src: url("https://rsms.me/inter/font-files/Inter-UI-Italic.woff2?v=3.1") format("woff2"),
134+
url("https://rsms.me/inter/font-files/Inter-UI-Italic.woff?v=3.1") format("woff");
94135
}
95136

96137
@font-face {
97138
  font-family: Inter UI;
98139
  font-style: normal;
99140
  font-weight: 500;
100141
  font-display: swap;
101-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-Medium.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-Medium.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-Medium.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-Medium.woff?v=3.1")) format("woff");
142+
  src: url("https://rsms.me/inter/font-files/Inter-UI-Medium.woff2?v=3.1") format("woff2"),
143+
url("https://rsms.me/inter/font-files/Inter-UI-Medium.woff?v=3.1") format("woff");
102144
}
103145

104146
@font-face {
105147
  font-family: Inter UI;
106148
  font-style: italic;
107149
  font-weight: 500;
108150
  font-display: swap;
109-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-MediumItalic.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-MediumItalic.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-MediumItalic.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-MediumItalic.woff?v=3.1")) format("woff");
151+
  src: url("https://rsms.me/inter/font-files/Inter-UI-MediumItalic.woff2?v=3.1") format("woff2"),
152+
url("https://rsms.me/inter/font-files/Inter-UI-MediumItalic.woff?v=3.1") format("woff");
110153
}
111154

112155
@font-face {
113156
  font-family: Inter UI;
114157
  font-style: normal;
115158
  font-weight: 600;
116159
  font-display: swap;
117-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-SemiBold.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-SemiBold.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-SemiBold.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-SemiBold.woff?v=3.1")) format("woff");
160+
  src: url("https://rsms.me/inter/font-files/Inter-UI-SemiBold.woff2?v=3.1") format("woff2"),
161+
url("https://rsms.me/inter/font-files/Inter-UI-SemiBold.woff?v=3.1") format("woff");
118162
}
119163

120164
@font-face {
121165
  font-family: Inter UI;
122166
  font-style: italic;
123167
  font-weight: 600;
124168
  font-display: swap;
125-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-SemiBoldItalic.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-SemiBoldItalic.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-SemiBoldItalic.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-SemiBoldItalic.woff?v=3.1")) format("woff");
169+
  src: url("https://rsms.me/inter/font-files/Inter-UI-SemiBoldItalic.woff2?v=3.1") format("woff2"),
170+
url("https://rsms.me/inter/font-files/Inter-UI-SemiBoldItalic.woff?v=3.1") format("woff");
126171
}
127172

128173
@font-face {
129174
  font-family: Inter UI;
130175
  font-style: normal;
131176
  font-weight: 700;
132177
  font-display: swap;
133-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-Bold.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-Bold.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-Bold.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-Bold.woff?v=3.1")) format("woff");
178+
  src: url("https://rsms.me/inter/font-files/Inter-UI-Bold.woff2?v=3.1") format("woff2"),
179+
url("https://rsms.me/inter/font-files/Inter-UI-Bold.woff?v=3.1") format("woff");
134180
}
135181

136182
@font-face {
137183
  font-family: Inter UI;
138184
  font-style: italic;
139185
  font-weight: 700;
140186
  font-display: swap;
141-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-BoldItalic.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-BoldItalic.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-BoldItalic.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-BoldItalic.woff?v=3.1")) format("woff");
187+
  src: url("https://rsms.me/inter/font-files/Inter-UI-BoldItalic.woff2?v=3.1") format("woff2"),
188+
url("https://rsms.me/inter/font-files/Inter-UI-BoldItalic.woff?v=3.1") format("woff");
142189
}
143190

144191
@font-face {
145192
  font-family: Inter UI;
146193
  font-style: normal;
147194
  font-weight: 800;
148195
  font-display: swap;
149-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-ExtraBold.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-ExtraBold.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-ExtraBold.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-ExtraBold.woff?v=3.1")) format("woff");
196+
  src: url("https://rsms.me/inter/font-files/Inter-UI-ExtraBold.woff2?v=3.1") format("woff2"),
197+
url("https://rsms.me/inter/font-files/Inter-UI-ExtraBold.woff?v=3.1") format("woff");
150198
}
151199

152200
@font-face {
153201
  font-family: Inter UI;
154202
  font-style: italic;
155203
  font-weight: 800;
156204
  font-display: swap;
157-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-ExtraBoldItalic.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-ExtraBoldItalic.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-ExtraBoldItalic.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-ExtraBoldItalic.woff?v=3.1")) format("woff");
205+
  src: url("https://rsms.me/inter/font-files/Inter-UI-ExtraBoldItalic.woff2?v=3.1") format("woff2"),
206+
url("https://rsms.me/inter/font-files/Inter-UI-ExtraBoldItalic.woff?v=3.1") format("woff");
158207
}
159208

160209
@font-face {
161210
  font-family: Inter UI;
162211
  font-style: normal;
163212
  font-weight: 900;
164213
  font-display: swap;
165-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-Black.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-Black.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-Black.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-Black.woff?v=3.1")) format("woff");
214+
  src: url("https://rsms.me/inter/font-files/Inter-UI-Black.woff2?v=3.1") format("woff2"),
215+
url("https://rsms.me/inter/font-files/Inter-UI-Black.woff?v=3.1") format("woff");
166216
}
167217

168218
@font-face {
169219
  font-family: Inter UI;
170220
  font-style: italic;
171221
  font-weight: 900;
172222
  font-display: swap;
173-
  src: url("[https://rsms.me/inter/font-files/Inter-UI-BlackItalic.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-BlackItalic.woff2?v=3.1")) format("woff2"), url("[https://rsms.me/inter/font-files/Inter-UI-BlackItalic.woff?v=3.1"](https://rsms.me/inter/font-files/Inter-UI-BlackItalic.woff?v=3.1")) format("woff");
223+
  src: url("https://rsms.me/inter/font-files/Inter-UI-BlackItalic.woff2?v=3.1") format("woff2"),
224+
url("https://rsms.me/inter/font-files/Inter-UI-BlackItalic.woff?v=3.1") format("woff");
174225
}
175226

176227
@font-face {
177228
  font-family: Inter UI var;
178229
  font-style: oblique 0deg 10deg;
179230
  font-weight: 400 900;
180231
  font-display: swap;
181-
  src: url("[https://rsms.me/inter/font-files/Inter-UI.var.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI.var.woff2?v=3.1")) format("woff2-variations"), url("[https://rsms.me/inter/font-files/Inter-UI.var.woff2?v=3.1"](https://rsms.me/inter/font-files/Inter-UI.var.woff2?v=3.1")) format("woff2");
232+
  src: url("https://rsms.me/inter/font-files/Inter-UI.var.woff2?v=3.1") format("woff2-variations"),
233+
url("https://rsms.me/inter/font-files/Inter-UI.var.woff2?v=3.1") format("woff2");
182234
}
183235

184236
.font-inter {
@@ -188,13 +240,13 @@ This will add some `@font-face` declaration and adding `.font-inter` class.
188240
@supports(font-variation-settings:normal) {
189241
  .font-inter {
190242
    font-family: "Inter UI var", sans-serif;
191-
  }
243+
}
192244
}
193245
```
194246

195-
## On `utilities` section
247+
## Font Sizes
196248

197-
Replace standard `text-lg` into `text-inter-lg` to get **Dynamic Metrics** applied to your `text` class.
249+
Alongside with the default `text-lg` classes, the plugin will generate `text-inter-lg` to set also line height and letter spacing according to Inter's **Dynamic Metrics**.
198250

199251
```css
200252
/* Will be generated on @tailwind utilities; */
@@ -253,7 +305,59 @@ Replace standard `text-lg` into `text-inter-lg` to get **Dynamic Metrics** appli
253305
  line-height: 4.2rem;
254306
}
255307
```
308+
### Font features
309+
310+
Also the plugin generates utility classes which allow you to specify named font feature settings.
311+
312+
```js
313+
// tailwind.config.js
314+
module.exports = {
315+
theme: {
316+
interFontFeatures: {
317+
default: ['calt', 'liga', 'kern'],
318+
numeric: ['tnum', 'salt', 'ss02']
319+
},
320+
},
321+
plugins: [
322+
require('tailwindcss-font-inter')()
323+
]
324+
}
325+
```
326+
327+
This will generate the following classes:
328+
329+
```css
330+
/* This is a default class */
331+
.font-feature-normal: {
332+
font-feature-settings: normal
333+
}
334+
335+
.font-feature-default: {
336+
font-feature-settings: "calt", "liga", "kern";
337+
}
256338

339+
.font-feature-numeric: {
340+
font-feature-settings: "tnum", "salt", "ss02";
341+
}
257342
```
258343

344+
The plugin will filter unsupported feature and won't include it to the output. Also to avoid some unexpected inheritance, you can set plugin's option `disableUnusedFeatures` to `true`, then generated classes will disable all supported featurs and enable only those you've specified.
345+
346+
```css
347+
/* This is a default class */
348+
.font-feature-normal: {
349+
font-feature-settings: normal
350+
}
351+
352+
.font-feature-default: {
353+
font-feature-settings: "aalt" 0, "calt", "case" 0, "ccmp" 0, "cpsp" 0, "cv01" 0, "cv02" 0, "cv03" 0, "cv04" 0, "cv05" 0, "cv06" 0, "cv07" 0, "cv08" 0, "cv09" 0, "cv10" 0, "cv11" 0, "dlig" 0, "dnom" 0, "frac" 0, "kern", "liga", "numr" 0, "ordn" 0, "pnum" 0, "rlig" 0, "salt" 0, "ss01" 0, "ss02" 0, "ss03" 0, "subs" 0, "sups" 0, "tnum" 0, "zero" 0;
354+
}
355+
356+
.font-feature-numeric: {
357+
font-feature-settings: "aalt" 0, "calt" 0, "case" 0, "ccmp" 0, "cpsp" 0, "cv01" 0, "cv02" 0, "cv03" 0, "cv04" 0, "cv05" 0, "cv06" 0, "cv07" 0, "cv08" 0, "cv09" 0, "cv10" 0, "cv11" 0, "dlig" 0, "dnom" 0, "frac" 0, "kern" 0, "liga" 0, "numr" 0, "ordn" 0, "pnum" 0, "rlig" 0, "salt", "ss01" 0, "ss02", "ss03" 0, "subs" 0, "sups" 0, "tnum", "zero" 0;
358+
}
259359
```
360+
361+
# License
362+
363+
[MIT](LICENSE.md)

demo/index.html

-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<body class="min-h-screen flex flex-col items-center justify-center bg-white text-black antialiased font-inter font-feature-default">
1111
<div class="text-inter-5xl font-bold">This page is for testing your sample css</div>
1212
<textarea class="w-4/5 h-screen m-16 appearance-none text-inter-xl font-feature-numeric">
13-
LV87 PARX 0006 5587 9000 3
14-
LV09 RIKO 0001 3009 6016 0
15-
301082-13102
16-
+371 29 707 175
17-
+7 (913) 123-24-24
1813
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1914
abcdefghijklmnopqrstuvwxyz
2015
0123456789!?.

0 commit comments

Comments
 (0)