Docs: the chrome is set in the system UI font
Pins estilo 260f98c, which drops Onest so the chrome can never flash; the layout no longer links the v1 font stylesheet, and a test fails if any served page links, preloads or declares a chrome webfont while the document page keeps preloading Docs' own fonts. Old v1 font URLs still answer. Reviewed by GPT-6-Astra via Codex (#85). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from chore/estilo-system-font into main.
7 files changed,
+176
−28
AGENTS.md+8 −3go.mod+1 −1go.sum+2 −2internal/docs/app.go+5 −1internal/docs/nowebfont_test.go+160 −0internal/docs/theme_assets_test.go+0 −20internal/docs/views/layout.html+0 −1
CI passed — run details
diff --git a/AGENTS.md b/AGENTS.md| index 9321835..7b093e3 100644 |
| --- a/AGENTS.md |
| +++ b/AGENTS.md |
| @@ -574,9 +574,14 @@ is `polish-audit/fonts/NO-FOUT.md`; this is how it is built. |
| expressions and fails unless every node and mark appears. The |
| generative test checks the server-rendered DOM and the mounted editor's |
| DOM. |
| -- **The chrome uses no webfont of Docs'**, so the toolbar glyphs and page |
| - numbers are system faces; keep it that way. estilo's Onest is the |
| - exception, and it is estilo's: it is `font-display: swap`. |
| +- **The chrome uses no webfont at all**, so the toolbar glyphs, page |
| + numbers and the rest of the chrome are system faces; keep it that way. |
| + estilo's Onest was the one exception until 2026-10-25, when estilo moved |
| + the chrome to the system UI face (estilo AGENTS.md row 9, Paul: "No |
| + flashing, ever!"). The layout no longer links it; estilo's v1 font URLs |
| + stay mounted only for pages cached before that. |
| + `TestNoPageLinksOrPreloadsAChromeWebfont` fails if any served page |
| + links, preloads or declares a font outside Docs' own `/static/fonts/`. |
| - **A page that was never held keeps its first layout.** The editor |
| freezes pagination if the sheet is already in view when it could first |
| paginate. That happens with no hold, or a gate that found none. |
diff --git a/go.mod b/go.mod| index 9f6ac9d..8d1151c 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -3,7 +3,7 @@ module github.com/carlosframework/docs |
| go 1.26.5 |
| require ( |
| - amadan.net/oficina/estilo.git v0.0.0-20261024225350-d53b8e9533a1 |
| + amadan.net/oficina/estilo.git v0.0.0-20261025200559-260f98c42e2d |
| amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064 |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 |
| amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf |
diff --git a/go.sum b/go.sum| index 8660ade..6163a42 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -1,5 +1,5 @@ |
| -amadan.net/oficina/estilo.git v0.0.0-20261024225350-d53b8e9533a1 h1:Xaidrm9rzFyne6PujFYXiY7nGRy+/KzH7kGBM2+D5LQ= |
| -amadan.net/oficina/estilo.git v0.0.0-20261024225350-d53b8e9533a1/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| +amadan.net/oficina/estilo.git v0.0.0-20261025200559-260f98c42e2d h1:p9+01xRdBD7s1viTINgQ6XoDD5ghOxYubD7FNcjhBTw= |
| +amadan.net/oficina/estilo.git v0.0.0-20261025200559-260f98c42e2d/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064 h1:2YbDksZDxpY9khlhXmTeiM89yze7w2XfYSumtrzH4tc= |
| amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064/go.mod h1:+7xsX+QyVFrKy5gDAGh+FZ5+75z4CibWTL0wl9DWAw0= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM= |
diff --git a/internal/docs/app.go b/internal/docs/app.go| index 9f5bd31..a261e7b 100644 |
| --- a/internal/docs/app.go |
| +++ b/internal/docs/app.go |
| @@ -651,7 +651,11 @@ func New(cfg Config) (*App, error) { |
| // The suite's app icons, served from estilo (the bar's brand, and the |
| // switcher's tiles once they render). |
| r.Handle(brand.Prefix+"*", brand.Handler()) |
| - // Onest, Calma's typeface, served by estilo under its versioned prefix. |
| + // estilo's retired v1 Onest files. The chrome is set in the system UI |
| + // face now, so no page links them (estilo AGENTS.md row 9); they stay |
| + // answering so a page cached before the change still resolves its |
| + // stylesheet. Docs' own document faces are a different thing, under |
| + // /static/fonts/ (internal/fonts). |
| r.Handle(theme.FontPrefix+"*", theme.FontHandler()) |
| // The sky behind the sign-in door: a closed set of SVGs, public. |
| r.Handle(sky.Prefix+"*", sky.Handler()) |
diff --git a/internal/docs/nowebfont_test.go b/internal/docs/nowebfont_test.go| new file mode 100644 |
| index 0000000..f8b415a |
| --- /dev/null |
| +++ b/internal/docs/nowebfont_test.go |
| @@ -0,0 +1,160 @@ |
| +package docs_test |
| + |
| +import ( |
| + "io/fs" |
| + "net/http" |
| + "net/http/httptest" |
| + "os" |
| + "path" |
| + "path/filepath" |
| + "regexp" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/estilo.git/theme" |
| + |
| + "github.com/carlosframework/docs/internal/docs" |
| + "github.com/carlosframework/docs/internal/fonts" |
| +) |
| + |
| +// The chrome is set in the system UI face and downloads no font, so it |
| +// can never flash (Paul, 2026-10-25: "There should never be a flash of |
| +// unstyled text. Ever." estilo AGENTS.md row 9). No page links or |
| +// preloads a chrome webfont: not estilo's retired Onest, and no font file |
| +// outside Docs' own. estilo's v1 files stay mounted (app.go) so a page |
| +// cached before this still resolves its stylesheet; nothing may name them. |
| +// |
| +// The document's fonts are a different thing and are untouched: a |
| +// document page preloads the faces its text is set in, from |
| +// internal/fonts under /static/fonts/ (fontgate.go). estilo's are under |
| +// /static/estilo/fonts/. The test tells the two apart by that prefix, and |
| +// requires the document page to still carry its own preloads, so an |
| +// allowance that matched nothing could not pass it. |
| +// |
| +// This replaces TestOnestIsLinkedAndServed, which required the link. |
| +func TestNoPageLinksOrPreloadsAChromeWebfont(t *testing.T) { |
| + estiloFonts := path.Dir(strings.TrimSuffix(theme.FontPrefix, "/")) + "/" |
| + if estiloFonts != "/static/estilo/fonts/" || fonts.PathPrefix != "/static/fonts/" || |
| + strings.HasPrefix(estiloFonts, fonts.PathPrefix) || strings.HasPrefix(fonts.PathPrefix, estiloFonts) { |
| + t.Fatalf("estilo's fonts are under %s and Docs' under %s; this test tells them apart by those prefixes", estiloFonts, fonts.PathPrefix) |
| + } |
| + |
| + // Every template, as source: whichever route renders a page, it is |
| + // made of these, including any this test does not request. |
| + templates := 0 |
| + err := filepath.WalkDir("views", func(p string, d fs.DirEntry, err error) error { |
| + if err != nil || d.IsDir() || filepath.Ext(p) != ".html" { |
| + return err |
| + } |
| + b, err := os.ReadFile(p) |
| + if err != nil { |
| + return err |
| + } |
| + templates++ |
| + if strings.Contains(string(b), estiloFonts) { |
| + t.Errorf("%s names estilo's webfont path %s", p, estiloFonts) |
| + } |
| + return nil |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if templates < 10 { |
| + t.Fatalf("read only %d templates under views; the scan would pass vacuously", templates) |
| + } |
| + |
| + // And as served, on every screen the layout wraps. |
| + app, err := docs.NewForTest(t) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + alice := signInCookies(t, app, "alice@example.com") |
| + sqid := createDoc(t, app, alice, "Minutes") |
| + public := linkFor(t, app, alice, sqid) |
| + // Someone it is not shared with meets the error page, not a 404 line. |
| + bob := signInCookies(t, app, "bob@example.com") |
| + pages := []struct { |
| + name string |
| + cookies []*http.Cookie |
| + path string |
| + status int |
| + }{ |
| + {"the sign-in door", nil, "/signin", http.StatusOK}, |
| + {"the list", alice, "/", http.StatusOK}, |
| + {"a document", alice, "/d/" + sqid, http.StatusOK}, |
| + {"the share page", alice, "/d/" + sqid + "/share", http.StatusOK}, |
| + {"a public link", nil, public, http.StatusOK}, |
| + {"the error page", bob, "/d/" + sqid, http.StatusNotFound}, |
| + } |
| + documentFonts := 0 |
| + for _, p := range pages { |
| + // As a browser asks: the error page is only for a request that |
| + // accepts HTML (errors.go's wantsHTML). |
| + req := httptest.NewRequest(http.MethodGet, p.path, nil) |
| + req.Header.Set("Accept", "text/html") |
| + for _, c := range p.cookies { |
| + req.AddCookie(c) |
| + } |
| + rec := httptest.NewRecorder() |
| + app.Handler().ServeHTTP(rec, req) |
| + if rec.Code != p.status { |
| + t.Fatalf("GET %s (%s) = %d, want %d", p.path, p.name, rec.Code, p.status) |
| + } |
| + body := rec.Body.String() |
| + if !strings.Contains(body, "<head>") { |
| + t.Fatalf("GET %s (%s) served no page", p.path, p.name) |
| + } |
| + bad, own := chromeWebfonts(body, estiloFonts) |
| + for _, why := range bad { |
| + t.Errorf("%s (GET %s) %s", p.name, p.path, why) |
| + } |
| + if p.name == "a document" { |
| + documentFonts = own |
| + } |
| + } |
| + // The document page's own preloads (TestANewDocumentIsInCarlito holds |
| + // which ones) are still there, and this test saw them as Docs'. |
| + if documentFonts == 0 { |
| + t.Errorf("a document page preloads none of Docs' own faces under %s; the allowance for them matched nothing", fonts.PathPrefix) |
| + } |
| + |
| + // The retired files still answer, for pages cached before the change. |
| + for _, name := range []string{"fonts.css", "onest-latin.woff2"} { |
| + if rec := get(t, app, nil, theme.FontPrefix+name); rec.Code != http.StatusOK { |
| + t.Errorf("GET %s%s = %d; keep estilo's font handler mounted for old pages", theme.FontPrefix, name, rec.Code) |
| + } |
| + } |
| +} |
| + |
| +var ( |
| + linkTag = regexp.MustCompile(`(?is)<link\b[^>]*>`) |
| + linkHref = regexp.MustCompile(`(?is)\bhref\s*=\s*["']?([^"'\s>]+)`) |
| + asFont = regexp.MustCompile(`(?i)\bas\s*=\s*["']?font\b`) |
| + fontFile = regexp.MustCompile(`(?i)\.(woff2?|ttf|otf|eot)\b`) |
| +) |
| + |
| +// chromeWebfonts names each way html would download a font for the |
| +// chrome: estilo's font path at any version, a <link> that preloads a |
| +// font or names a font file anywhere but Docs' own /static/fonts/, or a |
| +// face declared inline (Docs declares its faces in internal/fonts' |
| +// generated stylesheet, never in a page). own counts the font links that |
| +// are Docs' document faces. |
| +func chromeWebfonts(html, estiloFonts string) (found []string, own int) { |
| + if strings.Contains(html, estiloFonts) { |
| + found = append(found, "names estilo's webfont path "+estiloFonts) |
| + } |
| + for _, tag := range linkTag.FindAllString(html, -1) { |
| + if !asFont.MatchString(tag) && !fontFile.MatchString(tag) { |
| + continue |
| + } |
| + if m := linkHref.FindStringSubmatch(tag); m != nil && strings.HasPrefix(m[1], fonts.PathPrefix) { |
| + own++ |
| + continue |
| + } |
| + found = append(found, "links or preloads a chrome font: "+tag) |
| + } |
| + if strings.Contains(strings.ToLower(html), "@font-face") { |
| + found = append(found, "declares a font face inline") |
| + } |
| + return found, own |
| +} |
diff --git a/internal/docs/theme_assets_test.go b/internal/docs/theme_assets_test.go| index 95d1dbd..0afc830 100644 |
| --- a/internal/docs/theme_assets_test.go |
| +++ b/internal/docs/theme_assets_test.go |
| @@ -61,26 +61,6 @@ func TestSharedThemeAssetFingerprintAndCache(t *testing.T) { |
| } |
| } |
| -// The layout names Onest's stylesheet under estilo's versioned prefix, and |
| -// the app serves it there: when estilo moves the fonts, this fails rather |
| -// than every page quietly falling back to the system face. |
| -func TestOnestIsLinkedAndServed(t *testing.T) { |
| - app, err := NewForTest(t) |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| - page := serve(app, httptest.NewRequest(http.MethodGet, "/signin", nil)) |
| - css := theme.FontPrefix + "fonts.css" |
| - if !strings.Contains(page.Body.String(), `href="`+css+`"`) { |
| - t.Fatalf("layout does not link %s", css) |
| - } |
| - for _, path := range []string{css, theme.FontPrefix + "onest-latin.woff2"} { |
| - if res := serve(app, httptest.NewRequest(http.MethodGet, path, nil)); res.Code != http.StatusOK { |
| - t.Fatalf("GET %s = %d", path, res.Code) |
| - } |
| - } |
| -} |
| - |
| // The busy rule (estilo's busy): the page links busy.css and busy.js, and |
| // the shim it serves is estilo's — rastrillo's without the old busy rule, |
| // which would fight the new one. |
diff --git a/internal/docs/views/layout.html b/internal/docs/views/layout.html| index 2f08a5f..0e33722 100644 |
| --- a/internal/docs/views/layout.html |
| +++ b/internal/docs/views/layout.html |
| @@ -18,7 +18,6 @@ |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <title>{{range .Frame.TitleParts}}{{.}} · {{end}}{{.Frame.Chrome.App.Name}}</title> |
| {{block "pagehead" .}}{{end}} |
| -<link rel="stylesheet" href="/static/estilo/fonts/v1/fonts.css"> |
| <link rel="stylesheet" href="{{asset "static/tokens.css"}}"> |
| <link rel="stylesheet" href="{{asset "static/estilo/busy.css"}}"> |
| <link rel="stylesheet" href="{{asset "static/theme.css"}}"> |