From c9a56578d21af2228ce060deb911296a135f1952 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Wed, 16 Jun 2021 14:24:57 +1200 Subject: [PATCH] Use JuliaMono, drop Google Fonts CDN (#1569) --- CHANGELOG.md | 8 ++ assets/html/scss/documenter-dark.scss | 3 +- assets/html/scss/documenter/_variables.scss | 2 +- assets/html/themes/documenter-dark.css | 6 +- assets/html/themes/documenter-light.css | 6 +- src/Writers/HTMLWriter.jl | 6 +- test/examples/make.jl | 1 + test/examples/src/fonts.md | 139 ++++++++++++++++++++ test/examples/tests.jl | 2 +- 9 files changed, 162 insertions(+), 11 deletions(-) create mode 100644 test/examples/src/fonts.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 635f7f6069..adeec1183c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Version `v0.27.1` +* ![Enhancement][badge-enhancement] The HTML output now uses [JuliaMono][juliamono] as the default monospace font, retrieved from CDNJS. Relatedly, the Lato font is also now retrieved from CDNJS, and the generated HTML pages no longer depend on Google Fonts. ([#618][github-618], [#1561][github-1561], [#1568][github-1568], [#1569][github-1569], [JuliaLang/www.julialang.org][julialangorg-1272]) + * ![Enhancement][badge-enhancement] The wording of the text in the the old version warning box was improved. ([#1595][github-1595]) * ![Bugfix][badge-bugfix] Documenter no longer throws an error when generating the version selector if there are no deployed versions. ([#1594][github-1594], [#1596][github-1596]) @@ -594,6 +596,7 @@ [github-487]: https://github.com/JuliaDocs/Documenter.jl/issues/487 [github-511]: https://github.com/JuliaDocs/Documenter.jl/pull/511 [github-535]: https://github.com/JuliaDocs/Documenter.jl/issues/535 +[github-618]: https://github.com/JuliaDocs/Documenter.jl/issues/618 [github-631]: https://github.com/JuliaDocs/Documenter.jl/issues/631 [github-697]: https://github.com/JuliaDocs/Documenter.jl/pull/697 [github-706]: https://github.com/JuliaDocs/Documenter.jl/pull/706 @@ -811,7 +814,10 @@ [github-1556]: https://github.com/JuliaDocs/Documenter.jl/issues/1556 [github-1557]: https://github.com/JuliaDocs/Documenter.jl/pull/1557 [github-1559]: https://github.com/JuliaDocs/Documenter.jl/pull/1559 +[github-1561]: https://github.com/JuliaDocs/Documenter.jl/issues/1561 [github-1567]: https://github.com/JuliaDocs/Documenter.jl/pull/1567 +[github-1568]: https://github.com/JuliaDocs/Documenter.jl/issues/1568 +[github-1569]: https://github.com/JuliaDocs/Documenter.jl/pull/1569 [github-1577]: https://github.com/JuliaDocs/Documenter.jl/pull/1577 [github-1590]: https://github.com/JuliaDocs/Documenter.jl/pull/1590 [github-1594]: https://github.com/JuliaDocs/Documenter.jl/issues/1594 @@ -820,10 +826,12 @@ [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 [julia-39841]: https://github.com/JuliaLang/julia/pull/39841 +[julialangorg-1272]: https://github.com/JuliaLang/www.julialang.org/issues/1272 [documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl [documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl [json-jl]: https://github.com/JuliaIO/JSON.jl +[juliamono]: https://cormullion.github.io/pages/2020-07-26-JuliaMono/ [badge-breaking]: https://img.shields.io/badge/BREAKING-red.svg diff --git a/assets/html/scss/documenter-dark.scss b/assets/html/scss/documenter-dark.scss index 86402abcfa..941f1ed15d 100644 --- a/assets/html/scss/documenter-dark.scss +++ b/assets/html/scss/documenter-dark.scss @@ -10,8 +10,9 @@ $bulmaswatch-import-font: false; $documenter-is-dark-theme: true; +// Darkly sets the font variables, so we need to override them here $family-sans-serif: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "Helvetica", "Arial", sans-serif; -$family-monospace: 'Roboto Mono', 'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', 'DejaVu Sans Mono', monospace; +$family-monospace: 'JuliaMono', 'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', 'DejaVu Sans Mono', monospace; $info: #024c7d; $success: #008438; diff --git a/assets/html/scss/documenter/_variables.scss b/assets/html/scss/documenter/_variables.scss index 64260b2fdf..5648f4876c 100644 --- a/assets/html/scss/documenter/_variables.scss +++ b/assets/html/scss/documenter/_variables.scss @@ -40,7 +40,7 @@ $lightness-unit: 8% !default; // ----- // Declares the font family for the main text. $family-sans-serif: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "Helvetica", "Arial", sans-serif !default; -$family-monospace: 'Roboto Mono', 'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', 'DejaVu Sans Mono', monospace !default; +$family-monospace: 'JuliaMono', 'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', 'DejaVu Sans Mono', monospace !default; // Note: declaring a font family here does not necessarily mean that it will be available // for the user. For uncommon fonts it is up to the user to also provide the necessary font // assets, e.g. via a CDN, in the makedocs() call. diff --git a/assets/html/themes/documenter-dark.css b/assets/html/themes/documenter-dark.css index 2e7125287e..d8940652f0 100644 --- a/assets/html/themes/documenter-dark.css +++ b/assets/html/themes/documenter-dark.css @@ -762,10 +762,10 @@ a.has-text-danger:hover, a.has-text-danger:focus { font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "Helvetica", "Arial", sans-serif !important; } .is-family-monospace { - font-family: "Roboto Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } + font-family: "JuliaMono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } .is-family-code { - font-family: "Roboto Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } + font-family: "JuliaMono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } .is-block { display: block !important; } @@ -1112,7 +1112,7 @@ html.theme--documenter-dark { html.theme--documenter-dark pre { -moz-osx-font-smoothing: auto; -webkit-font-smoothing: auto; - font-family: "Roboto Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace; } + font-family: "JuliaMono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace; } html.theme--documenter-dark body { color: #fff; font-size: 1em; diff --git a/assets/html/themes/documenter-light.css b/assets/html/themes/documenter-light.css index 9ba7df2245..7af9a8febf 100644 --- a/assets/html/themes/documenter-light.css +++ b/assets/html/themes/documenter-light.css @@ -316,7 +316,7 @@ code, pre { -moz-osx-font-smoothing: auto; -webkit-font-smoothing: auto; - font-family: "Roboto Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace; } + font-family: "JuliaMono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace; } body { color: #222222; @@ -862,10 +862,10 @@ a.has-text-danger:hover, a.has-text-danger:focus { font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "Helvetica", "Arial", sans-serif !important; } .is-family-monospace { - font-family: "Roboto Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } + font-family: "JuliaMono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } .is-family-code { - font-family: "Roboto Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } + font-family: "JuliaMono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "DejaVu Sans Mono", monospace !important; } .is-block { display: block !important; } diff --git a/src/Writers/HTMLWriter.jl b/src/Writers/HTMLWriter.jl index 323f819d5b..60bf94c8a6 100644 --- a/src/Writers/HTMLWriter.jl +++ b/src/Writers/HTMLWriter.jl @@ -445,7 +445,8 @@ module RD using ..HTMLWriter: KaTeX, MathJax, MathJax2, MathJax3 const requirejs_cdn = "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" - const google_fonts = "https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" + const lato = "https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" + const juliamono = "https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.039/juliamono-regular.css" const fontawesome_version = "5.15.3" const fontawesome_css = [ "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/$(fontawesome_version)/css/fontawesome.min.css", @@ -839,7 +840,8 @@ function render_head(ctx, navnode) page_title = "$(mdflatten(pagetitle(ctx, navnode))) · $(ctx.doc.user.sitename)" css_links = [ - RD.google_fonts, + RD.lato, + RD.juliamono, RD.fontawesome_css..., RD.katex_css, ] diff --git a/test/examples/make.jl b/test/examples/make.jl index c1646de881..6cfabad5ef 100644 --- a/test/examples/make.jl +++ b/test/examples/make.jl @@ -197,6 +197,7 @@ htmlbuild_pages = Any[ "unicode.md", "latex.md", "example-output.md", + "fonts.md", ] function html_doc(build_directory, mathengine) diff --git a/test/examples/src/fonts.md b/test/examples/src/fonts.md new file mode 100644 index 0000000000..9110073c26 --- /dev/null +++ b/test/examples/src/fonts.md @@ -0,0 +1,139 @@ +# Font demo + +```@example generate-font-example +using Documenter.Utilities.DOM +function font_demo_snippet(weight, style) + @tags pre code div + codeblock = pre(code[".language-julia-repl"](""" + julia> for n in 0x2700:0x27bf + Base.isidentifier(string(Char(n))) && print(Char(n)) + end + ✀✁✂✃✄✅✆✇✈✉✊✋✌✍✎✏✐✑✒✓✔✕✖✗✘✙✚✛✜✝✞✟✠✡✢✣✤✥✦✧✨✩✪✫✬✭✮✯✰✱✲✳✴✵✶✷✸✹✺ + ✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞❟❠❡❢❣❤❥❦❧➔➕➖➗➘➙➚➛➜➝➞➟➠➡ + ➢➣➤➥➦➧➨➩➪➫➬➭➮➯➰➱➲➳➴➵➶➷➸➹➺➻➼➽➾➿ + + julia> ❤(s) = println("I ❤ \$(s)") + ❤ (generic function with 1 method) + + julia> ❤("Julia") + I ❤ Julia + """)) + + wrapping_div = if isnothing(weight) && isnothing(style) + div + else + css_style = isnothing(weight) ? "" : "font-weight: $(weight);" + css_style *= isnothing(style) ? "" : "font-style: $(style);" + div[:style => css_style] + end + + return wrapping_div(codeblock) +end +``` + +## Standard font + +```@example generate-font-example +font_demo_snippet(nothing, nothing) +``` + +## Different weights: `100:100:900` + +```@example generate-font-example +font_demo_snippet(100, nothing) +``` +```@example generate-font-example +font_demo_snippet(200, nothing) +``` +```@example generate-font-example +font_demo_snippet(300, nothing) +``` +```@example generate-font-example +font_demo_snippet(400, nothing) +``` +```@example generate-font-example +font_demo_snippet(500, nothing) +``` +```@example generate-font-example +font_demo_snippet(600, nothing) +``` +```@example generate-font-example +font_demo_snippet(700, nothing) +``` +```@example generate-font-example +font_demo_snippet(800, nothing) +``` +```@example generate-font-example +font_demo_snippet(900, nothing) +``` + +## Italic & italic @ 900 + +```@example generate-font-example +font_demo_snippet(nothing, "italic") +``` +```@example generate-font-example +font_demo_snippet(900, "italic") +``` + +## Unicode rendering + +Unicode rendering examples based on issues [#618](https://github.com/JuliaDocs/Documenter.jl/issues/618), [#1561](https://github.com/JuliaDocs/Documenter.jl/issues/1561). + +``` +'∀' : Unicode U+2200 (category Sm: Symbol, math) +ERROR: StringIndexError("∀ x ∃ y", 2) +1 ⊻ 3: +``` + +``` +┌────────────────────────────────────────────────────────────────────────────┐ +│ ┌───────────────┐ │ +│ HTTP.request(method, uri, headers, body) -> │ HTTP.Response ├──────────────┼┐ +│ │ └───────────────┘ ││ +│ │ ││ +│ │ ┌──────────────────────────────────────┐ ┌──────────────────┐ ││ +│ └───▶│ request(RedirectLayer, ...) │ │ HTTP.StatusError │ ││ +│ └─┬────────────────────────────────────┴─┐ └─────────▲────────┘ ││ +│ │ request(BasicAuthLayer, ...) │ │ ││ +│ └─┬────────────────────────────────────┴─┐ │ ││ +│ │ request(CookieLayer, ...) │ │ ││ +│ └─┬────────────────────────────────────┴─┐ │ ││ +│ │ request(CanonicalizeLayer, ...) │ │ ││ +│ └─┬────────────────────────────────────┴─┐ │ ││ +│ │ request(MessageLayer, ...) ├─────────┼──────┐ ││ +``` + +``` + ┌──────────────────────────────────────────────────────────────────────┐ +1 │ ▗▄▞▀▀▀▀▀▀▀▄▄ │ + │ ▄▞▘ ▀▄▖ │ + │ ▄▀ ▝▚▖ │ + │ ▗▞ ▝▄ │ + │ ▞▘ ▝▚▖ │ + │ ▗▀ ▝▚ │ + │ ▞▘ ▀▖ │ + │ ▗▞ ▝▄ │ + │ ▄▘ ▚▖ │ + │ ▗▞ ▝▄ │ + │ ▄▘ ▚▖ │ + │ ▗▀ ▝▚ │ + │ ▗▞▘ ▀▄ │ + │ ▄▀▘ ▀▚▖ │ +0 │ ▄▄▄▄▀▀ ▝▀▚▄▄▄▖│ + └──────────────────────────────────────────────────────────────────────┘ + 0 70 +``` + +``` +julia> pretty_table(data, display_size = (11,30)) +┌────────┬────────┬────────┬── +│ Col. 1 │ Col. 2 │ Col. 3 │ ⋯ +├────────┼────────┼────────┼── +│ 1 │ false │ 1.0 │ ⋯ +│ 2 │ true │ 2.0 │ ⋯ +│ 3 │ false │ 3.0 │ ⋯ +│ ⋮ │ ⋮ │ ⋮ │ ⋱ +└────────┴────────┴────────┴── + 1 column and 3 rows omitted +``` diff --git a/test/examples/tests.jl b/test/examples/tests.jl index 01c1c34d8c..aca2281d34 100644 --- a/test/examples/tests.jl +++ b/test/examples/tests.jl @@ -130,7 +130,7 @@ end @test realpath(doc.internal.assets) == realpath(joinpath(dirname(@__FILE__), "..", "..", "assets")) - @test length(doc.blueprint.pages) == 19 + @test length(doc.blueprint.pages) == 20 let headers = doc.internal.headers @test Documenter.Anchors.exists(headers, "Documentation")