Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache all fonts #56

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ jobs:
working-directory: test/subdir1
run: |
docker run -v $(pwd)/..:/workdir localhost:5000/name/app:latest /bin/bash -c "cd subdir1 && lualatex current-file.tex"
- name: 51-lualatex-simple.tex
run: |
docker run -v $(pwd)/test:/workdir localhost:5000/name/app:latest latexmk -pdflua 51-lualatex-simple.tex
- name: 51-lualatex-simple.tex (cache test)
run: |
set -e
output=$(docker run -v $(pwd)/test:/workdir localhost:5000/name/app:latest latexmk -pdflua 51-lualatex-simple.tex)
echo "$output"
echo "$output" | grep -qv "All targets are up-to-date" && exit 1
- name: Archive PDFs
uses: actions/upload-artifact@v4
with:
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-azuretools.vscode-docker"
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ We use letters instead of numbers to avoid confusion with the automatic builds s

Note that this version is continuously built based on [texlive/texlive](https://gitlab.com/islandoftex/images/texlive).

### Added

- All fonts are cached so that `latexmk` correctly determines whether it should re run. [#51](https://github.com/dante-ev/docker-texlive/issues/51)

## TeXLive 2024

### [2024-B] – 2025-02-13
Expand Down
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ENV LANG=C.UTF-8 \
ARG BUILD_DATE
ARG GITLATEXDIFF_VERSION=1.6.0

# Required at least for PlantUML below
WORKDIR /home

# Fix for update-alternatives: error: error creating symbolic link '/usr/share/man/man1/rmid.1.gz.dpkg-tmp': No such file or directory
Expand Down Expand Up @@ -67,7 +68,14 @@ RUN wget https://github.com/plantuml/plantuml/releases/download/v1.2025.0/plantu
rm plantuml.zip
ENV PLANTUML_JAR=/home/plantuml.jar

# update font index
RUN luaotfload-tool --update
# Create font cache
COPY load-fonts.tex /tmp/
RUN luaotfload-tool --update --force --no-compress && \
texhash && \
# This errors because of missing glyphs, but still populates the cache
cd /tmp && yes "" | lualatex load-fonts || true && \
# Needs to run twice according to https://tex.stackexchange.com/a/737059/9075
cd /tmp && yes "" | lualatex load-fonts || true && \
rm /tmp/load-fonts.*

WORKDIR /workdir
30 changes: 30 additions & 0 deletions load-fonts.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
% Source: https://tex.stackexchange.com/a/737059/9075

%! TeX program = lualatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{luacode}
\begin{document}

% based on https://tex.stackexchange.com/a/14171/9075
% based on @cfr's https://tex.stackexchange.com/a/737051/38080
% addaswyd yn ateb: https://tex.stackexchange.com/a/737051/
\begin{luacode}
myfonts = luaotfload.aux.read_font_index()
t={ myfonts, myfonts.families }
-- really? https://stackoverflow.com/questions/2705793/how-to-get-number-of-entries-in-a-lua-table
total = 0
for _,i in ipairs(myfonts.mappings) do
total = total + 1
end
n=0
for _,i in ipairs(myfonts.mappings) do
n = n + 1
-- if n > 100 then return 0 end -- be patient...
tex.print("\\ttfamily\\tiny\\detokenize{" .. myfonts.mappings[n].plainname .. "}: " ..
"\\font\\myfont = {file:" .. myfonts.mappings[n].basename .. "} at 14pt \\myfont \\detokenize{" ..
myfonts.mappings[n].plainname .. "}\\par\\smallskip")
tex.print("\\typeout{font " .. n .. " of " .. total .. "}")
end
\end{luacode}
\end{document}
6 changes: 6 additions & 0 deletions test/51-lualatex-simple.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\documentclass{article}
\usepackage{fontspec}
\setmainfont{QTGraphLite}
\begin{document}
Essai
\end{document}
Loading