2

The font I am using doesn't have a semibold weights.

I would like to fake a bold font that has a similar width to the regular font.

I tried using this approach from https://tex.stackexchange.com/a/23691/41036:

\newsavebox\CBox
\def\textBF#1{\sbox\CBox{#1}\resizebox{\wd\CBox}{\ht\CBox}{\textbf{#1}}}

It works very well for single words, however doesn't allow line-breaks etc.

How can I redefine this command to use it for longer expressions, most preferably like I would usually use \bfseries (e.g., by defining a new command like \bfsemiseries)?

Kindest regards, Mil

Mil
  • 1,197
  • It is not too difficult to take a font, and create a semibold font, using FontForge. Menu Element > Style > Change Weight, maybe 10 units. If the font has a lot of glyphs but you are only using a small portion of them, then you can limit the change to only the used characters. This assumes that you have a suitable font license. –  Nov 06 '17 at 00:18

2 Answers2

6

You can't extend this command. But you can use a pdfliteral (assuming that you use pdflatex):

\documentclass[]{article}
\newcommand{\textBF}[1]{%
    \pdfliteral direct {2 Tr 0.3 w} %the second factor is the boldness
     #1%
    \pdfliteral direct {0 Tr 0 w}%
}

\usepackage{lipsum}

\begin{document}
some text 

\textBF{some text}

\textbf{some text}

\lipsum[1]

\textBF{\lipsum[1]}
\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • According to the answer to this related question https://tex.stackexchange.com/questions/102578/fake-bold-in-lualatex/102706#102706 the thickened font may look OK on screen, but not necessarily when printed to paper. Perhaps it is a matter of expectations? –  Nov 06 '17 at 03:23
2

The fontspec package supports the FakeBold font option. You can either use \newfontfamily\somefamily{Some Font}[FakeBold=1.2] or \addfontfeature{FakeBold=1.2} (or whatever number you prefer, but normal weight is 1.0 and a typical value for bold is 1.5).

If you want to add a semibold weight that you can select with commands such as \sbseries and \textsb{}, here is an example:

\documentclass[varwidth, preview]{standalone}
\usepackage{fontspec}

\setmainfont{DejaVuSerif}[
  Scale = 1.0,
  Ligatures = {Common, Discretionary, TeX},
  UprightFont = * ,
  BoldFont = *-Bold ,
  ItalicFont = *-Italic ,
  BoldItalicFont = *-BoldItalic ,
  FontFace = {sb}{n}{ Font={*}, FakeBold = 1.2 },
  FontFace = {sb}{it}{ Font={*-Italic}, FakeBold = 1.2 },
  Extension = .ttf
]

% The commands to select semibold weight:
\DeclareRobustCommand{\sbseries}{\fontseries{sb}\selectfont}
\DeclareTextFontCommand{\textsb}{\sbseries}

\begin{document}

DejaVu \textit{Serif} \\
\textbf{Bold \textit{Italic}} \\
\textsb{\textit{Fake} Semibold} 

\end{document}

DejaVu Serif Sample

Davislor
  • 44,045
  • I found that FakeBold=1.0, when applied to regular weight, actually produced bolder text. However, FakeBold=0.0 seems to be the actual “normal weight”. Unfortunately the XeTeX manual doesn’t explain how embolden works, but I think it is additive rather than multiplicative as you stated. – Ruixi Zhang Jan 30 '19 at 18:28
  • Awesome option. By the way, AutoFakeBold is even better since it only affects \textbf-embedded text. See this post: https://tex.stackexchange.com/a/569750/262813. – Vincent Krebs Jan 15 '23 at 02:30