dalibo / pandocker

🐳 A simple docker image for pandoc with filters, templates, fonts, and the latex bazaar
https://hub.docker.com/r/dalibo/pandocker/
BSD 3-Clause "New" or "Revised" License
143 stars 23 forks source link

Add Adobe's open source Source fonts #268

Closed colindean closed 1 year ago

colindean commented 1 year ago

Is your feature request related to a problem? Please describe.

I've come to really prefer Source family for the docs I write.

https://github.com/adobe-fonts/source-code-pro

https://github.com/adobe-fonts/source-serif

https://github.com/adobe-fonts/source-sans

Describe the solution you'd like

I'd love for these fonts to be included in pandocker so I don't have to add them manually.

Describe alternatives you've considered

I could bake an image on top of pandocker or continue injecting them through mounts.

colindean commented 1 year ago

N.b. it's not on Debian or Ubuntu packages, but it is SIL OFL 1.1 like Liberation and many other fonts.

daamien commented 1 year ago

Hi !

Those fonts should be inside the image.

this image is now based on the pandoc/extra image and pandoc/extra does contains the sourcesanspro and sourcecodepro latex packages.

See https://github.com/pandoc/dockerfiles/blob/master/common/extra/packages.txt#L44

Can you provide an example ( file and command line ) and the error you get ?

colindean commented 1 year ago

Looks like Source Serif Pro is missing from that list. Proposed in https://github.com/pandoc/dockerfiles/pull/205.

colindean commented 1 year ago

I'm pretty sure that sourceserifpro is available now, and for good measure, I added it to the tlmgr invocation in my build:

$ tlmgr install draftwatermark glossaries sourceserifpro
tlmgr: package repository https://ctan.math.utah.edu/ctan/tex-archive/systems/texlive/tlnet (verified)
tlmgr install: package already present: draftwatermark
tlmgr install: package already present: glossaries
tlmgr install: package already present: sourceserifpro

And then it fails, seemingly indicating that it can't find the font:

$ make -j all
pandoc \
    --defaults config.yaml \
    0000_introduction.md 0001_contributors.md 0010_about_codeandsupply.md 0050_sponsors.md 0051_get_involved.md 0080_changelog.md 0090-transparency.md 0090_conventions.md 0091_notes_about_data.md 0100_quick_takeaways.md 0101-basic_salary.md 0200_compensation.md 0201_years_of_experience.md 0300_managers.md 0350_gender_wage_gap.md 0450_job_changes_interviewing.md 0500_current_emp_arrangements.md 0700_living_and_commuting.md 0775_learn_skills.md 0800_previous_results.md 0999-colophon.md \
    -o _codeandsupply_compensation_survey_results_2022.pdf \
    -M "date=v built April 25, 2023 02:46:51 UTC" \
    --bibliography refs.bibtex
[WARNING] Could not fetch resource : replacing image with description
[WARNING] Could not fetch resource : replacing image with description
[WARNING] Could not fetch resource : replacing image with description
kpathsea: Running mktextfm sourceserifpro
/opt/texlive/texdir/texmf-dist/web2c/mktexnam: Could not map source abbreviation  for sourceserifpro.
/opt/texlive/texdir/texmf-dist/web2c/mktexnam: Need to update ?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input sourceserifpro
This is METAFONT, Version 2.71828182 (TeX Live 2023) (preloaded base=mf)
kpathsea: Running mktexmf sourceserifpro
! I can't find file `sourceserifpro'.
<*> ...mag:=1; ; nonstopmode; input sourceserifpro

Please type another input file name
! Emergency stop.
<*> ...mag:=1; ; nonstopmode; input sourceserifpro

Transcript written on mfput.log.
grep: sourceserifpro.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input sourceserifpro' failed to make sourceserifpro.tfm.
kpathsea: Appending font creation commands to missfont.log.
kpathsea: Running mktextfm sourceserifpro
/opt/texlive/texdir/texmf-dist/web2c/mktexnam: Could not map source abbreviation  for sourceserifpro.
/opt/texlive/texdir/texmf-dist/web2c/mktexnam: Need to update ?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input sourceserifpro
This is METAFONT, Version 2.71828182 (TeX Live 2023) (preloaded base=mf)
kpathsea: Running mktexmf sourceserifpro
! I can't find file `sourceserifpro'.
<*> ...mag:=1; ; nonstopmode; input sourceserifpro

Please type another input file name
! Emergency stop.
<*> ...mag:=1; ; nonstopmode; input sourceserifpro

Transcript written on mfput.log.
grep: sourceserifpro.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input sourceserifpro' failed to make sourceserifpro.tfm.
kpathsea: Appending font creation commands to missfont.log.
kpathsea: Running mktextfm sourceserifpro
/opt/texlive/texdir/texmf-dist/web2c/mktexnam: Could not map source abbreviation  for sourceserifpro.
/opt/texlive/texdir/texmf-dist/web2c/mktexnam: Need to update ?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input sourceserifpro
This is METAFONT, Version 2.71828182 (TeX Live 2023) (preloaded base=mf)
kpathsea: Running mktexmf sourceserifpro
! I can't find file `sourceserifpro'.
<*> ...mag:=1; ; nonstopmode; input sourceserifpro

Please type another input file name
! Emergency stop.
<*> ...mag:=1; ; nonstopmode; input sourceserifpro

Transcript written on mfput.log.
grep: sourceserifpro.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input sourceserifpro' failed to make sourceserifpro.tfm.
kpathsea: Appending font creation commands to missfont.log.
Error producing PDF.
! Package fontspec Error: The font "sourceserifpro" cannot be found.
For immediate help type H <return>.
 ...                                              

l.24   \setsansfont
make: *** [Makefile:37: codeandsupply_compensation_survey_results_2022.pdf] Error 43

Relevant sections of config.yml:

pdf-engine: xelatex
variables:
  fontfamily: 'sourceserifpro'
  mainfont: 'sourceserifpro'
  sansfont: 'sourcesanspro'
  monofont: 'sourcecodepro'

and, for good measure, the relevant stage in my .gitlab-ci.yaml:

build-report:
  needs: ["run-notebooks"]
  stage: report
  image:
    name: dalibo/pandocker:stable
    entrypoint: [""]
  variables:
    DEBIAN_FRONTEND: noninteractive
  before_script:
    # updates tlmgr database
    - time tlmgr update --self
    # install some packages that at some point weren't pre-packaged but now may be
    - time tlmgr install draftwatermark glossaries sourceserifpro
    # install something to manipulate PDFs
    - time apt-get update --yes && time apt-get install --yes --no-install-recommends pdftk
    - cd report
  script:
    # list all of the resolved input files and output file
    - time make list-all
    # DO IT
    - time make -j all
  artifacts:
    paths:
      - "report/codeandsupply_compensation_survey_results*.pdf"
      - "report/buildlog.json"
colindean commented 1 year ago

Interestingly, I am able to get the above to build on one machine but not on another, and the other is one I'm on right now. Same error. But, it's using an ancient TeXLive distribution (2020!) with no ability to change that through the OS pkg manager... so I am installing TeXLive 20230313 through Homebrew but it'll take overnight on crappy hotel WiFi...

colindean commented 1 year ago

Didn't work, even after installing a new TeXLive and installing the sourceserifpro package through it on my Chromebook's Linux completely outside of Pandocker, so there must be something else going on.

[21:11:10 colin@penguin ~/Source/codeandsupply/comp-survey-2022-results ]
± (source-font) $ tlmgr --usermode update --self
tlmgr: package repository https://mirror.mwt.me/ctan/systems/texlive/tlnet (not verified: pubkey missing)
tlmgr: no self-updates for tlmgr available
[21:12:06 colin@penguin ~/Source/codeandsupply/comp-survey-2022-results ]
± (source-font) $ tlmgr --usermode install sourceserifpro
tlmgr: package repository https://mirror.mwt.me/ctan/systems/texlive/tlnet (not verified: pubkey missing)
[1/1, ??:??/??:??] install: sourceserifpro [3588k]
running mktexlsr ...
done running mktexlsr.
running updmap-user ...
done running updmap-user.

Then the ~same error as above.

I'll continue to troubleshoot.

colindean commented 1 year ago

I ended up fixing it by switching from xelatex to lualatex for the pdf-engine option. I don't think I was using anything specific to xelatex so this is an acceptable out for me.