5

The font, Kalpurush, doesn't have any Bold, Italic, BoldItalic etc. features in it.

\documentclass{article}
\usepackage{harfload, fontspec}
\setmainfont{Kalpurush}[RawFeature={mode=harf}]

\parindent 0pt
\begin{document}
    বাংলা  \textbf{বাংলা} \textit{বাংলা} \\
    English \textbf{English} \textit{English}
\end{document}

Setting it as mainfont removes the Bold, Italic, BoldItalic features from English as well. How can I make it Bold, Italic, BoldItalic? Does AutoFake wok with Luatex/Harftex?

Ulrike Fischer
  • 327,261
  • 1
    From the fontspec manual: »The FakeBold and AutoFakeBold features are only available with the XeTeX engine and will be ignored in LuaTeX.« – Henri Menke Jun 21 '19 at 04:24
  • I don't know if harf mode can embolden like you can do with xelatex. You could ask here https://github.com/khaledhosny/harf/issues. – Ulrike Fischer Jun 21 '19 at 06:50
  • @UlrikeFischer I'm pretty sure it can't. So it would have to be a feature request. – Marcel Krüger Jun 21 '19 at 06:58
  • @MarcelKrüger actually I don't think that this a harfbuzz "feature". I looked in the pdf from xelatex and it contains a literal Tf 2 Tr 0.300003 w which makes the font bolder. I asked once if the fontloader can do it too, but never got a real answer: https://www.mail-archive.com/ntg-context@ntg.nl/msg86408.html. – Ulrike Fischer Jun 21 '19 at 07:07
  • @UlrikeFischer It actually is implemented in modern LuaTeX versions (you can set 2 Tr by setting mode=2 in the fontdirectory and w through the width field of the font), so the missing thing to make it work with mode=harf is for the harf loader to set these entries in the font directory. The alternative would be to patch the font... – Marcel Krüger Jun 21 '19 at 07:27
  • @MarcelKrüger can you show me an example for the embolden in luatex? – Ulrike Fischer Jun 21 '19 at 07:33
  • 1
    @UlrikeFischer I added a branch embolden to my repo which implements a currently untested, but (hopefully) XeTeX compatible feature embolden to the fontloader. – Marcel Krüger Jun 21 '19 at 08:12
  • @MarcelKrüger that looks quite good, I will try to merge it in the afternoon and then run the testsuite. – Ulrike Fischer Jun 21 '19 at 08:20
  • @MarcelKrüger: Done for mode=harf. – خالد حسني Jun 21 '19 at 15:57

2 Answers2

3

Adding the font option AutoFakeBold and AutoFakeSlant should enable emboldened and slanted fonts with fonts that do not have bold and italic style.

This works with XeTeX:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Kalpurush}
[
  AutoFakeBold,
  AutoFakeSlant,
]

\parindent 0pt \begin{document} বাংলা \textbf{বাংলা} \textit{বাংলা} \ English \textbf{English} \textit{English} \end{document}

With LuaTeX and HarfTeX the AutoFakeBold option will cause a warning and will be ignored by fontspec (until this pull request is merged). A workaround is to do it manually BoldFeatures option:

\documentclass{article}
\usepackage{harfload, fontspec}
\setmainfont{Kalpurush}
[
  AutoFakeBold,
  AutoFakeSlant,
  BoldFeatures={RawFeature={embolden=1.5}},
  RawFeature={mode=harf},
]

\parindent 0pt \begin{document} বাংলা \textbf{বাংলা} \textit{বাংলা} \ English \textbf{English} \textit{English} \end{document}

(this requires the latest harfload package from its GitHub repository)

Gary Wang
  • 113
  • 6
3

With luahblatex (latex based on the engine luahbtex), luaotfload version 3.11 (uploaded 10.11.) (the version is needed so that Script=Bengali works correctly) and a current fontspec it works fine:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Kalpurush}[Renderer=Harfbuzz,Script=Bengali,AutoFakeSlant,AutoFakeBold]

\parindent 0pt
\begin{document}
    বাংলা  \textbf{বাংলা} \textit{বাংলা} \\
    English \textbf{English} \textit{English}
\end{document}

enter image description here How to install the luahbtex engine is described here: How to install HarfTeX on TeXLive?

Ulrike Fischer
  • 327,261