Aleph

Marcel Fabian Krüger tex at 2krueger.de
Wed Oct 16 11:52:45 CEST 2019


Hi Norbert,


On Wed, Oct 16, 2019 at 06:15:13PM +0900, Norbert Preining wrote:
> @Ulrike
> > To use harf you must declare the mode when loading the font. And as I
> > saw yesterday it is also necessary to correctly declare the script:
> > \setmainfont{Noto Sans Tibetan}[RawFeature={mode=harf;script=tibt;}]
> 
> Is this necessary for harf(la)tex only I guess? I tried it with luahbtex
> and it made everything worse.

While I am not entirely sure, I think you are trying to use `luahbtex`
with regular luaotfload versions (which do not include `mode=harf` yet)
and without loading the older `harf` code from Khaled. Then `mode=harf`
is not available and `luahbtex` behaves exactly like `luatex`. If you
specify `mode=harf` in that situation, you select a non-existing
mode, so you effectivly disable all shaping, leading to bad output.

So `mode=harf` should only be added when the `dev` version of luaotfload
is used in HarfBuzz engines. The difference between HarfTex and LuaHBTeX
is not important here.

> 
> For both of you - is there a way to distinguish between
> luatex/luahbtex/harftex?
> 
> I use
> \newfontface{\tibNoto}[Script=Tibetan]{Noto Serif Tibetan}
> \newfontface{\tibDDC}[Script=Tibetan]{DDC-Uchen.ttf}
> \newfontface{\tibJom}[Script=Tibetan]{Jomolhari.ttf}
> \ifXeTeX
>   \def\prog{Xe\LaTeX}
> \else
>   \ifLuaTeX
>     % check for harftex
>     \if1\directlua{if luaharfbuzz == nil then tex.print("1") else tex.print("2") end}
>       \def\prog{Lua\TeX}
>       \message{USING LUATEX CODE}
>     \else
>       \def\prog{LuaHB\LaTeX\ or Harf\LaTeX}
>       \message{USING LUAHBTEX OR HARFTEX CODE}
>       \renewfontface{\tibNoto}[RawFeature={mode=harf;script=tibt;}]{Noto Serif Tibetan}
>       \renewfontface{\tibDDC}[RawFeature={mode=harf;script=tibt;}]{DDC-Uchen.ttf}
>       \renewfontface{\tibJom}[RawFeature={mode=harf;script=tibt;}]{Jomolhari.ttf}
>     \fi
>   \fi
> \fi
> 
> Is there a better way, and can we distinguish between harftex and
> luahbtex?
> 

This works great for distinguishing between HarfBuzz and non-HarfBuzz
LuaTeX variants. Of course you do not catch if the necessary luaotfload
support exists, so you might prefer to check `luaotfload.harfbuzz` which
is only defined if `mode=harf` can be used:

\newfontface{\tibNoto}[Script=Tibetan]{Noto Serif Tibetan}                     
\newfontface{\tibDDC}[Script=Tibetan]{DDC-Uchen.ttf}                           
\newfontface{\tibJom}[Script=Tibetan]{Jomolhari.ttf}               
\ifXeTeX                                                           
  \def\prog{Xe\LaTeX}
\else
  \ifLuaTeX
    % check for harftex and compatible Lua support
    \if1\directlua{if luaotfload.harfbuzz then tex.print("2") else tex.print("1") end}
      \def\prog{Lua\TeX}                      
      \message{USING LUATEX CODE}             
    \else                                     
      \def\prog{LuaHB\LaTeX\ or Harf\LaTeX}
      \message{USING LUAHBTEX OR HARFTEX CODE}
      \renewfontface{\tibNoto}[RawFeature={mode=harf;script=tibt;}]{Noto Serif Tibetan}
      \renewfontface{\tibDDC}[RawFeature={mode=harf;script=tibt;}]{DDC-Uchen.ttf}
      \renewfontface{\tibJom}[RawFeature={mode=harf;script=tibt;}]{Jomolhari.ttf}
    \fi                                                                       
  \fi                                                                         
\fi

I don't think that there is a important use-case for distinguishing
harftex and luahbtex anymore. HarfTeX currently is deprecated and
doesn't behave differently than LuaHBTeX from a user perspective. 

But if you still want to, you can use `status.luatex_engine` to get the
name of the engine:

\ifcase\directlua{tex.write(({harftex = 2, luatex = 0, luahbtex = 1})[status.luatex_engine] or 3)}
  Lua%
\or
  LuaHB%
\or
  Harf%
\else
  ???%
\fi
\TeX


Marcel


More information about the tex-live mailing list