1

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

  • 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. – user139954 Nov 6 '17 at 0:18
3

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

0

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

  • 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 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.