1

I was trying the second and third solutions here error-using-fourierenc-with-koma-script-class-nobreakspace-unavailable-in-encod by @egreg which allows TeX Gyre Schola as text font. The last two give an error only with tex4ht.

-- error --- Can't find/open file `TeXGyreSchola:mode=base;script=latn;language=DFLT;.tfm'

My question is: Could TeX Gyre Schola be used as main text also with tex4ht?

Here is a MWE and the command used to compile it. It compiles OK in lualatex, but not with tex4ht in lua mode.

\documentclass[chapterprefix=false]{scrbook}
\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}

%commenting this block makes no difference, but was told to use this
%with tex4ht always, in luamode
\ifdefined\HCode
    \usepackage[utf8]{luainputenc}
\fi 

%see https://tex.stackexchange.com/questions/329855/error-using-fourierenc-with-koma-script-class-nobreakspace-unavailable-in-encod
\usepackage{unicode-math}
\setmainfont{TeX Gyre Schola}[Scale=0.95]
\setmathfont{TeX Gyre Schola Math}[Scale=0.95]

\begin{document}    
\chapter{test}

test Münchener-Straße $a+b=\sum_{i=1}^n x_i\sin y$

\end{document}

Now make4ht --lua -u foo.tex gives

.....
This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
......
tex4ht.c (2012-07-25-19:36 kpathsea)
tex4ht -cmozhtf 
  -utf8 
  foo 
(/usr/local/texlive/2016/texmf-dist/tex4ht/base/unix/tex4ht.env)
(/usr/local/texlive/2016/texmf-dist/tex4ht/ht-fonts/mozilla/charset/unicode.4hf)
sh: 1: .tfm: not found
.....
----------------------------------------------------
--- error --- Can't find/open file `TeXGyreSchola:mode=base;script=latn;language=DFLT;.tfm'
Make4ht: Fatal error. Command tex4ht returned exit code 256

Similarly with the second solution given in the linked to answer:

\documentclass[chapterprefix=false]{scrbook}
\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}

%commenting this block makes no difference
\ifdefined\HCode
    \usepackage[utf8]{luainputenc}
\fi 

%see https://tex.stackexchange.com/questions/329855/error-using-fourierenc-with-koma-script-class-nobreakspace-unavailable-in-encod
\usepackage{fouriernc}  % for math
\usepackage[no-math]{fontspec}
\setmainfont{TeX Gyre Schola}[Scale=0.95]

\begin{document}    
\chapter{test}

test Münchener-Straße $a+b=\sum_{i=1}^n x_i\sin y$

\end{document}

make4ht --lua -u foo.tex gives

ex4ht.c (2012-07-25-19:36 kpathsea)
tex4ht -cmozhtf 
  -utf8 
  foo1 
(/usr/local/texlive/2016/texmf-dist/tex4ht/base/unix/tex4ht.env)
(/usr/local/texlive/2016/texmf-dist/tex4ht/ht-fonts/mozilla/charset/unicode.4hf)
(/usr/local/texlive/2016/texmf-dist/fonts/tfm/public/fourier/fourier-mex.tfm)
--- warning --- Couldn't find font `fourier-mex.htf' (char codes: 33--232)

So now I am using this solution below, which do not use Tex Gyre for tex when compiling with tex4ht and this now works in both lualatex and tex4ht

\documentclass[chapterprefix=false]{scrbook}
\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}

\usepackage{fouriernc}

\ifdefined\HCode 
  \usepackage[utf8]{luainputenc}
\else
  \usepackage[no-math]{fontspec}
  \setmainfont{TeX Gyre Schola}[Scale=0.95]
\fi

\begin{document}

\chapter{test}

test Münchener-Straße $a+b=\sum_{i=1}^n x_i\sin y$

\end{document}
Nasser
  • 20,220
  • @cfr I was told to use luainputenc with make4ht in lua mode and see it mentioned in number of answers. Please see for example this and this. So now with TL 2016, I always include it, for tex4ht only, when I compile. I really know very little about fonts and how they work. I just try to follow instructions :) – Nasser Sep 17 '16 at 01:59
  • @cfr thank you. Ok, I really get confused with font and do not know when to use which and where. There should be a simple to read introduction to fonts for newbies. Fonts in Latex has always been very confusing to me. But thanks again for the info. Ok, so this can't be done. No problem. Should I close this question, or do you like to answer it and put your comments there if you think this will be useful for others? – Nasser Sep 17 '16 at 02:19
  • I've converted my comments to an answer. – cfr Sep 17 '16 at 02:30
  • There probably can't be a simple to read introduction to fonts for newbies. The whole topic is anything but simple, unfortunately. – cfr Sep 17 '16 at 02:31

1 Answers1

4

michal.h21's answers to your two previous questions after changing to \usepackage{fontspec} now make4ht do not compile my Latex file in lualatex mode and tex4ht scrambles some Matlab code when using mcode package clearly states the problem: TeX4ht cannot handle opentype fonts when converting from DVI to HTML.

The convertor [sic] from DVI to HTML doesn't support OpenType fonts, which is automatically selected when the Fontspec package is loaded. This is [a] well known tex4ht bug and also [the?] one which is hardest to fix (here).

As this also states, this means that you cannot use fontspec or, therefore, unicode-math. Instead, you need to stick to traditional TeX fonts and traditional encodings.

To do this, you need to tell LuaTeX how to manage them. This is what

\usepackage{luainputenc}

does.

None of this says you cannot use TeX Gyre Schola. But you cannot use the opentype version. Since it is also supported as a traditional TeX font with TFM files to support the PFB files, you can load it when creating the DVI. Whether that translates into something meaningful in the HTML I do not know.

luainputenc allows you to use these fonts. For example,

\usepackage[T1]{fontenc}
\usepackage{tgschola}

or whatever. tgschola loads TeX Gyre Schola with traditional TeX support. That is, it uses the relevant TFM files to create the DVI. These are designed to support the type1 PFB postscript versions of the fonts.

However, as I say, I do not know whether this will make a difference to the display of your HTML document. This depends on the handling of the fonts in the conversion from DVI to HTML. As far as I could tell, loading tgschola made no difference to the generated HTML font configuration. However, I don't know much about HTML, so I may be mistaken about this.

cfr
  • 198,882