Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
run: venv/bin/ruff check --output-format=github
- name: Check ruff formatting
run: venv/bin/ruff format --check --diff
- name: Install lualatex (temporary, until githubci docker image is updated)
run: |
apt-get update
apt-get install fonts-cmu fonts-noto-color-emoji texlive-luatex
- name: Test with pytest
run: venv/bin/pytest
- name: Run mypy
Expand All @@ -53,6 +57,10 @@ jobs:
- name: Build debian packages
run: |
make builddeb
- name: Install lualatex (temporary, until githubci docker image is updated)
run: |
apt-get update
apt-get install fonts-cmu fonts-noto-color-emoji texlive-luatex
- name: Install debian package
run: dpkg -i ../kattis-problemtools_*.deb
- name: Verify examples
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ The dependencies needed to *build/install* problemtools can be installed with:

And the dependencies needed to *run* problemtools can be installed with:

sudo apt install ghostscript pandoc python3 texlive-fonts-recommended texlive-lang-cyrillic texlive-latex-extra texlive-plain-generic tidy dvisvgm
sudo apt install ghostscript pandoc python3 texlive-fonts-recommended texlive-latex-extra texlive-luatex texlive-plain-generic tidy dvisvgm

To render problem statements to pdf with non-latin characters, also add the following fonts:

sudo apt install fonts-cmu fonts-noto-color-emoji

### Fedora

Expand Down
4 changes: 3 additions & 1 deletion admin/docker/Dockerfile.runreqs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean && \
apt-get update && apt-get install -y \
dvisvgm \
fonts-cmu \
fonts-noto-color-emoji \
ghostscript \
libgmp-dev \
pandoc \
python3 \
python3-venv \
texlive-fonts-recommended \
texlive-lang-cyrillic \
texlive-latex-extra \
texlive-luatex \
texlive-plain-generic \
tidy
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Homepage: https://github.com/Kattis/problemtools

Package: kattis-problemtools
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, pandoc, python3, texlive-plain-generic, texlive-fonts-recommended, texlive-latex-extra, texlive-lang-cyrillic, tidy, ghostscript, dvisvgm
Depends: ${shlibs:Depends}, ${misc:Depends}, pandoc, python3, texlive-plain-generic, texlive-fonts-recommended, texlive-latex-extra, texlive-luatex, tidy, ghostscript, dvisvgm, fonts-cmu, fonts-noto-color-emoji
Recommends: gcc, g++
Description: Kattis Problem Tools
These are tools to manage and verify problem packages in the
Expand Down
4 changes: 2 additions & 2 deletions problemtools/problem2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ def latex2pdf(options: argparse.Namespace, statement_file: Path) -> bool:
origcwd = os.getcwd()

os.chdir(texfile.parent)
params = ['pdflatex', '-interaction=nonstopmode']
params = ['lualatex', '--interaction=nonstopmode']
output = None
if options.quiet:
output = open(os.devnull, 'w')
if options.nopdf:
params.append('-draftmode')
params.append('--draftmode')

params.append(str(texfile.name))

Expand Down
26 changes: 21 additions & 5 deletions problemtools/templates/latex/problemset.cls
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
\RequirePackage{times} % Font choice
\RequirePackage{amsmath} % AMS
\RequirePackage{amssymb} % AMS
\RequirePackage[OT2,T1]{fontenc} % Cyrillic and standard % TODO: make alphabet options more general
\RequirePackage[utf8]{inputenc} % UTF-8 support
\RequirePackage{fancyhdr} % Headers
\RequirePackage{graphicx} % Graphics
\RequirePackage{subfigure} % Subfigures
Expand All @@ -55,6 +53,24 @@
\ifplastex\else
\RequirePackage{xstring}
\RequirePackage{pgffor}
% I do not understand how to do font handling well in a portable way in
% lualatex. The default font seems to only have latin characters. If we
% try to load a font which is not installed, rendering fails, which makes
% problem2pdf and verifyproblem unhappy. After a lot of trial-and-error,
% I ended up with this conditional loading of fonts (so we should degrade
% gracefully when fonts are missing). Getting the emoji font to work was weird,
% as apparently we need to define the fallback using lua code because the font
% uses colors.
\RequirePackage{fontspec}
\RequirePackage{luacode}
\IfFontExistsTF{CMU Serif}{
\IfFontExistsTF{NotoColorEmoji}{
\directlua{luaotfload.add_fallback("myfallback", {"NotoColorEmoji:mode=harf;"})}
\setmainfont{CMU Serif}[RawFeature={fallback=myfallback}]
}{
\setmainfont{CMU Serif}
}
}{}
\fi

%% Commands used to set name, logo, etc of contest
Expand Down Expand Up @@ -291,8 +307,8 @@

\newcommand{\sampletable}[4]{
% First find widths of the two files
\savebox{\PS@sampleinbox}{\lstinputlisting[inputencoding=utf8/latin1,basicstyle=\ttfamily]{#2}}
\savebox{\PS@sampleoutbox}{\lstinputlisting[inputencoding=utf8/latin1,basicstyle=\ttfamily]{#4}}
\savebox{\PS@sampleinbox}{\lstinputlisting[inputencoding=utf8,basicstyle=\ttfamily]{#2}}
\savebox{\PS@sampleoutbox}{\lstinputlisting[inputencoding=utf8,basicstyle=\ttfamily]{#4}}
\settowidth{\PS@sampleoutwidth}{\usebox{\PS@sampleoutbox}}
\settowidth{\PS@sampleinwidth}{\usebox{\PS@sampleinbox}}
\setlength{\PS@sampletotwidth}{\PS@sampleinwidth}
Expand Down Expand Up @@ -369,7 +385,7 @@
\hline
\parbox[t]{0.55\textwidth}{
\vspace{-0.49cm}
\lstinputlisting[inputencoding=utf8/latin1,basicstyle=\ttfamily]{\jobname.pstmp}
\lstinputlisting[inputencoding=utf8,basicstyle=\ttfamily]{\jobname.pstmp}
\vspace{-0.21cm}
}\\
\hline
Expand Down