% $Id: xfakebold.sty 1125 2019-12-29 21:34:19Z herbert $
%%
%% This is file `xfakebold.sty', 
%%
%%   Copyright (C) 1919, 2020  Herbert Voss
%% 
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xfakebold}[1919/12/29 v0.06 using bold characters]
\RequirePackage{xkeyval}

\@ifpackagelater{iftex}{2019/10/24}{% 
  \RequirePackage{ifxetex,ifluatex,ifpdf}
}{%
  \RequirePackage{iftex}
}

\def\fkbld@bold{0.3 }%

\def\fkbld@checkboldness#1{%
  \ifdim#1pt > \z@
    \def\fkbld@bold{#1 }%
  \else 
    \PackageWarning{fakebold}{The value must be greater than 0. Will choose 0.3 instead!}%
    \def\fkbld@bold{0.3 }%
  \fi
}

\DeclareOptionX{bold}{\fkbld@checkboldness{#1}}

\ProcessOptionsX*

\newcommand\setBold[1][]{%
  \begingroup
  \if$#1$\else
    \fkbld@checkboldness{#1}%
  \fi
  \ifxetex
    \special{pdf:literal direct 2 Tr \fkbld@bold w }\relax
  \else
    \ifluatex
      \pdfextension literal direct { 2 Tr \fkbld@bold w }\relax
    \else
      \ifpdftex
        \ifnum\pdfoutput=\@ne
          \pdfliteral direct { 2 Tr #1 w }\relax
        \else
          \special{pdf:literal direct 2 Tr \fkbld@bold w }\relax
        \fi
      \else
        \ifpdf
          \PackageWarning{fakebold}{!Unsupported engine! fakebold is disabled.}
        \else
          \special{pdf:literal direct 2 Tr \fkbld@bold w }\relax
        \fi                  
      \fi
    \fi
  \fi
  \endgroup
  \ignorespaces
}
\newcommand\unsetBold{%
  \ifxetex
    \special{pdf:literal direct 0 Tr 0 w }\relax
  \else
    \ifluatex
      \pdfextension literal direct { 0 Tr 0 w }\relax
    \else
      \ifpdftex
        \ifnum\pdfoutput=\@ne
          \pdfliteral direct { 0 Tr 0 w }\relax
        \else
          \special{pdf:literal direct 0 Tr 0 w }\relax
        \fi
      \else
        \ifpdf
        \else
          \special{pdf:literal direct 0 Tr 0 w }\relax
        \fi                  
      \fi
    \fi
  \fi
  \ignorespaces
}

\endinput
