summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xfakebold/doc/xfakebold-doc.tex
blob: b60ab2531619fd1081976b1bbdbd84b3d8a540df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
% $Id: xfakebold-doc.tex 11 2020-06-24 06:56:41Z herbert $
\listfiles
\documentclass[english]{article}
\usepackage{dejavu-otf}
\usepackage{xfp,dtk-logos}
\ExplSyntaxOn
\let\PI\c_pi_fp
\ExplSyntaxOff
\usepackage{xfakebold}
\usepackage{graphicx}
%\pdfcompresslevel=0
\usepackage{babel}
\usepackage[a4paper,tmargin=1cm,bmargin=1.5cm,includeheadfoot]{geometry}
\usepackage{listings}
\title{\texttt{xfakebold}, v. 0.08\\ using bold characters with\\ \texttt{pdflatex}, \texttt{lualatex} or \texttt{xelatex}}
\author{Herbert Voß}

\lstset{basicstyle=\ttfamily\small,language={[LaTeX]TeX},frame=lrtb}
\begin{document}

\maketitle

\tableofcontents

\vspace{1cm}
\begin{abstract}
The package fakes a vector font with outline characters by the text render of PDF.
It writes directly into the pdf output with \verb|\pdfliteral| and  uses the colorstack package \texttt{pdfrender} to allow
boldness with a pagebreak inside the bold part.
%(pdflatex ) or \verb|\pdfextension| \verb|literal| 
%(lualatex) or \verb|\special| (xelatex). 
The package defines two macros which can be used in text and in math mode. However, for the text
mode one should use the bold version of the text font which should be available in most cases. This is different to the
math mode where only some free math fonts provide a bold version.
\end{abstract}

\vfill
\small Thanks to: Heiko Oberdiek; Scott Pakin, Will Robertson; Yusuke Terada;
%\meaning\setBold

%\meaning\unsetBold

\newpage

\section{\TeX-engines}
With \XeLaTeX\ you do not really need this package, because you can use the optional argument \texttt{AutoFakeBold} from
package \texttt{fontspec} or \texttt{unicode-math} which does the same internally. For Lua\TeX\ the option \texttt{AutoFakeBold} is only supported
by \texttt{unicode-math} for math typesetting. For pdf\LaTeX\ this package can be used for text and math.


\section{How does it work?}
PDF knows different text render modes for outline fonts.

\bigskip
\ifxetex\else% Only for the test run with xelatex

\def\OFF{\pdfrender{TextRenderingMode=Fill,LineWidth=0}}
\def\Verb|#1|{\texttt{\{#1\}}}

\makebox[3cm][l]{Mode 0 \Verb| 0 Tr 0 w |} \tabular{l}\pdfrender{TextRenderingMode=Fill}\scalebox{10}{OTTO} OTTO\OFF\endtabular

\makebox[3cm][l]{Mode 1 \Verb| 1 Tr 0 w |} \tabular{l}\pdfrender{TextRenderingMode=Stroke,LineWidth=0}\scalebox{10}{OTTO} OTTO\OFF\endtabular

\makebox[3cm][l]{Mode 1 \Verb| 1 Tr 0.3 w |} \tabular{l}\pdfrender{TextRenderingMode=Stroke,LineWidth=0.3}\scalebox{10}{OTTO} OTTO\OFF\endtabular

\makebox[3cm][l]{Mode 2 \Verb| 2 Tr 0 w |} \tabular{l}\pdfrender{TextRenderingMode=FillStroke,LineWidth=0}\scalebox{10}{OTTO} OTTO\OFF\endtabular

\makebox[3cm][l]{Mode 2 \Verb| 2 Tr 0.3 w |} \tabular{l}\pdfrender{TextRenderingMode=FillStroke,LineWidth=0.3}\scalebox{10}{OTTO} OTTO\OFF\endtabular
\fi

\bigskip
In mode 0 the character is filled but without drawing its outline which can be seen when printing in mode 1, where
the linewidth of the outline is the smallest one which the system allows. Setting the linewidth to 0.3\,bp, which is
nearly the same as 0.3\,pt, the linewidth of the outline increases. In mode 2 the character is printed with filling \emph{and}
drawing the outline, which is mode 0 and 1 together. The reason why the character is bold by default.  Increasing the linewidth 
makes it more bold.


\section{Optional package argument}
The only package option is \verb|bold| which is preset by 0.3, which is the linewidth of
the outlines of the characters.

\begin{lstlisting}
\usepackage[bold=0.6]{xfakebold}
\end{lstlisting}

makes the characters more bold.

\section{The macros}

\begin{lstlisting}
\setBold[<optional value>]
\unsetBold
\end{lstlisting}

Without using the optional argument the default setting is used.




\section{The example code}

The following examples use the value for $\pi$, defined in \LaTeX3 as \verb|\c_pi_fp|. To get rid of
the L3-syntax we define a new variable:

\begin{lstlisting}
\ExplSyntaxOn
\let\PI\c_pi_fp
\ExplSyntaxOff
\end{lstlisting}

\subsection{Default setting}
\begin{lstlisting}
\documentclass{article}
\usepackage{xfakebold,xfp}
\begin{document}
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\setBold\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\unsetBold\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$
\end{document}
\end{lstlisting}

\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\setBold\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\unsetBold\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$


\section{Loading the package with  another value}

\begin{lstlisting}
\documentclass{article}
\usepackage[bold=1]{xfakebold}
\usepackage{xfp}
\begin{document}
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\setBold\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\unsetBold\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$
\end{document}
\end{lstlisting}

\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\ifxetex\special{pdf:literal direct 2 Tr 1 w }%
\else\pdfrender{TextRenderingMode=FillStroke,LineWidth=1}\fi
\noindent 
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\ifxetex\special{pdf:literal direct 0 Tr 0 w }%
\else\pdfrender{TextRenderingMode=Fill,LineWidth=0}\fi
\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\section{Using the optional argument of the macro}

\begin{lstlisting}
\documentclass{article}
\usepackage{xfakebold,xfp}
\begin{document}
\setBold[0.01]\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\setBold[0.2]\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\setBold[0.6]\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$
\unsetBold

\setBold\noindent% Using the default value
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$
\unsetBold
\end{document}
\end{lstlisting}

\setBold[0.01]\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\setBold[0.2]\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$

\setBold[0.6]\noindent
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$
\unsetBold

\setBold\noindent% Using the default value
An example: 
$\pi^{\pi}=\fpeval{\PI^\PI}$ and
$\displaystyle\int\limits_1^{\infty}\frac1{x^2}\symup dx=1$
\unsetBold
\end{document}