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
Font is not embedded when using tikzfadingfrompicture for color gradient on font glyphs #1315
Comments
It reproduces even with the (second) \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings,patterns}
\pagestyle{empty}
\begin{document}
\begin{tikzfadingfrompicture}[name=tikz]
\node [text=transparent!20]
{\fontencoding{T1}\fontfamily{ptm}\fontsize{45}{45}\bfseries\selectfont Ti\emph{k}Z};
\end{tikzfadingfrompicture}
\begin{tikzpicture}
\fill [black!20] (-2,-1) rectangle (2,1);
\pattern [pattern=checkerboard,pattern color=black!30]
(-2,-1) rectangle (2,1);
\shade[path fading=tikz,fit fading=false,left color=blue,right color=black]
(-2,-1) rectangle (2,1);
\end{tikzpicture}
\end{document}
|
The alternative way using knockout transparency group gives PDF with font(s) correctly embedded. But knockout group is not supported by some PDF readers, for example the popper-based built-in reader in editor TeXstudio. And when used inside % !TeX program = lualatex
\documentclass[a4paper,12pt]{report}
\usepackage{mwe}
\usepackage{fontspec}
\setmainfont{DejaVu Sans}
\newfontfamily\bgfont[Scale=1.0]{DejaVu Serif}
\usepackage{tikz}
\usetikzlibrary{backgrounds,fadings,patterns}
\AddToHook{shipout/background}{
\put (1.5in,-4.5in){%
\begin{tikzpicture}
\begin{scope}[transparency group=knockout]
\node [name=tikz, fill=white, text opacity=0, inner sep=2pt,
font=\fontsize{360}{360}\bgfont]
{T};
\end{scope}
\begin{scope}[on background layer={}]
\shade [left color=green, right color=blue, opacity=.4]
% make shading slightly smaller than node, to avoid thin lines
% rendered by some PDF readers
([shift={( 1pt, 1pt)}]tikz.south west) rectangle
([shift={(-1pt,-1pt)}]tikz.north east);
\end{scope}
\end{tikzpicture}%
}
}
\begin{document}
\blindtext
\end{document}
|
Checking directly the decompressed output PDF, I find the font used in Testing with other readers/tools,
Maybe the internal structure of output PDF is not strictly valid, or detection for embedded fonts in tools like This Example is based on #1315 (comment): \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\pagestyle{empty}
\begin{document}
ABC
\begin{tikzfadingfrompicture}[name=tikz]
\node [text=transparent!20]
{\fontencoding{T1}\fontfamily{ptm}\fontsize{45}{45}\bfseries\selectfont Ti\emph{k}Z};
\end{tikzfadingfrompicture}
\begin{tikzpicture}
\shade[path fading=tikz,fit fading=false,left color=blue,right color=black]
(-2,-1) rectangle (2,1);
\end{tikzpicture}
\end{document}
Full contents of corresponding 3 PDF objects
|
If I convert the original PDF produced by pdflatex with
then both
|
Brief outline of the bug
When using a tikzfadingfrompicture to render one or more font glyphs with a color gradient e.g. for a background watermark, the font used for rendering the text is not embedded in the produced PDF. This behaviour is independent of the engine (xelatex, or lualatex). When using a plain tikzpicture without tikzfadingfrompicture for the gradient, the font is embedded as expected, but when using tikzfadingfrompicture, the font is not embedded.
The lualatex shell output reveals that the necessity of the font is known at the pdf generation stage:
Nevertheless, the background font does not get embedded in the PDF:
A simple
$ gs -P- -dSAFER -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr -sOutputFile=test-fontembedding.full.pdf -dPDFSETTINGS=/prepress -dEmbedAllFonts=true test-fontembedding.pdf
will fix that, but should not be necessary. The output file should already have the font embedded.Otherwise it's dependent on the target system displaying the file if the watermark is shown (e.g. if the font is not present there and when using unicode glyphs that are not present in the default font).
Minimal working example (MWE)
The text was updated successfully, but these errors were encountered: