# Licenses and source materials / 许可证与源码材料

Formula Studio's original code and documentation are licensed under [MIT](../LICENSE), Copyright (c) 2026 Pierson Bian. The MIT grant does **not** replace the separate licenses of the third-party software, fonts, and TeX resources below. A distribution combining the application with AGPL components must also satisfy the applicable AGPL terms; this is not an MIT-only distribution.

Formula Studio 的原创代码与文档使用 [MIT](../LICENSE) 许可，Copyright (c) 2026 Pierson Bian。MIT 不替换下列第三方软件、字体和 TeX 资源的原有许可。包含 AGPL 组件的组合发行版还需满足适用的 AGPL 条件，并非整个发行版只适用 MIT。

| Component / 组件 | Retained license / 保留的许可 | Materials / 材料 |
| --- | --- | --- |
| SwiftLaTeX v20022022 | AGPL v3; contained third-party terms remain | [AGPL](third-party/swiftlatex/AGPL-3.0.txt), [engine build recipe](../scripts/rebuild-swiftlatex.py) |
| MuPDF.js 1.28.1 | AGPL v3 or later | [AGPL](third-party/mupdf/AGPL-3.0.txt), complete official source archive in the manifest |
| Times New Roman 2.82 | Microsoft original package EULA; proprietary | [Original EULA](Microsoft-EULA.txt); unchanged complete `runtime/fonts/times32.exe` |
| TeX Gyre Termes Math 1.543 | GUST Font License / LPPL | [License and work manifest](third-party/termes/) |
| MathLive 0.111.1 and KaTeX editor fonts | MIT / OFL 1.1 / retained Apache 2.0 components | [Original notices](MathLive-0.111.1-NOTICES.txt) |
| TeX resources, LaTeX2e, fontspec, unicode-math, Latin Modern, Computer Modern | Original per-work terms, including LPPL, GUST, and public-domain notices | [Resource manifest](tex-resources.json), [all original notices](../runtime/licenses/THIRD_PARTY_NOTICES.txt) |
| HarfBuzz / Graphite2 / Xpdf / Emscripten ports | Original per-component terms | [Original notices](third-party/), [retained source archives](source-manifest.json) |
| libarchive.js / libarchive and linked libraries | MIT, BSD, Zlib, OpenSSL/SSLeay and original notices | [Decoder notices](third-party/libarchive/), [upstream build materials](build-materials/libarchive/) |

## Obtain the exact source / 获取对应源码

[Source manifest](source-manifest.json) records fixed URLs, retained local archives, their SHA-256 hashes, the published runtime hashes, and release verification status. `sources/` contains complete preferred-source materials, not only selected headers. The SwiftLaTeX source-only archive excludes four unused historical `.a` libraries; its exact removal list, original archive hash, and preferred-source tree equivalence are recorded in [the derivation report](build-materials/swiftlatex/source-only-derivation.json). Source archives are also served from the online site's `LICENSES/` directory. Its license page offers the exact application source archive, build instructions, and this manifest alongside the runtime.

[源码清单](source-manifest.json)记录固定网址、保留的完整源码包、SHA-256、运行组件哈希以及发布验证状态。`sources/` 保存完整的源码材料，不只有头文件。SwiftLaTeX 的纯源码包去除了四个未采用的历史 `.a` 库；[派生记录](build-materials/swiftlatex/source-only-derivation.json)列出具体移除文件、原包哈希与源码树一致性证明。在线站点的 `LICENSES/` 目录也提供这些源码包；许可页同时提供本次应用源码归档、构建说明和清单。

```sh
python3 scripts/prepare-source-bundle.py
node scripts/verify-license-materials.mjs
```

`prepare-source-bundle.py --download-missing` can restore missing archives from their fixed URLs, but always verifies their pinned size and hash. For the SwiftLaTeX source-only archive it verifies the original upstream archive, removes only the four recorded static libraries, and verifies the derived archive hash before saving. Do not accept a changed archive under the same filename without a separate review. A complete application archive is generated by the normal site build, excluding upstream archives offered separately and excluding private inputs, research data, caches, and Git credentials.

`prepare-source-bundle.py --download-missing` 可以从固定网址恢复缺少的归档，始终验证尺寸及哈希；SwiftLaTeX 纯源码包会先验证上游原包，仅移除已记录的四个静态库，再验证派生包哈希。不应未经核查就接受同名但字节改变的归档。普通站点构建会生成完整应用源码包，另行提供的上游包不重复包含，私人输入、研究资料、缓存和 Git 凭据也不包含。

## Fonts / 字体

The complete, unchanged Microsoft `times32.exe` package is provided without charge, with the original name, bytes, notices, and EULA. The browser reads it as archive data and extracts its original font bytes into memory; it does not execute the installer, install fonts, publish extracted font URLs, or convert the font files. The historical terms do not expressly discuss WebAssembly; this browser use is an interpretation of the package's usage grant, not a new grant by Microsoft. Redistribution and commercial reuse remain governed by that EULA; the MIT license does not authorize commercial redistribution of the font package.

完整、未修改的微软 `times32.exe` 包免费提供，原名、字节、声明和 EULA 均保留。浏览器只读取归档数据，将原字体字节解包到内存；不运行安装器、不安装字体、不提供拆出字体的网址、不转换字体。历史条款未专门讨论 WebAssembly；此浏览器用法是对原包使用权的解释，并非微软新增授权。再分发及商业使用仍由 EULA 约束；MIT 不授予字体包的商业再分发权。

## Build the engines / 构建排版引擎

Activate the unmodified Emscripten **3.1.4** SDK, CMake **3.x**, make, and Python 3, then run:

启用原版 Emscripten **3.1.4** SDK、CMake **3.x**、make 和 Python 3 后执行：

```sh
python3 scripts/rebuild-swiftlatex.py --output-dir /tmp/formula-studio-engine-build --jobs 2
```

The recipe rebuilds HarfBuzz 3.2.0, Graphite2 1.3.14, and Xpdf 4.02 from their retained preferred source before building XeTeX and Dvipdfmx. It saves candidate engines and the build report; it never silently replaces the runtime. The release gate requires retained evidence that the selected engine build passes the formula-output baseline. Byte-for-byte identity with the historical upstream binary is not a requirement or claim.

该脚本先从保留的源码重新构建 HarfBuzz 3.2.0、Graphite2 1.3.14 和 Xpdf 4.02，再构建 XeTeX 与 Dvipdfmx。它保存候选引擎和构建记录，不会静默替换运行组件。发布检查要求所选引擎构建通过公式输出基线，并保留验证证据；不要求或声称与历史上游二进制逐字节相同。
