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

Support for TrueType fonts? #9

Closed
EvyBongers opened this issue Feb 2, 2019 · 6 comments
Closed

Support for TrueType fonts? #9

EvyBongers opened this issue Feb 2, 2019 · 6 comments

Comments

@EvyBongers
Copy link

Not quite sure if this is the right place to ask.

I'm currently trying to build a document in which I use Carlito as main font.

\usepackage{fontspec}

\setmainfont{Carlito}

I used to build this document with lualatex installed on my local system and recently switched to using bazel-latex. The switch went perfectly fine.

Today I attempted to build the same repository (updated to add bazel-toolchains) with bazel-buildbarn. When doing this, the build exists with an error.

ERROR: /network/nas/documents/work/cv/BUILD.bazel:3:1: LuaLatex curriculum_vitae.pdf failed (Exit 1)
cv.tex:9: error: [fontspec] "font-not-found"
      at \setmainfont{Carlito}
cv.tex:9: error: [fontspec] "font-not-found"
      at \setmainfont{Carlito}
cv.tex:9: error: [fontspec] "font-not-found"
      at \setmainfont{Carlito}
cv.tex:9: error: Font \TU/Carlito(0)/m/n/10=Carlito:mode=node;+tlig; at 10pt not loadable: metric data not found or bad
      at <to be read again>
    from \setmainfont{Carlito}

I attempted to solve the problem by adding the relevant *.ttf files to srcs, but this doesn't make a difference.

Is the use of custom fonts currently supported by bazel-latex?

@mickael-carl
Copy link
Contributor

You will likely need to specify the full path to the font, e.g.:

\setmainfont[
    Path = ./,
    Extension = .ttf,
    Ligatures = TeX,
    BoldFont = Carlito-Bold,
    ItalicFont = Carlito-Italic,
]{Carlito-Regular}

and in your BUILD.bazel file:

latex_document(
    name = "foo",
    main = "main.tex",
    srcs = "glob(["*.ttf"]) + [
        ... other dependencies go here ....
    ],
)

Provided you copied the TTFs in your project. Can you give this a try? I just gave it a shot and it seemed to have worked for me.

@EvyBongers
Copy link
Author

It works, thanks! Provided, I set path like Path = fonts/, since I keep the fonts in a subdirectory.

@EdSchouten
Copy link
Contributor

Hmmm... Interesting. I can get the following document to build out of the box, only depending on //packages:fontspec:

\documentclass{report}
\usepackage{fontspec}
\setmainfont{Carlito}
\begin{document}
\chapter{This is a chapter}
\section{This is a section}
\textbf{This} \textit{document} uses Carlito!
\end{document}

@mickael-carl
Copy link
Contributor

Same for me now with the font globally installed. Though I do wonder if relying on system font is a good idea.

@EvyBongers
Copy link
Author

Does that example work when building against buildbarn-docker? I have the font globally installed, but the build failed as soon as I attempt to build it against the cluster. I'm assuming that this is because the font isn't installed on the build images.

Then again, even when building locally, I'd say that bazel-latex shouldn't rely on system-installed fonts. This kills reproducability.

@EdSchouten
Copy link
Contributor

Oh, wait. I didn't test this against Buildbarn; just a direct build. Will try to figure out why this breaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants