Skip to content

Commit

Permalink
Support new font families for 6.7.x (#40)
Browse files Browse the repository at this point in the history
* support new font families for 6.7.x
update deps, test deps
  • Loading branch information
omacranger authored Dec 31, 2024
1 parent 3c01ccc commit 24dd9cc
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- ${{ github.event_name == 'pull_request' && github.triggering_actor == 'omacranger' }}
is_master_push:
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
version: ["5.15.4", "6.1.1", "6.2.0", "6.4.0"]
version: ["5.15.4", "6.1.1", "6.2.0", "6.4.0", "6.7.2"]
package: ["free", "pro"]
exclude:
- is_master_push: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
if [ "${{ inputs.package }}" != "free" ]; then \
printf "@fortawesome:registry=https://npm.fontawesome.com/\n//npm.fontawesome.com/:_authToken=${{ secrets.FA_NPM_KEY }}" > .npmrc; \
fi
if [ "${{ inputs.version }}" != "6.4.0" ] || [ "${{ inputs.package }}" != "free" ]; then \
if [ "${{ inputs.version }}" != "6.7.2" ] || [ "${{ inputs.package }}" != "free" ]; then \
npm i --no-save @fortawesome/fontawesome-${{ inputs.package }}@${{ inputs.version }}; \
fi
if [ "${{ inputs.package }}" != "free" ]; then \
Expand Down
60 changes: 37 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"dependencies": {
"lodash": ">=4.17.21",
"mkdirp": "^2.1.6",
"mkdirp": "^2.1.6 || ^3.0.1",
"subset-font": "^2.0.0",
"yaml": "^2.2.1"
},
Expand Down Expand Up @@ -57,7 +57,7 @@
}
},
"devDependencies": {
"@fortawesome/fontawesome-free": "^6.4.0",
"@fortawesome/fontawesome-free": "^6.7.2",
"@types/jest": "^29.5.0",
"@types/node": "~18.15.10",
"@types/opentype.js": "^1.3.3",
Expand Down
24 changes: 24 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ export const STYLE_FONT_MAP: Record<Subset, string> = {
"sharp-light": "fa-sharp-light-300",
"sharp-regular": "fa-sharp-regular-400",
"sharp-solid": "fa-sharp-solid-900",
"sharp-thin": "fa-sharp-thin-100",
"duotone-light": "fa-duotone-light-300",
"duotone-regular": "fa-duotone-regular-400",
"duotone-thin": "fa-duotone-thin-100",
"sharp-duotone-light": "fa-sharp-duotone-light-300",
"sharp-duotone-regular": "fa-sharp-duotone-regular-400",
"sharp-duotone-solid": "fa-sharp-duotone-solid-900",
"sharp-duotone-thin": "fa-sharp-duotone-thin-100",
};

export const OUTPUT_FORMAT_MAP: Record<TargetFormat, string> = {
Expand All @@ -23,6 +31,14 @@ export const SUBSET_FAMILY_MAP: Record<Subset, FAFamilyType> = {
"sharp-light": "sharp",
"sharp-regular": "sharp",
"sharp-solid": "sharp",
"sharp-thin": "sharp",
"duotone-regular": "duotone",
"duotone-light": "duotone",
"duotone-thin": "duotone",
"sharp-duotone-solid": "sharp-duotone",
"sharp-duotone-regular": "sharp-duotone",
"sharp-duotone-light": "sharp-duotone",
"sharp-duotone-thin": "sharp-duotone",
brands: "classic",
duotone: "duotone",
light: "classic",
Expand All @@ -35,6 +51,14 @@ export const SUBSET_STYLE_MAP: Record<Subset, FAStyleType> = {
"sharp-light": "light",
"sharp-regular": "regular",
"sharp-solid": "solid",
"sharp-thin": "thin",
"duotone-light": "light",
"duotone-regular": "regular",
"duotone-thin": "thin",
"sharp-duotone-light": "light",
"sharp-duotone-regular": "regular",
"sharp-duotone-solid": "solid",
"sharp-duotone-thin": "thin",
brands: "brands",
duotone: "solid",
light: "light",
Expand Down
12 changes: 10 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ export type Subset =
| "duotone"
| "sharp-solid"
| "sharp-regular"
| "sharp-light";
| "sharp-light"
| "sharp-thin"
| "duotone-light"
| "duotone-regular"
| "duotone-thin"
| "sharp-duotone-light"
| "sharp-duotone-regular"
| "sharp-duotone-solid"
| "sharp-duotone-thin";

export type GlyphName = string;

Expand Down Expand Up @@ -57,7 +65,7 @@ export interface FAIconType {
};
}

export type FAFamilyType = "classic" | "duotone" | "sharp";
export type FAFamilyType = "classic" | "duotone" | "sharp" | "sharp-duotone";
export type FAStyleType = "solid" | "thin" | "light" | "regular" | "brands";

/**
Expand Down
54 changes: 54 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,60 @@ describe("fontawesomeSubset", () => {
}
);

itGTE("6.5.0", "pro")(
"should add requested glyphs for new font styles in sharp-thin",
async () => {
expect.assertions(1);

await testShouldAllAllRequiredGlyphs(
{
"sharp-thin": ["star"],
},
[{ family: "fa-sharp-thin-100", icon: "star" }]
);
}
);

itGTE("6.6.0", "pro")(
"should add requested glyphs for new font styles in sharp-duotone-solid",
async () => {
expect.assertions(1);

await testShouldAllAllRequiredGlyphs(
{
"sharp-duotone-solid": ["star"],
},
[{ family: "fa-sharp-duotone-solid-900", icon: "star" }]
);
}
);

itGTE("6.7.0", "pro")(
"should add requested glyphs for new font styles in duotone-(regular|light|thin) and sharp-duotone-(regular|light|thin)",
async () => {
expect.assertions(6);

await testShouldAllAllRequiredGlyphs(
{
"duotone-regular": ["star"],
"duotone-light": ["star"],
"duotone-thin": ["star"],
"sharp-duotone-regular": ["star"],
"sharp-duotone-light": ["star"],
"sharp-duotone-thin": ["star"],
},
[
{ family: "fa-duotone-regular-400", icon: "star" },
{ family: "fa-duotone-light-300", icon: "star" },
{ family: "fa-duotone-thin-100", icon: "star" },
{ family: "fa-sharp-duotone-regular-400", icon: "star" },
{ family: "fa-sharp-duotone-light-300", icon: "star" },
{ family: "fa-sharp-duotone-thin-100", icon: "star" },
]
);
}
);

const testShouldCreateRequestedFontFiles = async (
subsets: SubsetOption,
expectedFonts: string[]
Expand Down

0 comments on commit 24dd9cc

Please sign in to comment.