Skip to content

Commit

Permalink
fix(generate)!: remove auto naming suffixes of variable packages (#950)
Browse files Browse the repository at this point in the history
* fix!: remove auto naming of variable package

* Create spicy-crabs-matter.md

* fix(cli): variable family names should be explicit

* Create nasty-yaks-fry.md
  • Loading branch information
ayuhito committed Apr 8, 2024
1 parent b1ab71c commit 759612d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-yaks-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fontsource-utils/cli": patch
---

fix(cli): use explicit naming for variable font families
5 changes: 5 additions & 0 deletions .changeset/spicy-crabs-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fontsource-utils/generate": major
---

fix(generate)!: remove auto naming suffix of variable packages
4 changes: 2 additions & 2 deletions packages/cli/src/google/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const generateVariableCSS = (

for (const subset of Object.keys(variant[style])) {
const fontObj: FontObject = {
family,
family: `${family} Variable`,
style,
display: 'swap',
weight: findClosest(weights, 400),
Expand Down Expand Up @@ -459,7 +459,7 @@ export const generateIconVariableCSS = (

for (const subset of Object.keys(variant[style])) {
const fontObj: FontObject = {
family,
family: `${family} Variable`,
style,
display: 'swap',
weight: Number(axes.wght.default),
Expand Down
2 changes: 1 addition & 1 deletion packages/generate/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const generateFontFace = (font: FontObject) => {
// If variable, modify output
const { wght, stretch, slnt } = variable ?? {};
let result = '@font-face {';
result += `${spacer}font-family: '${family}${variable ? ' Variable' : ''}';`;
result += `${spacer}font-family: '${family}';`;

// If slnt is present, switch to oblique style
result += `${spacer}font-style: ${
Expand Down
8 changes: 4 additions & 4 deletions packages/generate/tests/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('generate font face', () => {

it('should generate a single font face with variable wght', () => {
const font = {
family: 'Open Sans',
family: 'Open Sans Variable',
style: 'normal',
display: 'swap',
weight: 400,
Expand All @@ -104,7 +104,7 @@ describe('generate font face', () => {

it('should generate a single font face with font stretch', () => {
const font = {
family: 'Open Sans',
family: 'Open Sans Variable',
style: 'normal',
display: 'swap',
weight: 400,
Expand All @@ -128,7 +128,7 @@ describe('generate font face', () => {

it('should generate a single font face with slnt axis', () => {
const font = {
family: 'Open Sans',
family: 'Open Sans Variable',
style: 'normal',
display: 'swap',
weight: 400,
Expand All @@ -152,7 +152,7 @@ describe('generate font face', () => {

it('should generate a single font face with all variable axis', () => {
const font = {
family: 'Open Sans',
family: 'Open Sans Variable',
style: 'normal',
display: 'swap',
weight: 400,
Expand Down

0 comments on commit 759612d

Please sign in to comment.