% $Id: xfakebold.sty 793 2018-08-06 16:39:25Z herbert $
%%
%% This is file `xfakebold.sty', 
%%
%%   Copyright (C) 2018  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.
%% 
%%
\ProvidesPackage{xfakebold}[2018/08/21 v0.04 using bold characters]
\RequirePackage{ifluatex,ifxetex,xkeyval}

\def\setBold{}
\def\unsetBold{}
\def\fake@bold{0.3}%

\DeclareOptionX{bold}{%
  \def\fake@bold{#1}% 
  \ifdim\fake@bold pt > \p@
  \else 
    \PackageWarning{fakebold}{The value must be greater than 0. Will chooose 0.3}%
    \def\fake@bold{0.3}%
  \fi}

\ProcessOptionsX

\ifxetex
  \typeout{We have XeTeX}% 
  \PackageWarning{fakebold}%
  {^^J    No LuaTeX or PDFTeX running!
   ^^J    For Xe(La)TeX use the FakeBold option from package fontspec!
   \def\fake@bold{-1}}%
\fi

\ifluatex
    \def\setBold{\pdfextension literal direct { 2 Tr \fake@bold\space w }\relax}
    \def\unsetBold{\pdfextension literal direct { 0 Tr 0 w }\relax}
    \typeout{We have LuaTeX}% 
\else
  \ifdim\fake@bold pt < \p@ \else
    \def\setBold{\pdfliteral direct { 2 Tr \fake@bold\space w }\relax}
    \def\unsetBold{\pdfliteral direct { 0 Tr 0 w }\relax}
    \typeout{We have pdfTeX}% 
  \fi
\fi

