diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index 945d45a7ac..041a98a244 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -141,17 +141,18 @@ generated at build time and shipped beside this file. so nothing of PipeWire's ships inside our installers beyond the compiled result of its headers (inline functions and struct layouts). -## Fonts — Inter, Lora, Oswald, Caveat, IBM Plex Mono +## Fonts — Inter, Lora, Oswald, Caveat, IBM Plex Mono, Vazirmatn - **Components**: the Regular and Bold `.ttf` of each family, under - `resources/fonts/`. + `resources/fonts/`. The renderer also ships a variable Vazirmatn WOFF2 + face for the Persian and Arabic interfaces. - **Used by**: the native compositor, which draws captions and annotations with these files and nothing else (it registers them privately at start and never reads the fonts installed on the machine), and the editor's font picker. - **License**: **SIL Open Font License 1.1** — . Each family's copyright notice and licence text ship beside its files as `-OFL.txt`, as the licence requires. -- **Unmodified**: every file is redistributed exactly as upstream publishes it, +- **Unmodified**: the font files are redistributed exactly as upstream publishes them, which is also why the Reserved Font Names "Lora" and "Plex" are kept. - **Upstream**: - Inter — Copyright 2016 The Inter Project Authors. `extras/ttf/` of the v4.1 @@ -164,6 +165,9 @@ generated at build time and shipped beside this file. at `59745e818e`. - IBM Plex Mono 2.3 — Copyright © 2017 IBM Corp. `ofl/ibmplexmono/` of at `23e54b51dd`. + - Vazirmatn 33.003 — Copyright 2015 The Vazirmatn Project Authors. + `fonts/ttf/` and `fonts/webfonts/` of + . ## Recordly — helper code diff --git a/crates/compositor/src/text_fonts.rs b/crates/compositor/src/text_fonts.rs index c09a8c15e0..6ea5873399 100644 --- a/crates/compositor/src/text_fonts.rs +++ b/crates/compositor/src/text_fonts.rs @@ -54,8 +54,8 @@ pub(crate) fn repo_fonts_dir() -> PathBuf { /// Les familles embarquées, telles que l'app les stocke. Miroir de `TEXT_FONT_FAMILIES` /// (`src/lib/textFonts.ts`), dont le test vérifie que chaque fichier porte bien ce nom. #[cfg(test)] -pub(crate) const SHIPPED_FAMILIES: [&str; 5] = - ["Inter", "Lora", "Oswald", "Caveat", "IBM Plex Mono"]; +pub(crate) const SHIPPED_FAMILIES: [&str; 6] = + ["Inter", "Lora", "Oswald", "Caveat", "IBM Plex Mono", "Vazirmatn"]; /// Chaque famille se voit : deux familles se confondent quand elles dessinent le même bloc, /// même largeur ET même hauteur à 2 % près, et un repli commun les confondrait toutes. La diff --git a/public/fonts/Vazirmatn-Bold.ttf b/public/fonts/Vazirmatn-Bold.ttf new file mode 100644 index 0000000000..efa9b095da Binary files /dev/null and b/public/fonts/Vazirmatn-Bold.ttf differ diff --git a/public/fonts/Vazirmatn-OFL.txt b/public/fonts/Vazirmatn-OFL.txt new file mode 100644 index 0000000000..d8320040d8 --- /dev/null +++ b/public/fonts/Vazirmatn-OFL.txt @@ -0,0 +1,93 @@ +Copyright 2015 The Vazirmatn Project Authors (https://github.com/rastikerdar/vazirmatn) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/public/fonts/Vazirmatn-Regular.ttf b/public/fonts/Vazirmatn-Regular.ttf new file mode 100644 index 0000000000..64e4a81895 Binary files /dev/null and b/public/fonts/Vazirmatn-Regular.ttf differ diff --git a/src/assets/fonts/Vazirmatn-Variable.woff2 b/src/assets/fonts/Vazirmatn-Variable.woff2 new file mode 100644 index 0000000000..a501289a85 Binary files /dev/null and b/src/assets/fonts/Vazirmatn-Variable.woff2 differ diff --git a/src/components/ai-edition/CaptionsPane.choices.test.tsx b/src/components/ai-edition/CaptionsPane.choices.test.tsx index 02b3142d4e..686dbb5cec 100644 --- a/src/components/ai-edition/CaptionsPane.choices.test.tsx +++ b/src/components/ai-edition/CaptionsPane.choices.test.tsx @@ -55,15 +55,18 @@ describe("caption choices", () => { expect(stored().language).toBe("fr"); }); - it("shows each font as a specimen of itself and writes the one clicked", () => { + it.each([ + "Lora", + "Vazirmatn", + ])("shows %s as a specimen of itself and saves the choice", (family) => { show(); - const lora = within(screen.getByRole("group", { name: "Font", hidden: true })).getByRole( + const font = within(screen.getByRole("group", { name: "Font", hidden: true })).getByRole( "button", - { name: "Lora", hidden: true }, + { name: family, hidden: true }, ); - expect(lora.querySelector("span")).toHaveStyle({ fontFamily: "Lora" }); - fireEvent.click(lora); - expect(stored().fontFamily).toBe("Lora"); + expect(font.querySelector("span")).toHaveStyle({ fontFamily: family }); + fireEvent.click(font); + expect(stored().fontFamily).toBe(family); }); it("never lets the minimum words per line pass the maximum", () => { diff --git a/src/lib/ai-edition/annotations/fontTables.test.ts b/src/lib/ai-edition/annotations/fontTables.test.ts index ff1305511e..b44339e785 100644 --- a/src/lib/ai-edition/annotations/fontTables.test.ts +++ b/src/lib/ai-edition/annotations/fontTables.test.ts @@ -46,6 +46,16 @@ describe("readFontMetrics", () => { expect(inter.advanceOf(0x4e2d)).toBeNull(); }); + it.each([ + "normal", + "bold", + ] as const)("includes Persian and Arabic glyphs in Vazirmatn %s", (weight) => { + const font = shipped("Vazirmatn", weight); + for (const character of "پچژگکی۰۱۲۳۴۵۶۷۸۹أإةى٠١٢٣٤٥٦٧٨٩") { + expect(font.advanceOf(character.codePointAt(0) ?? 0), character).toBeGreaterThan(0); + } + }); + it("refuses bytes that are not a font", () => { expect(readFontMetrics(new Uint8Array([1, 2, 3, 4]))).toBeNull(); }); diff --git a/src/lib/textFonts.ts b/src/lib/textFonts.ts index 33f0b1f515..fb84d44069 100644 --- a/src/lib/textFonts.ts +++ b/src/lib/textFonts.ts @@ -10,7 +10,14 @@ import { getAssetPath } from "./assetPath"; -export const TEXT_FONT_FAMILIES = ["Inter", "Lora", "Oswald", "Caveat", "IBM Plex Mono"] as const; +export const TEXT_FONT_FAMILIES = [ + "Inter", + "Lora", + "Oswald", + "Caveat", + "IBM Plex Mono", + "Vazirmatn", +] as const; export type TextFontFamily = (typeof TEXT_FONT_FAMILIES)[number]; diff --git a/src/styles/design-tokens.css b/src/styles/design-tokens.css index 5efa10250e..045b526190 100644 --- a/src/styles/design-tokens.css +++ b/src/styles/design-tokens.css @@ -136,8 +136,9 @@ /* typography — Geist / Geist Mono are the brand faces, self-hosted by styles/fonts.css. The old system stacks stay on as fallback so a failed font load degrades instead of dropping to a serif default. */ - --font-display: "Geist", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif; - --font-body: "Geist", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif; + --font-ui: "Geist"; + --font-body: var(--font-ui), system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif; + --font-display: var(--font-body); --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace; /* size */ @@ -184,6 +185,11 @@ --ease: cubic-bezier(0.2, 0, 0, 1); } +:root:lang(fa), +:root:lang(ar) { + --font-ui: "Vazirmatn UI", "Geist"; +} + :root[data-theme="dark"] { --bg: #0a0d12; --bg-grad: radial-gradient(ellipse at 50% 0%, #13171f 0%, #0a0d12 60%); diff --git a/src/styles/fonts.css b/src/styles/fonts.css index 4662dc7892..3bd093e095 100644 --- a/src/styles/fonts.css +++ b/src/styles/fonts.css @@ -4,9 +4,8 @@ * --font-body / --font-mono in design-tokens.css. * * Self-hosted rather than pulled from Google Fonts on purpose: this is a - * desktop app that has to start with no network, and the whole UI chrome - * hangs off these two families. (The on-canvas caption/annotation families - * are separate: public/fonts, registered by lib/textFonts.ts.) + * desktop app that has to start with no network. The on-canvas caption + * and annotation families are registered separately by lib/textFonts.ts. * * One variable file per family covers weights 100-900, so the pair costs * ~138 KB instead of the ~19 static cuts it replaces. Upstream: @@ -28,3 +27,15 @@ font-style: normal; font-display: swap; } + +/* The UI uses the variable face. The video compositor uses the static + regular and bold faces in public/fonts, alongside the OFL licence. + Limit the UI face to Arabic script so Latin labels still use Geist. */ +@font-face { + font-family: "Vazirmatn UI"; + src: url("../assets/fonts/Vazirmatn-Variable.woff2") format("woff2"); + font-weight: 100 900; + font-style: normal; + font-display: swap; + unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200D, U+FB50-FDFF, U+FE70-FEFF; +}