8

I stumbled across a continuation of a problem that seemed to have been fixed at tex.stackexchange.com/questions/162626/, but the problem comes back if I'm using some form of Garamond font. None of the solutions suggested work.

I'm using TeX Live 2018 on Debian Linux 10 "Buster".

First, here's test.tex

\documentclass{article}
%\usepackage{garamondx}
%\usepackage{ebgaramond}
%\usepackage{urw-garamond}
%\usepackage[urw-garamond]{mathdesign}
%\usepackage{cmbright}
\usepackage{helvet}

\begin{document}

\section{Letters}
\subsection{Valid Letters}
AA Aa aA aa\\
BB Bb bB bb\\
CD Cd cD cd\\
\subsection{Invalid Letters}
FF Ff fF ff\\
FI Fi fI fi\\

\section{Strings}
a string of text\\
a fine string of text\\
a definition of an efficient and fine string of text\\
finally, the problem is solved!\\

\end{document}

And now the config file:

\Preamble{xhtml,NoFonts, -css}
\Configure{HtmlPar}
{\EndP\Tg<p>}
{\EndP\Tg<p>}
{\HCode{</p>\Hnewline}}
{\HCode{</p>\Hnewline}}
\Configure{emph}{\ifvmode\ShowPar\fi\HCode{<em>}}{\HCode{</em>}}
\Configure{textbf}{\ifvmode\ShowPar\fi\HCode{<b>}}{\HCode{</b>}}
\Configure{textit}{\ifvmode\ShowPar\fi\HCode{<i>}}{\HCode{</i>}}
\Configure{textsc}{\ifvmode\ShowPar\fi\HCode{<font style="font-variant: small-caps">}}{\HCode{</font>}}
\begin{document}
\EndPreamble

And the invocation:

make4ht -u -c test -s test
8

The issue is that there are no support font files for EB Garamond or other fonts you tested. tex4ht needs supporting htf files for 8-bit fonts. They contain mappings from the font characters to Unicode, which is necessary especially for stuff like ligatures or accented letters.

Creation of the htf files is not easy, the majority of htf files has been created by hand. When no htf font is found, a default mapping is used. It usually works for basic Latin text, but it may fail for symbols and especially ligatures.

You can see tex4ht complaining about missing htf files for EB Garamond when you run command tex4ht test:

(/usr/local/texlive/2018/texmf-dist/fonts/tfm/public/ebgaramond/EBGaramond12-Italic-osf-sc-ot1.tfm)
--- warning --- Couldn't find font `EBGaramond12-Italic-osf-sc-ot1.htf' (char codes: 0--127)
(/usr/local/texlive/2018/texmf-dist/fonts/tfm/public/ebgaramond/EBGaramond12-Italic-osf-ot1.tfm)
--- warning --- Couldn't find font `EBGaramond12-Italic-osf-ot1.htf' (char codes: 0--146)
(/usr/local/texlive/2018/texmf-dist/fonts/tfm/public/ebgaramond/EBGaramond12-Regular-osf-ot1.tfm)
--- warning --- Couldn't find font `EBGaramond12-Regular-osf-ot1.htf' (char codes: 0--138)

I've created set of tools, called Htfgen for an automatic htf file generation. The following Lua script uses libraries provided by Htfgen to generate htf files for fonts reported as missing in the tex4ht run. Save it as makehtf.lua:

kpse.set_program_name("luatex")
local lfs = require "lfs"
local htflib = require "htflibs.htflib"
local fontobj = require "htflibs.fontobj"

-- load a map file. pdftex.map should contain all possible fonts
local fonts = fontobj("pdftex")


local function write_file(htfname, contents)
  local f = io.open(htfname, "w")
  f:write(contents)
  f:close()
end

local function find_missing_fonts(tex4ht_output)
  local missing_fonts = {}
  for htf_font in tex4ht_output:gmatch("Couldn't find font `(.-)%.htf") do
    table.insert(missing_fonts, htf_font)
  end
  return missing_fonts
end

-- make test run on the dvi/xdv file to find unsupported fonts
local function run_tex4ht(dvifile)
  -- redirect stderr
  local ext = dvifile:match("^.+(%..+)$")
  local command = io.popen("tex4ht -" .. ext .. " " .. dvifile .. " 2>&1", "r")
  local result = command:read("*all")
  command:close()
  return find_missing_fonts(result)
end

local missing_fonts = run_tex4ht(arg[1])

for _, fontfile in ipairs(missing_fonts) do
  local fontobject 
  -- the virtual fonts have priority over tfm fonts
  local vffile = kpse.find_file(fontfile, "vf")
  if vffile then
    fontobject = fonts:load_virtual_font(vffile)
  else
    local tfmfile = kpse.find_file(fontfile, "tfm")
    if tfmfile then
      fontobject = fonts:load_tfm_font(tfmfile)
    end
  end
  if fontobject then
    local htfname = fontfile .. ".htf"
    print("writing " .. htfname)
    write_file(htfname, htflib.fontobj_to_htf_table(fontobject).."\n" .. htflib.fontobj_get_css(fontobject) .."\n")
    for _, missing in ipairs(fontobject.missing_glyphs) do
      print("Missing glyph", missing)
    end
  end

end

It can be executed in this way:

texlua makehtf.lua test.dvi

It should print something like this:

writing EBGaramond12-Regular-osf-sc-ot1.htf
writing EBGaramond12-Italic-osf-sc-ot1.htf
writing EBGaramond12-Italic-osf-ot1.htf
writing EBGaramond12-Regular-osf-ot1.htf

and create these htf files. I will post them here.

EBGaramond12-Regular-osf-ot1.htf:

EBGaramond12-Regular-osf-ot1 0 138
'&#x0393;' '' Gamma 0
'&#x0394;' '' uni0394 1
'&#x0398;' '' Theta 2
'&#x039B;' '' Lambda 3
'&#x039E;' '' Xi 4
'&#x03A0;' '' Pi 5
'&#x03A3;' '' Sigma 6
'&#x03A5;' '' Upsilon 7
'&#x03A6;' '' Phi 8
'&#x03A8;' '' Psi 9
'&#x03A9;' '' uni03A9 10
'' ''  
'' ''  
'' ''  
'' ''  
'' ''  
'&#x0131;' '' dotlessi 16
'&#x0237;' '' uni0237 17
'`' '' grave 18
'&#x00B4;' '' acute 19
'&#x02C7;' '' caron 20
'&#x02D8;' '' breve 21
'&#x00AF;' '' macron 22
'&#x02DA;' '' ring 23
'&#x00B8;' '' cedilla 24
'&#x00DF;' '' germandbls 25
'&#x00E6;' '' ae 26
'&#x0153;' '' oe 27
'&#x00F8;' '' oslash 28
'&#x00C6;' '' AE 29
'&#x0152;' '' OE 30
'&#x00D8;' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'&#x201D;' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'&#x2019;' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'&#x00A1;' '' exclamdown 60
'=' '' equal 61
'&#x00BF;' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'&#x201C;' '' quotedblleft 92
']' '' bracketright 93
'&#x02C6;' '' circumflex 94
'&#x02D9;' '' dotaccent 95
'&#x2018;' '' quoteleft 96
'a' '' a 97
'b' '' b 98
'c' '' c 99
'd' '' d 100
'e' '' e 101
'f' '' f 102
'g' '' g 103
'h' '' h 104
'i' '' i 105
'j' '' j 106
'k' '' k 107
'l' '' l 108
'm' '' m 109
'n' '' n 110
'o' '' o 111
'p' '' p 112
'q' '' q 113
'r' '' r 114
's' '' s 115
't' '' t 116
'u' '' u 117
'v' '' v 118
'w' '' w 119
'x' '' x 120
'y' '' y 121
'z' '' z 122
'&#x2013;' '' endash 123
'&#x2014;' '' emdash 124
'&#x02DD;' '' hungarumlaut 125
'&#x02DC;' '' tilde 126
'&#x00A8;' '' dieresis 127
'fi' '' f._i i.dotless 128
'f' '' f._f 129
'fl' '' f._asc l.f_ 130
'fj' '' f._i j.dotless 131
'fb' '' f._asc b.f_ 132
'fh' '' f._asc h.f_ 133
'fk' '' f._asc k.f_ 134
'' ''  
'' ''  
't' '' t.f_ 137
'Qy' '' Q_y 138
EBGaramond12-Regular-osf-ot1 0 138
htfcss:  EBGaramond12-Regular-osf-ot1  font-family: 'EB Garamond 12', serif;

EBGaramond12-Italic-osf-sc-ot1.htf

EBGaramond12-Italic-osf-sc-ot1 0 127
'&#x0393;' '' Gamma 0
'&#x0394;' '' uni0394 1
'&#x0398;' '' Theta 2
'&#x039B;' '' Lambda 3
'&#x039E;' '' Xi 4
'&#x03A0;' '' Pi 5
'&#x03A3;' '' Sigma 6
'&#x03A5;' '' Upsilon 7
'&#x03A6;' '' Phi 8
'&#x03A8;' '' Psi 9
'&#x03A9;' '' uni03A9 10
'' ''  
'' ''  
'' ''  
'' ''  
'' ''  
'&#x0131;' '' dotlessi.sc 16
'&#x0237;' '' uni0237 17
'`' '' grave 18
'&#x00B4;' '' acute 19
'&#x02C7;' '' caron 20
'&#x02D8;' '' breve 21
'&#x00AF;' '' macron 22
'&#x02DA;' '' ring 23
'&#x00B8;' '' cedilla 24
'ss' '' s.sc s.sc 25
'&#x00E6;' '' ae.sc 26
'&#x0153;' '' oe.sc 27
'&#x00F8;' '' oslash.sc 28
'&#x00C6;' '' AE 29
'&#x0152;' '' OE 30
'&#x00D8;' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'&#x201D;' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'&#x2019;' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'&#x00A1;' '' exclamdown 60
'=' '' equal 61
'&#x00BF;' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'&#x201C;' '' quotedblleft 92
']' '' bracketright 93
'&#x02C6;' '' circumflex 94
'&#x02D9;' '' dotaccent 95
'&#x2018;' '' quoteleft 96
'a' '' a.sc 97
'b' '' b.sc 98
'c' '' c.sc 99
'd' '' d.sc 100
'e' '' e.sc 101
'f' '' f.sc 102
'g' '' g.sc 103
'h' '' h.sc 104
'i' '' i.sc 105
'j' '' j.sc 106
'k' '' k.sc 107
'l' '' l.sc 108
'm' '' m.sc 109
'n' '' n.sc 110
'o' '' o.sc 111
'p' '' p.sc 112
'q' '' q.sc 113
'r' '' r.sc 114
's' '' s.sc 115
't' '' t.sc 116
'u' '' u.sc 117
'v' '' v.sc 118
'w' '' w.sc 119
'x' '' x.sc 120
'y' '' y.sc 121
'z' '' z.sc 122
'&#x2013;' '' endash 123
'&#x2014;' '' emdash 124
'&#x02DD;' '' hungarumlaut 125
'&#x02DC;' '' tilde 126
'&#x00A8;' '' dieresis 127
EBGaramond12-Italic-osf-sc-ot1 0 127
htfcss:  EBGaramond12-Italic-osf-sc-ot1  font-style: italic; font-variant: small-caps; font-family: 'EB Garamond 12', serif;

EBGaramond12-Italic-osf-ot1.htf:

EBGaramond12-Italic-osf-ot1 0 146
'&#x0393;' '' Gamma 0
'&#x0394;' '' uni0394 1
'&#x0398;' '' Theta 2
'&#x039B;' '' Lambda 3
'&#x039E;' '' Xi 4
'&#x03A0;' '' Pi 5
'&#x03A3;' '' Sigma 6
'&#x03A5;' '' Upsilon 7
'&#x03A6;' '' Phi 8
'&#x03A8;' '' Psi 9
'&#x03A9;' '' uni03A9 10
'' ''  
'' ''  
'' ''  
'' ''  
'' ''  
'&#x0131;' '' dotlessi 16
'&#x0237;' '' uni0237 17
'`' '' grave 18
'&#x00B4;' '' acute 19
'&#x02C7;' '' caron 20
'&#x02D8;' '' breve 21
'&#x00AF;' '' macron 22
'&#x02DA;' '' ring 23
'&#x00B8;' '' cedilla 24
'&#x00DF;' '' germandbls 25
'&#x00E6;' '' ae 26
'&#x0153;' '' oe 27
'&#x00F8;' '' oslash 28
'&#x00C6;' '' AE 29
'&#x0152;' '' OE 30
'&#x00D8;' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'&#x201D;' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'&#x2019;' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'&#x00A1;' '' exclamdown 60
'=' '' equal 61
'&#x00BF;' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'&#x201C;' '' quotedblleft 92
']' '' bracketright 93
'&#x02C6;' '' circumflex 94
'&#x02D9;' '' dotaccent 95
'&#x2018;' '' quoteleft 96
'a' '' a 97
'b' '' b 98
'c' '' c 99
'd' '' d 100
'e' '' e 101
'f' '' f 102
'g' '' g 103
'h' '' h 104
'i' '' i 105
'j' '' j 106
'k' '' k 107
'l' '' l 108
'm' '' m 109
'n' '' n 110
'o' '' o 111
'p' '' p 112
'q' '' q 113
'r' '' r 114
's' '' s 115
't' '' t 116
'u' '' u 117
'v' '' v 118
'w' '' w 119
'x' '' x 120
'y' '' y 121
'z' '' z 122
'&#x2013;' '' endash 123
'&#x2014;' '' emdash 124
'&#x02DD;' '' hungarumlaut 125
'&#x02DC;' '' tilde 126
'&#x00A8;' '' dieresis 127
'&#xFB00;' '' f_f 128
'&#xFB01;' '' uniFB01 129
'&#xFB02;' '' uniFB02 130
'&#xFB03;' '' uniFB03 131
'&#xFB04;' '' uniFB04 132
'fh' '' f_h 133
'fk' '' f_k 134
'fb' '' f_b 135
'ft' '' f_t 136
'fj' '' f_j 137
'gy' '' g_y 138
'gg' '' g_g 139
'gj' '' g_j 140
'ffb' '' f_f_b 141
'ffh' '' f_f_h 142
'ffj' '' f_f_j 143
'ff{' '' f_f_k 144
'fft' '' f_f_t 145
'Qy' '' Q_y 146
EBGaramond12-Italic-osf-ot1 0 146
htfcss:  EBGaramond12-Italic-osf-ot1  font-style: italic; font-family: 'EB Garamond 12', serif;

EBGaramond12-Regular-osf-ot1.htf:

EBGaramond12-Regular-osf-ot1 0 138
'&#x0393;' '' Gamma 0
'&#x0394;' '' uni0394 1
'&#x0398;' '' Theta 2
'&#x039B;' '' Lambda 3
'&#x039E;' '' Xi 4
'&#x03A0;' '' Pi 5
'&#x03A3;' '' Sigma 6
'&#x03A5;' '' Upsilon 7
'&#x03A6;' '' Phi 8
'&#x03A8;' '' Psi 9
'&#x03A9;' '' uni03A9 10
'' ''  
'' ''  
'' ''  
'' ''  
'' ''  
'&#x0131;' '' dotlessi 16
'&#x0237;' '' uni0237 17
'`' '' grave 18
'&#x00B4;' '' acute 19
'&#x02C7;' '' caron 20
'&#x02D8;' '' breve 21
'&#x00AF;' '' macron 22
'&#x02DA;' '' ring 23
'&#x00B8;' '' cedilla 24
'&#x00DF;' '' germandbls 25
'&#x00E6;' '' ae 26
'&#x0153;' '' oe 27
'&#x00F8;' '' oslash 28
'&#x00C6;' '' AE 29
'&#x0152;' '' OE 30
'&#x00D8;' '' Oslash 31
' ' '' space 32
'!' '' exclam 33
'&#x201D;' '' quotedblright 34
'#' '' numbersign 35
'$' '' dollar 36
'%' '' percent.sc 37
'&' '' ampersand 38
'&#x2019;' '' quoteright 39
'(' '' parenleft 40
')' '' parenright 41
'*' '' asterisk 42
'+' '' plus 43
',' '' comma 44
'-' '' hyphen 45
'.' '' period 46
'/' '' slash 47
'0' '' zero 48
'1' '' one 49
'2' '' two 50
'3' '' three 51
'4' '' four 52
'5' '' five 53
'6' '' six 54
'7' '' seven 55
'8' '' eight 56
'9' '' nine 57
':' '' colon 58
';' '' semicolon 59
'&#x00A1;' '' exclamdown 60
'=' '' equal 61
'&#x00BF;' '' questiondown 62
'?' '' question 63
'@' '' at 64
'A' '' A 65
'B' '' B 66
'C' '' C 67
'D' '' D 68
'E' '' E 69
'F' '' F 70
'G' '' G 71
'H' '' H 72
'I' '' I 73
'J' '' J 74
'K' '' K 75
'L' '' L 76
'M' '' M 77
'N' '' N 78
'O' '' O 79
'P' '' P 80
'Q' '' Q 81
'R' '' R 82
'S' '' S 83
'T' '' T 84
'U' '' U 85
'V' '' V 86
'W' '' W 87
'X' '' X 88
'Y' '' Y 89
'Z' '' Z 90
'[' '' bracketleft 91
'&#x201C;' '' quotedblleft 92
']' '' bracketright 93
'&#x02C6;' '' circumflex 94
'&#x02D9;' '' dotaccent 95
'&#x2018;' '' quoteleft 96
'a' '' a 97
'b' '' b 98
'c' '' c 99
'd' '' d 100
'e' '' e 101
'f' '' f 102
'g' '' g 103
'h' '' h 104
'i' '' i 105
'j' '' j 106
'k' '' k 107
'l' '' l 108
'm' '' m 109
'n' '' n 110
'o' '' o 111
'p' '' p 112
'q' '' q 113
'r' '' r 114
's' '' s 115
't' '' t 116
'u' '' u 117
'v' '' v 118
'w' '' w 119
'x' '' x 120
'y' '' y 121
'z' '' z 122
'&#x2013;' '' endash 123
'&#x2014;' '' emdash 124
'&#x02DD;' '' hungarumlaut 125
'&#x02DC;' '' tilde 126
'&#x00A8;' '' dieresis 127
'fi' '' f._i i.dotless 128
'f' '' f._f 129
'fl' '' f._asc l.f_ 130
'fj' '' f._i j.dotless 131
'fb' '' f._asc b.f_ 132
'fh' '' f._asc h.f_ 133
'fk' '' f._asc k.f_ 134
'' ''  
'' ''  
't' '' t.f_ 137
'Qy' '' Q_y 138
EBGaramond12-Regular-osf-ot1 0 138
htfcss:  EBGaramond12-Regular-osf-ot1  font-family: 'EB Garamond 12', serif;

This is the resulting HTML:

enter image description here

The used TeX file:

\documentclass{article}
%\usepackage{garamondx}
\usepackage{ebgaramond}
%\usepackage{urw-garamond}
%\usepackage[urw-garamond]{mathdesign}
%\usepackage{cmbright}
% \usepackage{helvet}

\begin{document}

\section{Letters}
\subsection{Valid Letters}
AA Aa aA aa\\
BB Bb bB bb\\
CD Cd cD cd\\
\subsection{Invalid Letters}
FF Ff fF ff\\
FI Fi fI fi\\

\bgroup
\itshape
FF Ff fF ff\\
FI Fi fI fi\\

\scshape

FF Ff fF ff\\
FI Fi fI fi\\

\normalfont
\scshape

FF Ff fF ff\\
FI Fi fI fi\\

\egroup

\section{Strings}
a string of text\\
a fine string of text\\
a definition of an efficient and fine string of text\\
finally, the problem is solved!\\

\end{document}
  • This works with ebgaramond and libertine, but not garamondx, which is what I need because it includes bold. – Frotz Nov 9 '18 at 2:41
  • Also, having problems getting this working with xelatex. – Frotz Nov 9 '18 at 4:06
  • @Frotz different mechanism is used with xelatex, the ligatures here seems OK, but style is missing, which seems like a bug in tex4ht – michal.h21 Nov 9 '18 at 15:05
  • @Frotz I don't have garamondx installed, so I cannot test it. but you can try to run the Lua script from my answer to make the htf files – michal.h21 Nov 9 '18 at 15:06
  • I did try the Lua script with the garamondx font installed. This is what I got: ...1/home/dave/texmf/tex/latex/htfgen/htflibs/pfbparser.lua:13: bad argument #1 to 'open' (string expected, got nil) – Frotz Nov 10 '18 at 1:23

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.