diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 4008b78b..f48cf20b 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -28,7 +28,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - run: sudo apt install -y ghostscript fonts-freefont-ttf - uses: julia-actions/setup-julia@v2 with: version: 1 diff --git a/docs/Project.toml b/docs/Project.toml index b624607f..e70dbbff 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,7 @@ [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +Fontconfig = "186bb1d3-e1f7-5a2c-a377-96d770f13627" InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" @@ -14,5 +15,6 @@ Unitful = {path = ".."} [compat] Documenter = "1" -Latexify = "0.16.9" +Latexify = "0.16.10" Plots = "1" +Fontconfig = "0.4" diff --git a/docs/generate_latex_images.jl b/docs/generate_latex_images.jl index e2349db1..3c0c4288 100644 --- a/docs/generate_latex_images.jl +++ b/docs/generate_latex_images.jl @@ -1,4 +1,10 @@ -using LaTeXStrings, Unitful, Latexify, tectonic_jll +using LaTeXStrings, Unitful, Latexify +import tectonic_jll # needed for lightweight LaTeX render +using Fontconfig: format, match, Pattern + +# Since the docs can get built on different systems, we need to find a locally installed +# monospaced font that has enough Unicode coverage to handle π +monofont = format(match(Pattern(spacing=100, charset="3c0")), "%{family}") commands = [ :(latexify(612.2u"nm")), @@ -19,11 +25,16 @@ end ltab1 = latextabular(tab1, adjustment=:l, transpose=true, latex=false, booktabs=true, head=["julia", "\\LaTeX", "Result"]) # Setting an explicit white background color results in transparent PDF, so go offwhite. -ltab1 = LaTeXString("\\definecolor{offwhite}{rgb}{0.999,0.999,0.999}\n\\pagecolor{offwhite}\n\\color{black}\n" * ltab1) +ltab1 = LaTeXString(""" + \\setmonofont{$monofont} + \\definecolor{offwhite}{rgb}{0.999,0.999,0.999} + \\pagecolor{offwhite} + \\color{black} +""" * ltab1) -render(ltab1, MIME("image/png"); use_tectonic=true, +render(ltab1, MIME("image/png"); use_tectonic=true, open=false, name=(@__DIR__)*"/src/assets/latex-examples", - packages=["booktabs", "color", "siunitx"], + packages=["booktabs", "color", "siunitx", "fontspec"], documentclass=("standalone")) functions = [ @@ -133,14 +144,13 @@ ltab2 = latextabular(tab2, adjustment=:l, transpose=true, latex=false, booktabs= # Set background to not-quite-white so it doesn't get treated as transparent ltab2 = LaTeXString( """ - \\setmainfont{FreeSerif} - \\setmonofont{FreeMono} + \\setmonofont{$monofont} \\definecolor{offwhite}{rgb}{0.999,0.999,0.999} \\pagecolor{offwhite} \\color{black} """ * ltab2) -render(ltab2, MIME("image/png"); use_tectonic=true, +render(ltab2, MIME("image/png"); use_tectonic=true, open=false, tectonic_flags=`-Z continue-on-errors`, name=(@__DIR__)*"/src/assets/latex-allunits", packages=["booktabs", "color", "siunitx", "fontspec"], diff --git a/docs/make.jl b/docs/make.jl index d33e94c8..905b2575 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -4,30 +4,31 @@ using Documenter, Unitful, Dates include("generate_latex_images.jl") DocMeta.setdocmeta!(Unitful, :DocTestSetup, :(using Unitful)) - -makedocs( - sitename = "Unitful.jl", - format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"), - warnonly = [:missing_docs], - modules = [Unitful], - workdir = joinpath(@__DIR__, ".."), - pages = [ - "Home" => "index.md" - "Highlighted features" => "highlights.md" - "Types" => "types.md" - "Defining new units" => "newunits.md" - "Conversion/promotion" => "conversion.md" - "Manipulating units" => "manipulations.md" - "How units are displayed" => "display.md" - "Logarithmic scales" => "logarithm.md" - "Temperature scales" => "temperature.md" - "Interoperability with `Dates`" => "dates.md" - "Latexifying units" => "latexify.md" - "Extending Unitful" => "extending.md" - "Troubleshooting" => "trouble.md" - "Pre-defined dimensions, units, and constants" => "defaultunits.md" - "License" => "LICENSE.md" - ] -) +withenv("UNITFUL_FANCY_EXPONENTS" => "false") do + makedocs( + sitename = "Unitful.jl", + format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"), + warnonly = [:missing_docs], + modules = [Unitful], + workdir = joinpath(@__DIR__, ".."), + pages = [ + "Home" => "index.md" + "Highlighted features" => "highlights.md" + "Types" => "types.md" + "Defining new units" => "newunits.md" + "Conversion/promotion" => "conversion.md" + "Manipulating units" => "manipulations.md" + "How units are displayed" => "display.md" + "Logarithmic scales" => "logarithm.md" + "Temperature scales" => "temperature.md" + "Interoperability with `Dates`" => "dates.md" + "Latexifying units" => "latexify.md" + "Extending Unitful" => "extending.md" + "Troubleshooting" => "trouble.md" + "Pre-defined dimensions, units, and constants" => "defaultunits.md" + "License" => "LICENSE.md" + ] + ) +end deploydocs(repo = "github.com/JuliaPhysics/Unitful.jl.git")