( snapshot: GitSnapshot, id: string, source: GoogleFamilyDirectory, root: string, ctx: ReturnType<typeof createFontContext>, tags: readonly string[], languageCatalog: LanguageCatalog, matchLanguages: ReturnType<typeof createLanguageMatcher>, isNew: boolean, )
| 708 | }; |
| 709 | |
| 710 | const writeFamily = async ( |
| 711 | snapshot: GitSnapshot, |
| 712 | id: string, |
| 713 | source: GoogleFamilyDirectory, |
| 714 | root: string, |
| 715 | ctx: ReturnType<typeof createFontContext>, |
| 716 | tags: readonly string[], |
| 717 | languageCatalog: LanguageCatalog, |
| 718 | matchLanguages: ReturnType<typeof createLanguageMatcher>, |
| 719 | isNew: boolean, |
| 720 | ): Promise<void> => { |
| 721 | const { directory, family: google, files } = source; |
| 722 | const license = LICENSES[google.license]; |
| 723 | if (!license) |
| 724 | throw new Error(`${id} has unsupported license ${google.license}`); |
| 725 | const licensePath = license.filenames |
| 726 | .map((filename) => `${directory}/${filename}`) |
| 727 | .find((path) => files.has(path)); |
| 728 | |
| 729 | const { sources, languages: detectedLanguages } = await inspectFamilySources( |
| 730 | snapshot, |
| 731 | id, |
| 732 | source, |
| 733 | ctx, |
| 734 | matchLanguages, |
| 735 | ); |
| 736 | const languages = new Set( |
| 737 | detectedLanguages.filter((language) => languageCatalog[language]), |
| 738 | ); |
| 739 | if (google.primaryLanguage && languageCatalog[google.primaryLanguage]) { |
| 740 | languages.add(google.primaryLanguage); |
| 741 | } |
| 742 | |
| 743 | const copyrights = Array.from( |
| 744 | new Set( |
| 745 | google.fonts |
| 746 | .map((font) => font.copyright?.trim()) |
| 747 | .filter((value): value is string => Boolean(value)), |
| 748 | ), |
| 749 | ).toSorted(compareStrings); |
| 750 | const lastChanged = snapshot.lastChanged(directory); |
| 751 | const family = familySchema.parse({ |
| 752 | family: google.name, |
| 753 | status: 'active', |
| 754 | provenance: { |
| 755 | type: 'github', |
| 756 | repository: 'google/fonts', |
| 757 | revision: lastChanged.revision, |
| 758 | directory, |
| 759 | }, |
| 760 | displayName: |
| 761 | google.displayName === google.name ? undefined : google.displayName, |
| 762 | classifications: normalizeGoogleClassifications(google), |
| 763 | tags, |
| 764 | languages: [...languages].toSorted(compareStrings), |
| 765 | primaryLanguage: languages.has(google.primaryLanguage ?? '') |
| 766 | ? google.primaryLanguage |
| 767 | : undefined, |
no test coverage detected