Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

4.1 KB
Raw Blame
/**
 * The bundled fonts' credits, for the app's Credits page: each face the package ships, which
 * themes name it by default, where it comes from, and its licence — title and full text. The
 * licences are the texts in `LICENSES/` (the mirror `scripts/sync-font-licenses.mjs` keeps and
 * `font-licenses.test.ts` holds to the packages), imported whole, so the page shows the very
 * text that ships beside the font files. A test holds this list to that directory: every text
 * credited once, every credit naming its licence, the vendored font's title and source equal to
 * `vendored-fonts.json`.
 *
 * MiSans's licence asks the software to credit the font; the sentence that does so is UI copy
 * and lives in the app's dictionaries, on the same page.
 */
import { THEME_IDS } from "../tokens";
import type { ThemeId } from "../tokens";
import { THEME_FONTS } from "../boot";
import type { BundledFontName } from "../boot";
import ibmPlexSans from "./LICENSES/ibm-plex-sans.txt?raw";
import ibmPlexSansCondensed from "./LICENSES/ibm-plex-sans-condensed.txt?raw";
import jetbrainsMono from "./LICENSES/jetbrains-mono.txt?raw";
import misans from "./LICENSES/misans.txt?raw";
import monaSans from "./LICENSES/mona-sans.txt?raw";
import notoSansSc from "./LICENSES/noto-sans-sc.txt?raw";

export interface FontCredit {
  /** The licence file's name in `LICENSES/`, without the extension. */
  readonly id: string;
  /** The family's display name. */
  readonly family: string;
  /** The themes that name the family by default; empty for a face only the pairing offers. */
  readonly themes: readonly ThemeId[];
  /** The npm package the face arrives through, or the vendor's download for a vendored face. */
  readonly source: string;
  /**
   * The type's own project — the licence holder's page, which is what a reader following "来源"
   * wants. `source` says how the file got here; this says whose type it is.
   */
  readonly upstream: string;
  readonly licenseTitle: string;
  readonly licenseText: string;
}

const OFL = "SIL Open Font License 1.1";

/** The vendored face's manifest entry (`vendored-fonts.json`), spelled here so the list is plain data. */
export const MISANS_LICENSE_TITLE = "MiSans Font Intellectual Property License Agreement";
export const MISANS_SOURCE = "https://hyperos.mi.com/font-download/MiSans.zip";

const namedBy = (family: BundledFontName): readonly ThemeId[] =>
  THEME_IDS.filter((id) => Object.values(THEME_FONTS[id]).includes(family));

export const FONT_CREDITS: readonly FontCredit[] = [
  {
    id: "mona-sans",
    family: "Mona Sans",
    themes: namedBy("Mona Sans"),
    source: "@fontsource-variable/mona-sans",
    upstream: "https://github.com/github/mona-sans",
    licenseTitle: OFL,
    licenseText: monaSans,
  },
  {
    id: "jetbrains-mono",
    family: "JetBrains Mono",
    themes: namedBy("JetBrains Mono"),
    source: "@fontsource-variable/jetbrains-mono",
    upstream: "https://github.com/JetBrains/JetBrainsMono",
    licenseTitle: OFL,
    licenseText: jetbrainsMono,
  },
  {
    id: "misans",
    family: "MiSans",
    themes: namedBy("MiSans"),
    source: MISANS_SOURCE,
    upstream: MISANS_SOURCE,
    licenseTitle: MISANS_LICENSE_TITLE,
    licenseText: misans,
  },
  {
    id: "ibm-plex-sans",
    family: "IBM Plex Sans",
    themes: namedBy("IBM Plex Sans"),
    source: "@fontsource-variable/ibm-plex-sans",
    upstream: "https://github.com/IBM/plex",
    licenseTitle: OFL,
    licenseText: ibmPlexSans,
  },
  {
    // Declared in `fonts/geek.css` and named by no theme since Console's uppercase condensed h1
    // went; its files still ship until the dependency is dropped, so it is still credited.
    id: "ibm-plex-sans-condensed",
    family: "IBM Plex Sans Condensed",
    themes: [],
    source: "@fontsource/ibm-plex-sans-condensed",
    upstream: "https://github.com/IBM/plex",
    licenseTitle: OFL,
    licenseText: ibmPlexSansCondensed,
  },
  {
    id: "noto-sans-sc",
    family: "Noto Sans SC",
    themes: namedBy("Noto Sans SC"),
    source: "@fontsource-variable/noto-sans-sc",
    upstream: "https://github.com/notofonts/noto-cjk",
    licenseTitle: OFL,
    licenseText: notoSansSc,
  },
];