% $Id: xfakebold.sty 820 2023-11-21 15:10:21Z herbert $
%%
%% This is file `xfakebold.sty', 
%%
%%   Copyright (C) 2019, ..., 2023  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
%%    https://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}[2023/11/21 v0.10 using bold characters]
\RequirePackage{xkeyval}
\RequirePackage{pdfrender}
\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][]{%
  \if$#1$\else
    \fkbld@checkboldness{#1}%
  \fi
  \ifxetex
    \special{pdf:literal direct 2 Tr \fkbld@bold\space w }\relax
  \else
    \ifluatex
      \pdfrender{TextRenderingMode=FillStroke,LineWidth=\fkbld@bold}%
    \else
      \ifpdftex
        \pdfrender{TextRenderingMode=FillStroke,LineWidth=\fkbld@bold}%
      \else
        \ifpdf
          \PackageWarning{fakebold}{!Unsupported engine! fakebold is disabled.}%
        \else
          \pdfrender{TextRenderingMode=FillStroke,LineWidth=\fkbld@bold}%
        \fi
      \fi
    \fi
  \fi
  \ignorespaces
}
\newcommand\unsetBold{%
  \ifxetex
    \special{pdf:literal direct 0 Tr 0 w }\relax
  \else
    \ifluatex
      \pdfrender{TextRenderingMode=Fill,LineWidth=0}%
    \else
      \ifpdftex
        \ifnum\pdfoutput=\@ne
          \pdfrender{TextRenderingMode=Fill,LineWidth=0}%
        \else
          \pdfrender{TextRenderingMode=Fill,LineWidth=0}%
        \fi
      \else
        \ifpdf\else
          \pdfrender{TextRenderingMode=Fill,LineWidth=0}%
        \fi
      \fi
    \fi
  \fi
  \ignorespaces
}

\endinput
